Created
October 25, 2020 04:50
-
-
Save RayStarkMC/57b143a1bc86b2e35ba4309e64c9ec22 to your computer and use it in GitHub Desktop.
ジェネリッククラスでstaticメソッドの参照に失敗する問題の最小コード
This file contains hidden or 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
import java.util.function.Consumer; | |
public class MethodResolveIssueSample { | |
static class NonGenericClass { | |
static <T> void f() { | |
h(NonGenericClass::<T>methodToBeReferenced); | |
} | |
static <T> void methodToBeReferenced(T t1) {} | |
} | |
static class GenericClass<Unused> { | |
static <T> void f() { | |
h(GenericClass::<T>methodToBeReferenced); // Cannot resolve method. | |
} | |
static <T> void methodToBeReferenced(T t1) {} | |
} | |
static <T> void h(Consumer<T> consumer) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hメソッドの呼び出し時点で
とした場合はコンパイルに通る様子