mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-201942 Do not use compiling evaluator for method references - super support
This commit is contained in:
+13
-9
@@ -1220,26 +1220,30 @@ public class EvaluatorBuilderImpl implements EvaluatorBuilder {
|
||||
PsiMethod method = (PsiMethod)resolved;
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
String methodName = "";
|
||||
String findMethodName;
|
||||
String find;
|
||||
String bind = "";
|
||||
if (method.isConstructor()) {
|
||||
findMethodName = "findConstructor";
|
||||
find = "findConstructor(" + containingClass.getQualifiedName() + ".class, mt)";
|
||||
}
|
||||
else if (qualifier instanceof PsiSuperExpression) {
|
||||
find = "in(" + containingClass.getQualifiedName() + ".class).findSpecial(" +
|
||||
containingClass.getQualifiedName() + ".class, \"" + method.getName() + "\", mt, " +
|
||||
containingClass.getQualifiedName() + ".class)";
|
||||
bind = "mh = mh.bindTo(" + qualifier.getText() + ");\n";
|
||||
}
|
||||
else {
|
||||
methodName = ", \"" + method.getName() + "\"";
|
||||
find = containingClass.getQualifiedName() + ".class, \"" + method.getName() + "\", mt)";
|
||||
if (method.hasModifier(JvmModifier.STATIC)) {
|
||||
findMethodName = "findStatic";
|
||||
find = "findStatic(" + find;
|
||||
}
|
||||
else {
|
||||
findMethodName = "findVirtual";
|
||||
bind = "mh = mh.bindTo(" + qualifier.getText() + ")\n";
|
||||
find = "findVirtual(" + find;
|
||||
bind = "mh = mh.bindTo(" + qualifier.getText() + ");\n";
|
||||
}
|
||||
}
|
||||
code =
|
||||
"MethodType mt = MethodType.fromMethodDescriptorString(\"" + JVMNameUtil.getJVMSignature(method) + "\", null);\n" +
|
||||
"MethodHandle mh = MethodHandles.publicLookup()." + findMethodName + "(" +
|
||||
containingClass.getQualifiedName() + ".class " + methodName + ", mt);\n" +
|
||||
"MethodHandle mh = MethodHandles.lookup()." + find + ";\n" +
|
||||
bind +
|
||||
"MethodHandleProxies.asInterfaceInstance(" + interfaceType.getCanonicalText() + ".class, mh);";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user