Bug 431871 - @Data : order of declaration matters...
Summary: @Data : order of declaration matters...
Status: NEW
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.5.3   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-03 04:43 EDT by Victor Noël CLA
Modified: 2014-04-04 02:07 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 Victor Noël CLA 2014-04-03 04:43:11 EDT
Hi, I found this strange bug.

The following generates correct code:
@Data class A {
	val double a
}
@Data class B extends A {
	val double b
}

The following generates code with error (a is not considered in B):
@Data class B extends A {
	val double b
}
@Data class A {
	val double a
}
Comment 1 Sven Efftinge CLA 2014-04-04 02:07:30 EDT
The technical reason is that model inference is done at once per file from top to bottom. So at the point where for the first class the super type is asked for all members the members haven't been created.

We could specially hadle this case in @Data, i.e. check whereher the super type is in the current class and process it first.
Or we could think about a more holistic improvement in which we do the inference on a per type basis and will lazily trigger inference when a type is referenced from somewhere. This is the way it already works cross file but not with multiple types in the same resource.