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

Bug 342598

Summary: Inconsistent handling of error types
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: APTAssignee: Olivier Thomann <Olivier_Thomann>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: eclipse
Version: 3.7   
Target Milestone: 3.7 M7   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Attachments:
Description Flags
Proposed fix
none
Proposed fix + regression test none

Description Olivier Thomann CLA 2011-04-12 11:45:44 EDT
Right now in apt, we can return the kind TypeKind.ERROR for types which are not instances of javax.lang.model.type.ErrorType.
This seems to be inconsistent. When the user gets a type mirror with the kind TypeKind.ERROR, he/she can expect that type mirror to be successfully cast to the type javax.lang.model.type.ErrorType.
We need to be more consistent in the way we handle error types in the apt type system.

The compiler bindings are tagged with the bit org.eclipse.jdt.internal.compiler.lookup.TagBits.HasMissingType now that we better support missing/unresolved types.
Comment 1 Olivier Thomann CLA 2011-04-12 11:47:19 EDT
I'll take care of this. I need to review all usage of TypeKind.ERROR and how the error type instances are being instantiated.
We also need to make sure that any method declared on javax.lang.model.type.DeclaredType can be invoked on an error type without any errors.
Comment 2 Olivier Thomann CLA 2011-04-19 09:11:34 EDT
Created attachment 193576 [details]
Proposed fix
Comment 3 Olivier Thomann CLA 2011-04-21 10:40:37 EDT
Created attachment 193835 [details]
Proposed fix + regression test

Updated regression tests. This is using ProcessingEnvironment.getSourceVersion() to switch between old implementation and new implementation for error types as interfaces.
Tests are passing on JDK6 and JDK7.
Comment 4 Olivier Thomann CLA 2011-04-21 10:42:29 EDT
Walter, I'll release this for M7 so that we get a more consistent handling of error types inside the apt model.
Comment 5 Olivier Thomann CLA 2011-04-21 10:42:56 EDT
Released for 3.7M7.