From d6e0f26899e9553f869591601f0e469b8cc31de3 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Tue, 5 Apr 2022 18:59:01 -0400 Subject: [PATCH] Handle nested anonymous classes in field initializers. Fixes #210. --- checker/tests/tainting/NestedAnonymous.java | 14 ++++++++++++++ docs/CHANGELOG.md | 1 + .../framework/util/element/VariableApplier.java | 3 ++- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 checker/tests/tainting/NestedAnonymous.java diff --git a/checker/tests/tainting/NestedAnonymous.java b/checker/tests/tainting/NestedAnonymous.java new file mode 100644 index 00000000000..4fe15a787e2 --- /dev/null +++ b/checker/tests/tainting/NestedAnonymous.java @@ -0,0 +1,14 @@ +import org.checkerframework.checker.tainting.qual.Tainted; +import org.checkerframework.checker.tainting.qual.Untainted; + +class NestedAnonymous { + Object o1 = new @Tainted Object() {}; + Object o2 = new Outer.@Tainted Inner() {}; + + // :: error: (assignment.type.incompatible) + Outer.@Untainted Inner unt = new Outer.@Tainted Inner() {}; + + static class Outer { + static class Inner {} + } +} diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 26b16c7da5a..5accf53bb6e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,6 +6,7 @@ Version 3.21.4-eisop2 (April ?, 2022) **Implementation details:** **Closed issues:** +eisop#210. Version 3.21.4-eisop1 (April 4, 2022) diff --git a/framework/src/main/java/org/checkerframework/framework/util/element/VariableApplier.java b/framework/src/main/java/org/checkerframework/framework/util/element/VariableApplier.java index 7924b891b52..415088af4be 100644 --- a/framework/src/main/java/org/checkerframework/framework/util/element/VariableApplier.java +++ b/framework/src/main/java/org/checkerframework/framework/util/element/VariableApplier.java @@ -83,7 +83,8 @@ protected TargetType[] validTargets() { TargetType.CONSTRUCTOR_REFERENCE, TargetType.METHOD_REFERENCE_TYPE_ARGUMENT, TargetType.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT, - TargetType.METHOD_FORMAL_PARAMETER + TargetType.METHOD_FORMAL_PARAMETER, + TargetType.CLASS_EXTENDS }; }