Bug 393561 - Function types and Annotations can not be combined
Summary: Function types and Annotations can not be combined
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.4.0   Edit
Hardware: PC Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 384889 404973 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-11-05 10:11 EST by Moritz Eysholdt CLA
Modified: 2013-05-22 07:59 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Moritz Eysholdt CLA 2012-11-05 10:11:43 EST
class Foo {
	(String, String) => void func0 // works
	@Property var (String, String) => void func1 // works
	@Property (String) => void func2 // produces funny linking errors "The method or field String is undefined for the type Foo"
	@Property (String, String) => void func3 // produces funny syntax errors:
	//	Multiple markers at this line 
	// - no viable alternative at input ',' 
	// - missing ')' at 'String' 
	// - The value of the field 
	// - no viable alternative at input ')'
}

workaround: use the "var" or "val" keyword
Comment 1 Sebastian Zarnekow CLA 2012-11-05 10:16:10 EST
It's an ambiguous situation where we use a predicate to bind the parentheses explicitly to the annotation. Linking problems are obviously confusing in that case since the declaration is semantically something like

@Property(String, String)
() => void fun0


Another possible workaround is
@Property() (String, String)=>void fun
Comment 2 Sven Efftinge CLA 2012-11-09 05:09:02 EST
*** Bug 384889 has been marked as a duplicate of this bug. ***
Comment 3 Sven Efftinge CLA 2012-11-09 05:09:20 EST
I don't see how we can fix this. But an improvement would be validation with a quick fix.
Comment 4 Sebastian Zarnekow CLA 2013-04-05 03:34:29 EDT
*** Bug 404973 has been marked as a duplicate of this bug. ***
Comment 5 Sebastian Zarnekow CLA 2013-04-05 03:35:04 EDT
I'd think we can use a predicate to disambiguate these cases.