-
Notifications
You must be signed in to change notification settings - Fork 29
Handle Rawtype more gracefully #1438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
84daaaf
2a374b5
e161f8e
d596468
08171af
4a7f361
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,16 @@ public Void visitWildcard(AnnotatedWildcardType wildcard, Void aVoid) { | |
| } | ||
| visitedNodes.put(wildcard, null); | ||
|
|
||
| // Raw wildcard args are already fixed up in visitDeclared. | ||
| // Recursive traversal through scan(wildcard.getExtendsBound(), ...) can | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand what this comment is trying to say. The body of the then-block calls scan on both bounds of the wildcard. Is this intended? What is the problem with re-entering? |
||
| // re-enter visitWildcard with a synthesized raw wildcard object that is | ||
| // not identity-equal to the parent type argument wildcard. | ||
| if (AnnotatedTypes.isTypeArgOfRawType(wildcard)) { | ||
| scan(wildcard.getExtendsBound(), null); | ||
| scan(wildcard.getSuperBound(), null); | ||
| return null; | ||
| } | ||
|
|
||
| Element typeParamElement = TypesUtils.wildcardToTypeParam(wildcard.getUnderlyingType()); | ||
| if (typeParamElement == null && !parents.isEmpty()) { | ||
| typeParamElement = getTypeParameterElement(wildcard, parents.peekFirst()); | ||
|
|
@@ -212,7 +222,8 @@ private void applyAnnosFromBound( | |
| * | ||
| * @param typeArg a typeArg of {@code declaredType} | ||
| * @param declaredType the type in which {@code typeArg} is a type argument | ||
| * @return the type parameter in {@code declaredType} that corresponds to {@code typeArg} | ||
| * @return the type parameter in {@code declaredType} that corresponds to {@code typeArg}, or | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change can be undone again? |
||
| * null if not found (which can happen with raw types) | ||
| */ | ||
| private Element getTypeParameterElement( | ||
| @FindDistinct AnnotatedTypeMirror typeArg, AnnotatedDeclaredType declaredType) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| public class RawtypeCrash<V> { | ||
| RawtypeCrash<? extends V> nullObj = null; | ||
| Object obj = ((RawtypeCrash) null).nullObj; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Raw wildcard" doesn't make sense, does it? You mean "If the wildcard is a type argument to a raw type" or something like that?