Bug 416932 - Xbase inappropriately allows 'super' to be used without a following method call
Summary: Xbase inappropriately allows 'super' to be used without a following method call
Status: NEW
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.4.0   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-10 10:24 EDT by Ed Merks CLA
Modified: 2013-09-12 03:08 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Merks CLA 2013-09-10 10:24:08 EDT
In this Xtend-based example, Xbase allows the following

package foo

class X {
	def void foo()
	{
		val x = super
	}
}

but that compiles to this Java code that in turn doesn't actually compile:

package foo;

@SuppressWarnings("all")
public class X {
  public void foo() {
    final Object x = super;
  }
}


There needs to be some constraint defined that super is only allowed in the context of a feature call.

I'm not sure if such a constraint can be defined in Xbase, but Xtend and Xcore should not consider something valid if it won't compile to valid Java code.
Comment 1 Ed Merks CLA 2013-09-11 10:21:57 EDT
Note that I think the handling of super is also problematic in the interpreter.  Specifically XbaseInterpreter.invokeOperation(JvmOperation, Object, List<Object>) does not know if it must just invoke the method, or must invoke it on super.  I suppose the interpretation of "super" itself needs to return some special object that's handled by this method.  Any thoughts on how that should work?  I suppose you can't really test calls via "super" in Xbase itself...
Comment 2 Sven Efftinge CLA 2013-09-12 03:08:12 EDT
Yes, interpreting in the context of a certain instance is problematic. Also visibilities etc. are different.

But we should add a validation for the problem in comment #0.