forked from typetools/checker-framework
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stubs: Allow recursively parsing enclosing classes (#305)
- Loading branch information
Showing
10 changed files
with
137 additions
and
61 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
checker/jtreg/stubs/defaultqualinstub/default-on-class/List.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,3 @@ | ||
public abstract class List<T> { | ||
abstract void retainAll(List<?> other); | ||
} |
4 changes: 4 additions & 0 deletions
4
checker/jtreg/stubs/defaultqualinstub/default-on-class/MutableList.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,4 @@ | ||
public abstract class MutableList<T> extends List<T> { | ||
@Override | ||
abstract void retainAll(List<?> other); | ||
} |
22 changes: 22 additions & 0 deletions
22
checker/jtreg/stubs/defaultqualinstub/default-on-class/Test.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,22 @@ | ||
import org.checkerframework.checker.nullness.qual.*; | ||
|
||
/* | ||
* @test | ||
* @summary Defaults applied on class will not be inherited. | ||
* | ||
* @compile -XDrawDiagnostics -Xlint:unchecked List.java | ||
* @compile -XDrawDiagnostics -Xlint:unchecked MutableList.java | ||
* @compile/fail/ref=test.out -XDrawDiagnostics -Xlint:unchecked -processor org.checkerframework.checker.nullness.NullnessChecker -Anomsgtext -Astubs=list.astub -Werror Test.java | ||
*/ | ||
|
||
public class Test { | ||
// l1 has type List<? extends @NonNull Object> | ||
// mutableList has type MutableList<? extends @Nullable Object> | ||
void foo(List<?> l1, MutableList<?> mutableList) { | ||
// retainAll only accepts List with non-null elements | ||
l1.retainAll(mutableList); | ||
|
||
// l2 has type List<? extends @NonNull Object> | ||
List<?> l2 = mutableList; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
checker/jtreg/stubs/defaultqualinstub/default-on-class/list.astub
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,8 @@ | ||
import org.checkerframework.framework.qual.DefaultQualifier; | ||
import org.checkerframework.framework.qual.TypeUseLocation; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
|
||
@DefaultQualifier(value = NonNull.class, locations = TypeUseLocation.UPPER_BOUND) | ||
public class List<T> { | ||
abstract void retainAll(List<?> other); | ||
} |
3 changes: 3 additions & 0 deletions
3
checker/jtreg/stubs/defaultqualinstub/default-on-class/test.out
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,3 @@ | ||
Test.java:17:22: compiler.err.proc.messager: (argument.type.incompatible) | ||
Test.java:20:22: compiler.err.proc.messager: (assignment.type.incompatible) | ||
2 errors |
16 changes: 16 additions & 0 deletions
16
checker/tests/nullness-safedefaultsbytecode/AnnotatedJdkTest.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,16 @@ | ||
import org.checkerframework.checker.nullness.qual.*; | ||
|
||
import java.util.HashMap; | ||
import java.util.Set; | ||
|
||
// There should be no warnings for the following operations | ||
// if the annotated JDK is loaded properly | ||
public class AnnotatedJdkTest { | ||
String toStringTest(Object v) { | ||
return v.toString(); | ||
} | ||
|
||
Set<@KeyFor("#1") String> keySetTest(HashMap<String, Object> map) { | ||
return map.keySet(); | ||
} | ||
} |
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