-
Bug
-
Resolution: Fixed
-
P2
-
7
-
b136
-
generic
-
generic
-
Verified
The specs for the utility method javax.lang.model.util.Types.asElement(TypeMirror) says:
-----------------------------------------------------------------------------------
Returns the element corresponding to a type.
The type may be a DeclaredType or TypeVariable.
Returns null if the type is not one with a corresponding element.
-----------------------------------------------------------------------------------
However the method returns null if invoked with the ErrorType instance.
Such behavior looks contradicting to the specs because:
1. ErrorType extends DeclaredType
2. ErrorType does have a corresponding element which can be retrieved using:
if (typeMirror.getKind() == TypeKind.ERROR) {
element = ((ErrorType) typeMirror).asElement();
}
-----------------------------------------------------------------------------------
Returns the element corresponding to a type.
The type may be a DeclaredType or TypeVariable.
Returns null if the type is not one with a corresponding element.
-----------------------------------------------------------------------------------
However the method returns null if invoked with the ErrorType instance.
Such behavior looks contradicting to the specs because:
1. ErrorType extends DeclaredType
2. ErrorType does have a corresponding element which can be retrieved using:
if (typeMirror.getKind() == TypeKind.ERROR) {
element = ((ErrorType) typeMirror).asElement();
}