[英]Why am I getting compilation error on this lambda
In the following piece of code I am getting compilation error:在下面的代码中,我遇到了编译错误:
error: method method1 in class MyClass cannot be applied to given types;
MyClass.method1(MyClass.method2());
however if I store MyClass in a variable at line 1, the error is gone但是,如果我将 MyClass 存储在第 1 行的变量中,错误就消失了
var myVar = MyClass.method2();
MyClass.method1(myVar);
Here is the source:这是来源:
class Test {
static void doSomething(Runnable c) {}
static void main() {
doSomething(() -> {
class MyClass {
static void method1(MyClass myClass1) {}
static MyClass method2() {return new MyClass();}
}
MyClass.method1(MyClass.method2()); //Line 1
});
}
}
What is the possible reason for this?这可能是什么原因?
Thanks!谢谢!
This is a compiler bug in OpenJDK: https://bugs.openjdk.org/browse/JDK-8295019这是 OpenJDK 中的编译器错误: https://bugs.openjdk.org/browse/JDK-8295019
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.