Skip to content

Commit

Permalink
Updates to better match main-eisop reference checker (#505)
Browse files Browse the repository at this point in the history
  • Loading branch information
wmdietl committed Apr 22, 2024
1 parent 45d2204 commit 5e5ce85
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 34 deletions.
1 change: 0 additions & 1 deletion samples/AnnotatedElementIsAnnotationPresent.java
Expand Up @@ -32,7 +32,6 @@ Object check(AnnotatedElement element, Class<Foo> clazz) {

Object checkWildcard(AnnotatedElement element, Class<? extends Foo> clazz) {
if (element.isAnnotationPresent(clazz)) {
// :: error: jspecify_but_expect_error
return element.getAnnotation(clazz);
}
return "";
Expand Down
26 changes: 11 additions & 15 deletions samples/ComplexParametric.java
Expand Up @@ -43,7 +43,7 @@ interface SuperSuper<T extends @Nullable Object> {

void checkNeverNull(Lib<? extends Object> lib);

<U> void checkUnspecNull(Lib<@NullnessUnspecified U> lib);
<U extends @Nullable Object> void checkUnspecNull(Lib<@NullnessUnspecified U> lib);
}

interface SuperNeverNever<T extends Object & Foo> extends SuperSuper<T> {
Expand Down Expand Up @@ -82,7 +82,6 @@ default void x() {

interface SuperNeverUnspec<T extends Object & @NullnessUnspecified Foo> extends SuperSuper<T> {
default void x() {
// :: error: jspecify_but_expect_warning
checkNeverNull(t());
// :: error: jspecify_nullness_not_enough_information
checkUnspecNull(t());
Expand Down Expand Up @@ -117,19 +116,18 @@ default void x() {

interface SuperNeverUnionNull<T extends Object & @Nullable Foo> extends SuperSuper<T> {
default void x() {
// :: error: jspecify_but_expect_error
checkNeverNull(t());
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
checkUnspecNull(t());
checkT(t());
// :: error: jspecify_nullness_not_enough_information
checkTUnspec(t());
// :: error: jspecify_nullness_mismatch
checkTUnionNull(t());

// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
checkNeverNull(tUnspec());
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
checkUnspecNull(tUnspec());
// :: error: jspecify_nullness_not_enough_information
checkT(tUnspec());
Expand All @@ -140,7 +138,7 @@ default void x() {

// :: error: jspecify_nullness_mismatch
checkNeverNull(tUnionNull());
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
this.<T>checkUnspecNull(tUnionNull());
// :: error: jspecify_nullness_mismatch
checkT(tUnionNull());
Expand All @@ -152,7 +150,6 @@ default void x() {

interface SuperUnspecNever<T extends @NullnessUnspecified Object & Foo> extends SuperSuper<T> {
default void x() {
// :: error: jspecify_but_expect_warning
checkNeverNull(t());
// :: error: jspecify_nullness_not_enough_information
checkUnspecNull(t());
Expand Down Expand Up @@ -197,19 +194,18 @@ interface SuperUnspecUnionNull<T extends @NullnessUnspecified Object & @Nullable

interface SuperUnionNullNever<T extends @Nullable Object & Foo> extends SuperSuper<T> {
default void x() {
// :: error: jspecify_but_expect_error
checkNeverNull(t());
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
checkUnspecNull(t());
checkT(t());
// :: error: jspecify_nullness_not_enough_information
checkTUnspec(t());
// :: error: jspecify_nullness_mismatch
checkTUnionNull(t());

// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
checkNeverNull(tUnspec());
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
checkUnspecNull(tUnspec());
// :: error: jspecify_nullness_not_enough_information
checkT(tUnspec());
Expand All @@ -220,7 +216,7 @@ default void x() {

// :: error: jspecify_nullness_mismatch
checkNeverNull(tUnionNull());
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
this.<T>checkUnspecNull(tUnionNull());
// :: error: jspecify_nullness_mismatch
checkT(tUnionNull());
Expand Down Expand Up @@ -250,7 +246,7 @@ default void x() {

// :: error: jspecify_nullness_mismatch
checkNeverNull(tUnspec());
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
checkUnspecNull(tUnspec());
// :: error: jspecify_nullness_not_enough_information
checkT(tUnspec());
Expand All @@ -261,7 +257,7 @@ default void x() {

// :: error: jspecify_nullness_mismatch
checkNeverNull(tUnionNull());
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
this.<T>checkUnspecNull(tUnionNull());
// :: error: jspecify_nullness_mismatch
checkT(tUnionNull());
Expand Down
4 changes: 0 additions & 4 deletions samples/MapGetWildcardValueType.java
Expand Up @@ -21,15 +21,13 @@
class MapGetWildcardValueType {
Object keySetObject(Map<Object, ? extends Object> map) {
for (Object o : map.keySet()) {
// :: error: jspecify_but_expect_error
return map.get(o);
}
return "";
}

Object containsKeyObject(Map<Object, ? extends Object> map, Object o) {
if (map.containsKey(o)) {
// :: error: jspecify_but_expect_error
return map.get(o);
}
return "";
Expand All @@ -53,7 +51,6 @@ Object containsKeyObjectUnionNull(Map<Object, ? extends @Nullable Object> map, O

<V extends @Nullable Object> V keySetV(Map<Object, ? extends V> map, V defaultValue) {
for (Object o : map.keySet()) {
// :: error: jspecify_but_expect_error
return map.get(o);
}
return defaultValue;
Expand All @@ -62,7 +59,6 @@ Object containsKeyObjectUnionNull(Map<Object, ? extends @Nullable Object> map, O
<V extends @Nullable Object> V containsKeyV(
Map<Object, ? extends V> map, Object o, V defaultValue) {
if (map.containsKey(o)) {
// :: error: jspecify_but_expect_error
return map.get(o);
}
return defaultValue;
Expand Down
6 changes: 3 additions & 3 deletions samples/MultiBoundTypeVariableUnspecToObject.java
Expand Up @@ -30,7 +30,7 @@ <T extends Object & Lib> Object x0(@NullnessUnspecified T x) {
}

<T extends Object & @Nullable Lib> Object x2(@NullnessUnspecified T x) {
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
return x;
}

Expand All @@ -51,12 +51,12 @@ <T extends Object & Lib> Object x0(@NullnessUnspecified T x) {
}

<T extends @Nullable Object & Lib> Object x6(@NullnessUnspecified T x) {
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
return x;
}

<T extends @Nullable Object & @NullnessUnspecified Lib> Object x7(@NullnessUnspecified T x) {
// :: error: jspecify_nullness_not_enough_information jspecify_but_expect_error
// :: error: jspecify_nullness_not_enough_information
return x;
}

Expand Down
2 changes: 0 additions & 2 deletions samples/MultiplePathsToTypeVariable.java
Expand Up @@ -47,13 +47,11 @@ <T> Object x3(TUnspecBounded<T, ? extends T> t) {
return t.get();
}

// :: error: jspecify_but_expect_warning
<T> Object x4(TUnspecBounded<T, ? extends @NullnessUnspecified T> t) {
// :: error: jspecify_nullness_not_enough_information
return t.get();
}

// :: error: jspecify_but_expect_warning
<T> Object x5(TUnspecBounded<T, ? extends @Nullable T> t) {
// :: error: jspecify_nullness_not_enough_information
return t.get();
Expand Down
Expand Up @@ -31,8 +31,8 @@ class Test {}
class Instances {
static final NullnessUnspecifiedTypeParameter<Object> A1 =
new NullnessUnspecifiedTypeParameter<>();
// :: error: jspecify_nullness_mismatch
static final NullnessUnspecifiedTypeParameter<@Nullable Object> A2 =
// :: error: jspecify_nullness_mismatch
new NullnessUnspecifiedTypeParameter<>();
static final Test X = new Test();
}
Expand Down
2 changes: 1 addition & 1 deletion samples/packageDefault/packagedefault/Bar.java
Expand Up @@ -19,7 +19,7 @@

class Bar {
Object x(@Nullable Object o) {
// test:cannot-convert:Object? to Object!
// :: error: test:cannot-convert:Object? to Object!
return o;
}
}
14 changes: 7 additions & 7 deletions samples/selfType/selftype/SelfType.java
Expand Up @@ -32,7 +32,7 @@ class C<E extends C<E>> extends SelfType<E> {}
// :: error: jspecify_nullness_not_enough_information
class AK extends SelfType<AK> {}

// test:cannot-convert:AK? to SelfType!<AK!>
// :: error: test:cannot-convert:AK? to SelfType!<AK!>
class AKN extends SelfType<@Nullable AK> {}

class BK extends B {}
Expand All @@ -41,7 +41,7 @@ class BK extends B {}
class CK extends C<CK> {}

@NullMarked
// test:cannot-convert:CK? to C!<CK!>
// :: error: test:cannot-convert:CK? to C!<CK!>
abstract class Super extends C<@Nullable CK> {
abstract AK ak();

Expand All @@ -57,21 +57,21 @@ abstract class Super extends C<@Nullable CK> {
abstract class CKN extends Super {
public void main() {
ak().foo(ak());
// test:cannot-convert:null? to AK!
// :: error: test:cannot-convert:null? to AK!
ak().foo(null);

// test:cannot-convert:null? to AK!
// :: error: test:cannot-convert:null? to AK!
akn().foo(null);

bk().foo(bk());
// test:cannot-convert:null? to B!
// :: error: test:cannot-convert:null? to B!
bk().foo(null);

ck().foo(ck());
// test:cannot-convert:null? to CK!
// :: error: test:cannot-convert:null? to CK!
ck().foo(null);

// test:cannot-convert:null? to CK!
// :: error: test:cannot-convert:null? to CK!
ckn().foo(null);
}
}

0 comments on commit 5e5ce85

Please sign in to comment.