diff --git a/checker/src/main/java/org/checkerframework/checker/pico/PICONoInitAnnotatedTypeFactory.java b/checker/src/main/java/org/checkerframework/checker/pico/PICONoInitAnnotatedTypeFactory.java
index 29d89cf8312..9c48b4c3e49 100644
--- a/checker/src/main/java/org/checkerframework/checker/pico/PICONoInitAnnotatedTypeFactory.java
+++ b/checker/src/main/java/org/checkerframework/checker/pico/PICONoInitAnnotatedTypeFactory.java
@@ -156,11 +156,12 @@ public QualifierHierarchy createQualifierHierarchy() {
@Override
public ParameterizedExecutableType constructorFromUse(NewClassTree tree) {
- boolean hasExplicitAnnos = getExplicitNewClassAnnos(tree).isEmpty();
+ boolean noExplicitAnnotations = getExplicitNewClassAnnos(tree).isEmpty();
ParameterizedExecutableType mType = super.constructorFromUse(tree);
AnnotatedExecutableType method = mType.executableType;
- if (hasExplicitAnnos && method.getReturnType().hasAnnotation(RECEIVER_DEPENDENT_MUTABLE)) {
- method.getReturnType().replaceAnnotation(MUTABLE);
+ if (noExplicitAnnotations
+ && method.getReturnType().hasAnnotation(RECEIVER_DEPENDENT_MUTABLE)) {
+ method.getReturnType().replaceAnnotation(IMMUTABLE);
}
return mType;
}
diff --git a/checker/tests/pico-immutability/HashCodeSafetyExample.java b/checker/tests/pico-immutability/HashCodeSafetyExample.java
index 38bb611dd78..1a0f076c9a1 100644
--- a/checker/tests/pico-immutability/HashCodeSafetyExample.java
+++ b/checker/tests/pico-immutability/HashCodeSafetyExample.java
@@ -7,7 +7,7 @@
public class HashCodeSafetyExample {
public static void main(String[] args) {
A a = new A();
- HashMap m = new @Mutable HashMap<>();
+ Map m = new @Mutable HashMap<>();
m.put(a, "hello");
System.out.println("HashCode before: " + a.hashCode());
// :: error: (illegal.field.write)