-
Notifications
You must be signed in to change notification settings - Fork 352
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use instantiation of inference variable. (#6638)
- Loading branch information
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters