Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 356361

Summary: Constructors in handlers shouldn't be "abstract"
Product: z_Archived Reporter: Matt Heitz <mheitz>
Component: EDTAssignee: Project Inbox <edt.compiler-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: pharmon
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Matt Heitz CLA 2011-08-31 11:41:59 EDT
As part of the nullability language changes, we started allowing handlers to have constructors.  Unfortunately we're not allowing people to write a body for their constructors.


handler handleme
	
	private constructor();  // Should be invalid, but no error.
	constructor( i int out );  // Should be invalid, but no error.

	constructor( s string in ) // Should be valid.
		x = foo();
		SysLib.writeStdout( s );
	end

	x int;

	function foo() returns( int )
		return( 1 );
	end
end
Comment 1 Paul Harmon CLA 2011-08-31 16:44:31 EDT
I have released some support for this. You can now define statements, and they are validated and generated into the IR. However, the resolution code needs to be updated to support invoking a constructor from within a constructor. EX:


Handler hand1
  constructor()
   ....
  end

  constructor(f1 int)
   this();
   ...
  end
end

Also, we need to define what rules there are for invoking a constructor in this manner. Java, for instance, only lets you invoke a constructor using "this()" if you are on the first line of a constructor.
Comment 2 Paul Harmon CLA 2011-09-08 08:51:04 EDT
I have fixed the original problem with this. You can now specify statements in the constructors.  

However, the code can still not handle resolution to constructors via the "this" syntax. For example:

Handler myHandler
   field1 int;
   field2 string;

   constructor(p1 int)
      field1 = p1;
   end

   constructor(p1 int, p2 string)
      this(p1);   // this resolution fails in binding and in the IRs
      field2 = p2;
   end

end


Also, we have not yet defined what restrictions may exist for invoking constructors within constructors. In Java, for instance, a constructor invocation must be the first statement inside a constructor.

I am leaving this bug open until the resolution problem is fixed and any validation that is required is written.
Comment 3 Paul Harmon CLA 2011-10-25 14:54:43 EDT
This work has been completed
Comment 4 Matt Heitz CLA 2011-10-25 15:03:31 EDT
Do we have restrictions on invoking constructors within constructors, such as the one in Java?
Comment 5 Paul Harmon CLA 2011-10-26 09:25:52 EDT
Yes, for now I have added valdiation checks so that the syntax:

this(...) 


to invoke a constructor can only be used as the first statement of a constructor.
Comment 6 Matt Heitz CLA 2011-11-01 11:00:27 EDT
Verified.