-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the direct super type of Enums (#6127)
- Loading branch information
Showing
9 changed files
with
82 additions
and
44 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...ker/src/main/java/org/checkerframework/checker/tainting/TaintingAnnotatedTypeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.checkerframework.checker.tainting; | ||
|
||
import java.util.Set; | ||
import javax.lang.model.element.AnnotationMirror; | ||
import org.checkerframework.checker.tainting.qual.Untainted; | ||
import org.checkerframework.common.basetype.BaseAnnotatedTypeFactory; | ||
import org.checkerframework.common.basetype.BaseTypeChecker; | ||
import org.checkerframework.javacutil.AnnotationBuilder; | ||
import org.checkerframework.javacutil.AnnotationMirrorSet; | ||
|
||
/** Annotated type factory for the Tainting Checker. */ | ||
public class TaintingAnnotatedTypeFactory extends BaseAnnotatedTypeFactory { | ||
|
||
/** The {@code @}{@link Untainted} annotation mirror. */ | ||
private final AnnotationMirror UNTAINTED; | ||
|
||
/** A singleton set containing the {@code @}{@link Untainted} annotation mirror. */ | ||
private final AnnotationMirrorSet setOfUntainted; | ||
|
||
/** | ||
* Creates a {@link TaintingAnnotatedTypeFactory}. | ||
* | ||
* @param checker the tainting checker | ||
*/ | ||
public TaintingAnnotatedTypeFactory(BaseTypeChecker checker) { | ||
super(checker); | ||
this.UNTAINTED = AnnotationBuilder.fromClass(getElementUtils(), Untainted.class); | ||
this.setOfUntainted = AnnotationMirrorSet.singleton(UNTAINTED); | ||
postInit(); | ||
} | ||
|
||
@Override | ||
protected Set<AnnotationMirror> getEnumConstructorQualifiers() { | ||
return setOfUntainted; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import java.util.EnumSet; | ||
import org.checkerframework.checker.tainting.qual.Tainted; | ||
import org.checkerframework.checker.tainting.qual.Untainted; | ||
|
||
class Issue6110 { | ||
enum TestEnum { | ||
ONE, | ||
@Untainted TWO | ||
} | ||
|
||
static void test(Enum<@Untainted TestEnum> o) { | ||
|
||
@Tainted TestEnum e = TestEnum.ONE; | ||
o.compareTo(TestEnum.ONE); | ||
o.compareTo(TestEnum.TWO); | ||
|
||
EnumSet<@Tainted TestEnum> s1 = EnumSet.of(TestEnum.ONE); | ||
// :: error: (assignment) | ||
EnumSet<@Untainted TestEnum> s2 = EnumSet.of(TestEnum.ONE); | ||
EnumSet<@Untainted TestEnum> s3 = EnumSet.of(TestEnum.TWO); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters