From 07405bccfc7a3b4fd94a34ac1af093ee8c053489 Mon Sep 17 00:00:00 2001 From: zcai Date: Mon, 11 Jul 2022 13:52:24 -0400 Subject: [PATCH 1/2] correct type.invalid.super.wildcard message --- .../checkerframework/common/basetype/BaseTypeValidator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeValidator.java b/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeValidator.java index 6b1a9fa9242..8c5ea2bc2da 100644 --- a/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeValidator.java +++ b/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeValidator.java @@ -638,8 +638,8 @@ protected Void visitParameterizedType(AnnotatedDeclaredType type, ParameterizedT checker.reportError( tree.getTypeArguments().get(i), "type.invalid.super.wildcard", - wildcard.getExtendsBound(), - wildcard.getSuperBound()); + wildcard.getSuperBound(), + wildcard.getExtendsBound()); } } } From aa08bd6271da0f333d7e6f4ba467866a9214c395 Mon Sep 17 00:00:00 2001 From: zcai Date: Mon, 11 Jul 2022 15:41:02 -0400 Subject: [PATCH 2/2] make code more readable --- .../common/basetype/BaseTypeValidator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeValidator.java b/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeValidator.java index 8c5ea2bc2da..3c8eac39285 100644 --- a/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeValidator.java +++ b/framework/src/main/java/org/checkerframework/common/basetype/BaseTypeValidator.java @@ -622,19 +622,19 @@ protected Void visitParameterizedType(AnnotatedDeclaredType type, ParameterizedT // (See https://bugs.openjdk.java.net/browse/JDK-8054309.) // In this case, the Checker Framework uses the annotations on the super // bound of the wildcard and ignores the annotations on the extends bound. + // For example, Set<@1 ? super @2 Object> will collapse into Set<@2 Object>. // So, issue a warning if the annotations on the extends bound are not the // same as the annotations on the super bound. + Set extendsBoundAnnos = + wildcard.getExtendsBound().getAnnotations(); + Set superBoundAnnos = + wildcard.getSuperBound().getEffectiveAnnotations(); if (!(atypeFactory .getQualifierHierarchy() - .isSubtype( - wildcard.getSuperBound().getEffectiveAnnotations(), - wildcard.getExtendsBound().getAnnotations()) + .isSubtype(extendsBoundAnnos, superBoundAnnos) && atypeFactory .getQualifierHierarchy() - .isSubtype( - wildcard.getExtendsBound().getAnnotations(), - wildcard.getSuperBound() - .getEffectiveAnnotations()))) { + .isSubtype(superBoundAnnos, extendsBoundAnnos))) { checker.reportError( tree.getTypeArguments().get(i), "type.invalid.super.wildcard",