Skip to content

Commit

Permalink
Use instantiation of inference variable. (#6638)
Browse files Browse the repository at this point in the history
  • Loading branch information
smillst committed Jun 3, 2024
1 parent 463c4eb commit cac43aa
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
27 changes: 27 additions & 0 deletions checker/tests/nullness/Issue6635.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;

public class Issue6635 {
@FunctionalInterface
public interface ThrowingRunnable<X extends Throwable> {
void run() throws X;
}

@FunctionalInterface
public interface ThrowingConsumer<T, X extends Throwable> {
void accept(T t) throws X;
}

public static ThrowingRunnable<Exception> closing(@Nullable AutoCloseable resource) {
return disposing(resource, AutoCloseable::close);
}

public static <T extends @NonNull Object, X extends Throwable> ThrowingRunnable<X> disposing(
@Nullable T resource, ThrowingConsumer<? super T, X> disposer) {
return () -> {
if (resource != null) {
disposer.accept(resource);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,12 @@ public ConstraintSet getCheckedExceptionConstraints(
if (ei.isProper()) {
properTypes.add((ProperType) ei);
} else {
es.add((UseOfVariable) ei);
UseOfVariable varEi = (UseOfVariable) ei;
if (varEi.getVariable().getInstantiation() != null) {
properTypes.add(varEi.getVariable().getInstantiation());
} else {
es.add((UseOfVariable) ei);
}
}
}
if (es.isEmpty()) {
Expand Down

0 comments on commit cac43aa

Please sign in to comment.