@@ -9084,33 +9084,21 @@ algorithm
90849084 SCode.Encapsulated encflag;
90859085 SCode.Restriction restr;
90869086
9087- // first try without instantiating, if class is in parents
9088- case ((SCode.CLASS()),cdef,env)
9089- equation
9090- ErrorExt.setCheckpoint("getInheritedClassesHelper");
9091- lst = getBaseClasses(cdef, env);
9092- failure({} = lst);
9093- ErrorExt.rollBack("getInheritedClassesHelper");
9094- then
9095- lst;
9096-
9097- // clear any messages that may have been added
9098- case ((SCode.CLASS()),_,_)
9099- equation
9100- ErrorExt.rollBack("getInheritedClassesHelper");
9101- then
9102- fail();
9103-
9104- // if that fails, instantiate, which takes more time
91059087 case ((c as SCode.CLASS(name = id,encapsulatedPrefix = encflag,restriction = restr)),cdef,env)
9106- equation
9088+ algorithm
91079089 ErrorExt.setCheckpoint("getInheritedClassesHelper");
9108- env2 = FGraph.openScope(env, encflag, id, FGraph.restrictionToScopeType(restr));
9109- ci_state = ClassInf.start(restr, FGraph.getGraphName(env2));
9110- (_,env_2,_,_,_) =
9111- Inst.partialInstClassIn(FCore.emptyCache(),env2,InnerOuter.emptyInstHierarchy,
9090+ if SCode.isDerivedClass(c) then
9091+ // for derived classes search in the parent
9092+ env_2 := env;
9093+ else
9094+ // for non-derived classes search from self
9095+ env2 := FGraph.openScope(env, encflag, id, FGraph.restrictionToScopeType(restr));
9096+ ci_state := ClassInf.start(restr, FGraph.getGraphName(env2));
9097+ (_,env_2,_,_,_) :=
9098+ Inst.partialInstClassIn(FCore.emptyCache(),env2,InnerOuter.emptyInstHierarchy,
91129099 DAE.NOMOD(), Prefix.NOPRE(), ci_state, c, SCode.PUBLIC(), {}, 0);
9113- lst = getBaseClasses(cdef, env_2);
9100+ end if;
9101+ lst := getBaseClasses(cdef, env_2);
91149102 ErrorExt.rollBack("getInheritedClassesHelper");
91159103 then
91169104 lst;
@@ -9458,7 +9446,7 @@ protected function getNthInheritedClass2
94589446 input FCore.Graph inEnv4;
94599447 output String outString;
94609448algorithm
9461- outString := matchcontinue (inClass1,inClass2,inInteger3,inEnv4)
9449+ outString := match (inClass1,inClass2,inInteger3,inEnv4)
94629450 local
94639451 list<Absyn.ComponentRef> lst;
94649452 Integer n_1,n;
@@ -9471,30 +9459,26 @@ algorithm
94719459 ClassInf.State ci_state;
94729460 SCode.Encapsulated encflag;
94739461 SCode.Restriction restr;
9474- /* First try without instantiating, if class is in parents */
9475- case ((SCode.CLASS()),cdef,n,env)
9476- equation
9477- lst = getBaseClasses(cdef, env);
9478- cref = listGet(lst, n);
9479- path = Absyn.crefToPath(cref);
9480- str = Absyn.pathString(path);
9481- then
9482- str;
9483- /* If that fails, instantiate, which takes more time */
9462+
94849463 case ((c as SCode.CLASS(name = id,encapsulatedPrefix = encflag,restriction = restr)),cdef,n,env)
9485- equation
9486- env2 = FGraph.openScope(env, encflag, id, FGraph.restrictionToScopeType(restr));
9487- ci_state = ClassInf.start(restr, FGraph.getGraphName(env2));
9488- (_,env_2,_,_,_) =
9489- Inst.partialInstClassIn(FCore.emptyCache(),env2,InnerOuter.emptyInstHierarchy,
9490- DAE.NOMOD(), Prefix.NOPRE(), ci_state, c, SCode.PUBLIC(), {}, 0);
9491- lst = getBaseClasses(cdef, env_2);
9492- cref = listGet(lst, n);
9493- path = Absyn.crefToPath(cref);
9494- str = Absyn.pathString(path);
9464+ algorithm
9465+ // for derived classes, search in parents
9466+ if SCode.isDerivedClass(c) then
9467+ lst := getBaseClasses(cdef, env);
9468+ else // for non-derived classes, search from inside the class
9469+ env2 := FGraph.openScope(env, encflag, id, FGraph.restrictionToScopeType(restr));
9470+ ci_state := ClassInf.start(restr, FGraph.getGraphName(env2));
9471+ (_,env_2,_,_,_) :=
9472+ Inst.partialInstClassIn(FCore.emptyCache(),env2,InnerOuter.emptyInstHierarchy,
9473+ DAE.NOMOD(), Prefix.NOPRE(), ci_state, c, SCode.PUBLIC(), {}, 0);
9474+ lst := getBaseClasses(cdef, env_2);
9475+ end if;
9476+ cref := listGet(lst, n);
9477+ path := Absyn.crefToPath(cref);
9478+ str := Absyn.pathString(path);
94959479 then
94969480 str;
9497- end matchcontinue ;
9481+ end match ;
94989482end getNthInheritedClass2;
94999483
95009484public function getComponentCount
0 commit comments