diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 58c433a1a7ce..278745421c2a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -53,7 +53,7 @@ Removed method `InitializationParentAnnotatedTypeFactory.createUnderInitializati **Closed issues:** -eisop#1247, eisop#1263, eisop#1310, eisop#1326, typetools#7096, eisop#1448, eisop#1543. +eisop#792, eisop#1247, eisop#1263, eisop#1310, eisop#1326, typetools#7096, eisop#1448, eisop#1543. Version 3.49.5 (June 30, 2025) diff --git a/framework/src/main/java/org/checkerframework/framework/type/typeannotator/PropagationTypeAnnotator.java b/framework/src/main/java/org/checkerframework/framework/type/typeannotator/PropagationTypeAnnotator.java index b432c3ae96b7..0d3f2af506a7 100644 --- a/framework/src/main/java/org/checkerframework/framework/type/typeannotator/PropagationTypeAnnotator.java +++ b/framework/src/main/java/org/checkerframework/framework/type/typeannotator/PropagationTypeAnnotator.java @@ -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 + // 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 + * null if not found (which can happen with raw types) */ private Element getTypeParameterElement( @FindDistinct AnnotatedTypeMirror typeArg, AnnotatedDeclaredType declaredType) { diff --git a/framework/tests/viewpointtest/RawtypeCrash.java b/framework/tests/viewpointtest/RawtypeCrash.java new file mode 100644 index 000000000000..e095fe0a69fb --- /dev/null +++ b/framework/tests/viewpointtest/RawtypeCrash.java @@ -0,0 +1,4 @@ +public class RawtypeCrash { + RawtypeCrash nullObj = null; + Object obj = ((RawtypeCrash) null).nullObj; +}