Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 332801 - [compiler][generics] instantiating a generic role cannot be type-checked
Summary: [compiler][generics] instantiating a generic role cannot be type-checked
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTJ (show other bugs)
Version: 0.8   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 0.8 M5   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-16 17:49 EST by Stephan Herrmann CLA
Modified: 2011-01-29 13:44 EST (History)
0 users

See Also:


Attachments
test & fix (4.04 KB, patch)
2011-01-26 19:54 EST, Stephan Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2010-12-16 17:49:00 EST
Given this snippet:

public team class Canonicalization {
  protected class Cache<K,V> { }
  Cache<Integer,String> stringCache = new Cache<Integer, String>();
}

The compiler fails to see compatibility of the field initializer:

Type mismatch: cannot convert from Cache<@tthis[Canonicalization],Object,Object> to Cache<@tthis[Canonicalization],Integer,String>

The same applies when initializing the field in a constructor.
Apparently the allocation expression looses type information.
Comment 1 Stephan Herrmann CLA 2011-01-26 19:54:40 EST
Created attachment 187704 [details]
test & fix

Indeed, role creation dropped type arguments.

Also, LookupEnvironment.createParameterizedType(..) created too many
type bindings, because a wrong (already parameterized) key was used
for lookup into uniqueParameterizedTypeBindings.

Both issues are fixed in the patch.
Comment 2 Stephan Herrmann CLA 2011-01-26 19:56:50 EST
Patch has been committed as r1253, r1254
Comment 3 Stephan Herrmann CLA 2011-01-29 13:44:09 EST
Verified for 0.8M5 using build 201101290806.