Skip to content

Commit

Permalink
make @Polydet the default for constructor returns (Fixes typetools#58) (
Browse files Browse the repository at this point in the history
  • Loading branch information
t-rasmud authored May 18, 2019
1 parent ee31b95 commit 17d1a43
Show file tree
Hide file tree
Showing 18 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,12 @@
@PolymorphicQualifier(NonDet.class)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
@DefaultFor({TypeUseLocation.PARAMETER, TypeUseLocation.RETURN, TypeUseLocation.RECEIVER})
@DefaultFor({
TypeUseLocation.PARAMETER,
TypeUseLocation.RETURN,
TypeUseLocation.RECEIVER,
TypeUseLocation.CONSTRUCTOR_RESULT
})
public @interface PolyDet {
/**
* Optionally, {@code @PolyDet} takes one of the four String values "up", "down", "use", or
Expand Down
1 change: 1 addition & 0 deletions checker/tests/determinism/AllTestsMultipleUnions.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ class MyExceptionA extends Throwable implements Cloneable, MyInterface<String> {

class MyExceptionB extends Throwable implements Cloneable, MyInterface<String> {}

// :: error: (super.invocation.invalid)
class SubMyExceptionA extends MyExceptionA {}
}
1 change: 1 addition & 0 deletions checker/tests/determinism/AllTestsUnionCrash.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ class MyExceptionA extends Throwable implements Cloneable, MyInterface<String> {

class MyExceptionB extends Throwable implements Cloneable, MyInterface<String> {}

// :: error: (super.invocation.invalid)
class SubMyExceptionA extends MyExceptionA {}
}
2 changes: 2 additions & 0 deletions checker/tests/determinism/AllTestsUnions.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ class MyExceptionA extends Throwable implements Cloneable, MyInterface<String> {

class MyExceptionB extends Throwable implements Cloneable, MyInterface<String> {}

// :: error: (super.invocation.invalid)
class SubMyExceptionA extends MyExceptionA {}

// :: error: (super.invocation.invalid)
class SubMyExceptionA2 extends MyExceptionA {}
}
1 change: 1 addition & 0 deletions checker/tests/determinism/Issue58.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class Issue58 {
public Issue58(@PolyDet int a) {}

public static void f(@PolyDet int b) {
// :: error: (assignment.type.incompatible)
@Det Issue58 c = new Issue58(b);
}
}
1 change: 1 addition & 0 deletions checker/tests/determinism/TestTypeParams.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void testtypes(@Det int a, @NonDet int y) {
MyClass<String> sobj = new MyClass<String>();
System.out.println(sobj);
MyClass<Integer> nobj = new MyClass<Integer>(y);
// :: error: (argument.type.incompatible)
System.out.println(nobj);
}
}
2 changes: 2 additions & 0 deletions framework/tests/all-systems/FieldAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ class MyException extends RuntimeException {
Object field = new Object();
}

@SuppressWarnings("super.invocation.invalid")
class MyExceptionA extends MyException {}

@SuppressWarnings("super.invocation.invalid")
class MyExceptionB extends MyException {}

@SuppressWarnings("nullness")
Expand Down
1 change: 1 addition & 0 deletions framework/tests/all-systems/GenericTest12b.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ void nodecall(Cell<CONTENT> userObject) {}
}

class RootNode extends Node<Void> {
@SuppressWarnings("super.invocation.invalid")
public RootNode() {
super(new Cell<Void>());
call(new Cell<Void>());
Expand Down
2 changes: 2 additions & 0 deletions framework/tests/all-systems/Issue1442.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ protected void configure(SubConfig<SubMyClass>.SubConfigInner x) {

static class MyClass<A extends MyClass<A>> {}

@SuppressWarnings("super.invocation.invalid")
static class SubMyClass extends MyClass<SubMyClass> {}

static class Config<B extends MyClass<B>> {
Expand All @@ -18,6 +19,7 @@ public T getT() {
}
}

@SuppressWarnings("super.invocation.invalid")
static class SubConfig<C extends MyClass<C>> extends Config<C> {
public class SubConfigInner extends ConfigInner<Thing> {
public C outerClassTypeVar() {
Expand Down
1 change: 1 addition & 0 deletions framework/tests/all-systems/Issue1697.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ abstract static class D<A extends D<A, B>, B extends D.M<A, B>> implements E {
abstract static class M<A extends D<A, B>, B extends M<A, B>> implements E.M {}
}

@SuppressWarnings("super.invocation.invalid")
abstract static class C<A extends C<A, B>, B extends C.M<A, B>> extends D<A, B> {
abstract static class M<A extends C<A, B>, B extends M<A, B>> extends D.M<A, B> {}
}
Expand Down
1 change: 1 addition & 0 deletions framework/tests/all-systems/Issue1698.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

class Issue1698 {
static class B {
@SuppressWarnings("return.type.incompatible")
static C f() {
return new B().new C();
}
Expand Down
2 changes: 2 additions & 0 deletions framework/tests/all-systems/Issue2199.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ public StrangeConstructorTypeArgs(Abstract<String, byte[]> abs) {}

abstract static class Abstract<KEY, VALUE> {}

@SuppressWarnings("super.invocation.invalid")
static class Concrete<K, V> extends Abstract<K, V> {}

@SuppressWarnings("return.type.incompatible")
static StrangeConstructorTypeArgs getStrangeConstructorTypeArgs() {
return new StrangeConstructorTypeArgs(new Concrete<>());
}
Expand Down
1 change: 1 addition & 0 deletions framework/tests/all-systems/Issue2302.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public StrangeConstructorTypeArgs(MyClass<byte[]> abs) {}

static class MyClass<VALUE> {}

@SuppressWarnings("return.type.incompatible")
static StrangeConstructorTypeArgs getStrangeConstructorTypeArgs() {
// Crash with the diamond operator.
// Type inference chooses `Object` as the type argument.
Expand Down
2 changes: 2 additions & 0 deletions framework/tests/all-systems/Issue2446.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
class Issue2446 {
static class One<T, V> {}

@SuppressWarnings("super.invocation.invalid")
static class Two<V, B extends Two<V, B>> extends One<V, B> {}

@SuppressWarnings("super.invocation.invalid")
static class Three<V, B extends Three<V, B>> extends Two<V, B> {}

static <B extends Three<Object, B>> Three<Object, ?> f() {
Expand Down
1 change: 1 addition & 0 deletions framework/tests/all-systems/Issue577.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Banana<T extends Number> extends Apple<int[]> {
@Override
void fooIssue577Outer(int[] array) {}

@SuppressWarnings("super.invocation.invalid")
class InnerBanana extends InnerApple<long[]> {
@Override
<F2> void foo(int[] array, long[] array2, F2 param3) {}
Expand Down
1 change: 1 addition & 0 deletions framework/tests/all-systems/TypeVars.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ void m() {

class Inner1<X extends T> {}

@SuppressWarnings("return.type.incompatible")
public Inner1<T> method1() {
return new Inner1<>();
}
Expand Down
1 change: 1 addition & 0 deletions framework/tests/all-systems/java8inference/Issue1399.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

public class Issue1399 {
static class Box<T> {
@SuppressWarnings("return.type.incompatible")
static <T> Box<T> box(Class<T> type) {
return new Box<T>();
}
Expand Down
1 change: 1 addition & 0 deletions framework/tests/all-systems/java8inference/Issue1419.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
abstract class Issue1419 {
class Map<A> {}

@SuppressWarnings("super.invocation.invalid")
class EnumMap<C extends Enum<C>> extends Map<C> {}

abstract <E extends Enum<E>> Map<E> foo(Map<E> map);
Expand Down

0 comments on commit 17d1a43

Please sign in to comment.