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

Bug 332801

Summary: [compiler][generics] instantiating a generic role cannot be type-checked
Product: [Tools] Objectteams Reporter: Stephan Herrmann <stephan.herrmann>
Component: OTJAssignee: Stephan Herrmann <stephan.herrmann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 0.8   
Target Milestone: 0.8 M5   
Hardware: Other   
OS: Linux   
Whiteboard:
Attachments:
Description Flags
test & fix none

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.