Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342598 - Inconsistent handling of error types
Summary: Inconsistent handling of error types
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: APT (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-12 11:45 EDT by Olivier Thomann CLA
Modified: 2011-04-21 10:42 EDT (History)
1 user (show)

See Also:


Attachments
Proposed fix (39.25 KB, patch)
2011-04-19 09:11 EDT, Olivier Thomann CLA
no flags Details | Diff
Proposed fix + regression test (46.04 KB, patch)
2011-04-21 10:40 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.