Browse Source

* fixed constructor call in class methods

florian 22 years ago
parent
commit
8fcfcc6606
2 changed files with 18 additions and 5 deletions
  1. 11 2
      compiler/ncal.pas
  2. 7 3
      compiler/pexpr.pas

+ 11 - 2
compiler/ncal.pas

@@ -1785,7 +1785,13 @@ type
           { do not create/destroy when called from member function
           { do not create/destroy when called from member function
             without specifying self explicit }
             without specifying self explicit }
           if (nf_member_call in flags) then
           if (nf_member_call in flags) then
-            vmttree:=cpointerconstnode.create(0,voidpointertype)
+            begin
+              if (methodpointer.resulttype.def.deftype=classrefdef) and
+                (procdefinition.proctypeoption=potype_constructor) then
+                vmttree:=methodpointer.getcopy
+              else
+                vmttree:=cpointerconstnode.create(0,voidpointertype);
+            end
         else
         else
           { constructor with extended syntax called from new }
           { constructor with extended syntax called from new }
           if (nf_new_call in flags) then
           if (nf_new_call in flags) then
@@ -2609,7 +2615,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.193  2003-10-08 19:19:45  peter
+  Revision 1.194  2003-10-09 15:00:13  florian
+    * fixed constructor call in class methods
+
+  Revision 1.193  2003/10/08 19:19:45  peter
     * set_varstate cleanup
     * set_varstate cleanup
 
 
   Revision 1.192  2003/10/07 21:14:32  peter
   Revision 1.192  2003/10/07 21:14:32  peter

+ 7 - 3
compiler/pexpr.pas

@@ -1374,8 +1374,9 @@ implementation
                     if possible_error then
                     if possible_error then
                      begin
                      begin
                        do_resulttypepass(p1);
                        do_resulttypepass(p1);
-                       if not(po_classmethod in tcallnode(p1).procdefinition.procoptions) then
-                        Message(parser_e_only_class_methods);
+                       if not(tcallnode(p1).procdefinition.proctypeoption=potype_constructor) and
+                          not(po_classmethod in tcallnode(p1).procdefinition.procoptions) then
+                         Message(parser_e_only_class_methods);
                      end;
                      end;
                   end;
                   end;
 
 
@@ -2417,7 +2418,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.133  2003-10-08 19:19:45  peter
+  Revision 1.134  2003-10-09 15:00:13  florian
+    * fixed constructor call in class methods
+
+  Revision 1.133  2003/10/08 19:19:45  peter
     * set_varstate cleanup
     * set_varstate cleanup
 
 
   Revision 1.132  2003/10/05 12:56:04  peter
   Revision 1.132  2003/10/05 12:56:04  peter