Created
October 25, 2020 05:26
-
-
Save RayStarkMC/a16fc61f66337b0881db5b84ce122bfe to your computer and use it in GitHub Desktop.
メソッド参照時の型指定が意味を成さない問題のサンプルコード
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.UnaryOperator; | |
public class GenericMethodReferenceIssueSample { | |
static <T> T genericMethod(T t) { | |
return t; | |
} | |
static <T> UnaryOperator<T> of(UnaryOperator<T> t) { | |
return t; | |
} | |
public static void main(String[] args) { | |
var f = of(GenericMethodReferenceIssueSample::<Integer>genericMethod); //コンパイルエラー | |
f.apply(1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment