Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The type of a method invocation is the return type after capture conversion. #4841

Merged
merged 3 commits into from Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
}
}