Skip to content

Commit

Permalink
The type of a method invocation is the return type after capture conv…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
smillst committed Jul 28, 2021
1 parent 28e0ac1 commit 82aafe6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 0 additions & 1 deletion checker/tests/nullness/java-unsound/Figure3.java
Expand Up @@ -12,7 +12,6 @@ <B> A coerce(B b) {
// extends @Initialized @Nullable Object super @Initialized @NonNull Void]]
// method return type: A[ extends @Initialized @Nullable Object super @Initialized
// @NonNull Void]
// :: error: (return)
return pair(this.<B>bad(), b).value;
}
}
Expand Down
1 change: 0 additions & 1 deletion checker/tests/nullness/java-unsound/Figure3NC.java
Expand Up @@ -11,7 +11,6 @@ class Constraint<B extends A> extends Type<B> {}
}

<B> A coerce(B b) {
// :: error: (return)
return pair(this.<B>bad(), b).value;
}
}
Expand Down
Expand Up @@ -326,7 +326,7 @@ public AnnotatedTypeMirror visitNewClass(NewClassTree node, AnnotatedTypeFactory
public AnnotatedTypeMirror visitMethodInvocation(
MethodInvocationTree node, AnnotatedTypeFactory f) {
AnnotatedExecutableType ex = f.methodFromUse(node).executableType;
return ex.getReturnType().asUse();
return f.applyCaptureConversion(ex.getReturnType().asUse());
}

@Override
Expand Down
18 changes: 18 additions & 0 deletions framework/tests/all-systems/Issue4829.java
@@ -0,0 +1,18 @@
import java.util.concurrent.Future;
import org.checkerframework.checker.nullness.qual.Nullable;

@SuppressWarnings("all") // Just check for crashes.
public class Issue4829 {

interface ListenableFuture<V extends @Nullable Object> extends Future<V> {}

enum E {}

ListenableFuture<Object> f(E e) {
return g(e);
}

ListenableFuture<? super Object> g(E e) {
throw new AssertionError();
}
}

0 comments on commit 82aafe6

Please sign in to comment.