diff --git a/checker/tests/stubparser-nullness/NoExplicitAnnotations.java b/checker/tests/stubparser-nullness/NoExplicitAnnotations.java index 82e72708ca5..5e0dd3d4062 100644 --- a/checker/tests/stubparser-nullness/NoExplicitAnnotations.java +++ b/checker/tests/stubparser-nullness/NoExplicitAnnotations.java @@ -51,6 +51,7 @@ void use( NoExplicitAnnotationsSub2 sub2, NoExplicitAnnotationsSub3 sub3) { nble = sub1.method1(); + // :: error: (assignment.type.incompatible) nn = sub1.method1(); nble = sub2.method2(); nn = sub2.method2(); diff --git a/framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileParser.java b/framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileParser.java index 0557b75cb6f..ef20f024d6e 100644 --- a/framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileParser.java +++ b/framework/src/main/java/org/checkerframework/framework/stub/AnnotationFileParser.java @@ -1521,7 +1521,9 @@ private void clearAnnotations(AnnotatedTypeMirror atype, Type typeDef) { */ // Clear existing annotations, which only makes a difference for // type variables, but doesn't hurt in other cases. - atype.clearAnnotations(); + if (atype.getKind() == TypeKind.TYPEVAR) { + atype.clearAnnotations(); + } } /**