compiler/libec: Fixed warnings on setting LinkList::first = null
[sdk] / compiler / libec / src / pass15.ec
index a9164fc..8a4f2a9 100644 (file)
@@ -9470,11 +9470,20 @@ void ProcessExpressionType(Expression exp)
                      FinishTemplatesContext(context);
 
                      // Mark parameters that were 'thisclass'
-                     /*{
+                     {
                         Type p, op;
                         for(p = functionType.params.first, op = methodType.method.dataType.params.first; p && op; p = p.next, op = op.next)
-                           p.wasThisClass = op.kind == thisClassType;
-                     }*/
+                        {
+                           //p.wasThisClass = op.kind == thisClassType;
+                           if(op.kind == thisClassType)
+                              p.thisClassFrom = methodType.method._class;
+                        }
+                     }
+                     if(methodType.method.dataType.returnType.kind == thisClassType)
+                     {
+                        // functionType.returnType.wasThisClass = true;
+                        functionType.returnType.thisClassFrom = methodType.method._class;
+                     }
                   }
 
                   FreeList(specs, FreeSpecifier);
@@ -10170,6 +10179,7 @@ void ProcessExpressionType(Expression exp)
                      kind = classType;
                      _class = prop ? prop._class.symbol : method ? method._class.symbol : _class.symbol;
                      // wasThisClass = type ? type.wasThisClass : false;
+                     thisClassFrom = type ? type.thisClassFrom : null;
                   };
                }
 
@@ -10304,11 +10314,22 @@ void ProcessExpressionType(Expression exp)
                         ClassTemplateArgument arg = tClass.templateArgs[id];
                         Context context = SetupTemplatesContext(tClass);
                         bool constant = exp.expType.constant;
+                        bool passAsTemplate = false;
+                        Class thisClassFrom = null;
+                        Type t = ProcessTypeString(exp.expType.templateParameter.dataTypeString, false);
+                        if(t && t.kind == classType && t._class)
+                           thisClassFrom = t._class.registered;
+                        FreeType(t);
+
+                        passAsTemplate = tClass.templateClass && (exp.expType.kind != templateType ||
+                           (!exp.expType.templateParameter || (!exp.expType.templateParameter.dataTypeString && !exp.expType.templateParameter.dataType)));
+
                         /*if(!arg.dataType)
                            arg.dataType = ProcessTypeString(arg.dataTypeString, false);*/
                         FreeType(exp.expType);
 
                         exp.expType = ProcessTypeString(arg.dataTypeString, false);
+                        exp.expType.thisClassFrom = thisClassFrom;
                         if(exp.expType.kind == classType && constant) exp.expType.constant = true;
                         else if(exp.expType.kind == pointerType)
                         {
@@ -10324,7 +10345,7 @@ void ProcessExpressionType(Expression exp)
                               exp.expType = ReplaceThisClassType(_class);
                            }
 
-                           if(tClass.templateClass && (exp.expType.kind != templateType || (!exp.expType.templateParameter || (!exp.expType.templateParameter.dataTypeString && !exp.expType.templateParameter.dataType))))
+                           if(passAsTemplate)
                               exp.expType.passAsTemplate = true;
                            //exp.expType.refCount++;
                            if(!exp.destType)