mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
substitute base class according to resolve place
EA-90836 - assert: InferenceSession.collectApplicabilityConstraints
This commit is contained in:
+8
-5
@@ -1614,7 +1614,7 @@ public class InferenceSession {
|
||||
}
|
||||
|
||||
if (methodContainingClass != null) {
|
||||
psiSubstitutor = TypeConversionUtil.getClassSubstitutor(methodContainingClass, containingClass, psiSubstitutor);
|
||||
psiSubstitutor = JavaClassSupers.getInstance().getSuperClassSubstitutor(methodContainingClass, containingClass, reference.getResolveScope(), psiSubstitutor);
|
||||
LOG.assertTrue(psiSubstitutor != null, "derived: " + containingClass +
|
||||
"; super: " + methodContainingClass +
|
||||
"; reference: " + reference.getText() +
|
||||
@@ -1631,7 +1631,7 @@ public class InferenceSession {
|
||||
final PsiType pType = signature.getParameterTypes()[0];
|
||||
|
||||
// 15.13.1 If the ReferenceType is a raw type, and there exists a parameterization of this type, T, that is a supertype of P1,
|
||||
// the type to search is the result of capture conversion (5.1.10) applied to T;
|
||||
// the type to search is the result of capture conversion (5.1.10) applied to T;
|
||||
// otherwise, the type to search is the same as the type of the first search. Again, the type arguments, if any, are given by the method reference.
|
||||
if (PsiUtil.isRawSubstitutor(containingClass, psiSubstitutor)) {
|
||||
PsiType normalizedPType = PsiUtil.captureToplevelWildcards(pType, myContext);
|
||||
@@ -1646,7 +1646,7 @@ public class InferenceSession {
|
||||
mySiteSubstitutor = mySiteSubstitutor.putAll(receiverSubstitutor);
|
||||
|
||||
if (methodContainingClass != null) {
|
||||
final PsiSubstitutor superSubstitutor = TypeConversionUtil.getClassSubstitutor(methodContainingClass, containingClass, receiverSubstitutor);
|
||||
final PsiSubstitutor superSubstitutor = JavaClassSupers.getInstance().getSuperClassSubstitutor(methodContainingClass, containingClass, reference.getResolveScope(), receiverSubstitutor);
|
||||
LOG.assertTrue(superSubstitutor != null, "mContainingClass: " + methodContainingClass.getName() + "; containingClass: " + containingClass.getName());
|
||||
mySiteSubstitutor = mySiteSubstitutor.putAll(superSubstitutor);
|
||||
}
|
||||
@@ -1660,8 +1660,11 @@ public class InferenceSession {
|
||||
addConstraint(new TypeCompatibilityConstraint(substituteWithInferenceVariables(qType), pType));
|
||||
|
||||
if (methodContainingClass != null) {
|
||||
psiSubstitutor = TypeConversionUtil.getClassSubstitutor(methodContainingClass, containingClass, psiSubstitutor);
|
||||
LOG.assertTrue(psiSubstitutor != null, "derived: " + containingClass + "; super: " + methodContainingClass);
|
||||
psiSubstitutor = JavaClassSupers.getInstance().getSuperClassSubstitutor(methodContainingClass, containingClass, reference.getResolveScope(), psiSubstitutor);
|
||||
LOG.assertTrue(psiSubstitutor != null, "derived: " + containingClass +
|
||||
"; super: " + methodContainingClass +
|
||||
"; reference: " + reference.getText() +
|
||||
"; containingFile: " + reference.getContainingFile().getName());
|
||||
}
|
||||
|
||||
for (int i = 0; i < signature.getParameterTypes().length - 1; i++) {
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package p;
|
||||
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class PersistentMap<K, V> extends FileReader {
|
||||
public void close() throws IOException {}
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package p;
|
||||
import java.io.*;
|
||||
|
||||
class Subst {
|
||||
PersistentMap<Integer, String> messages;
|
||||
|
||||
{
|
||||
register(() -> catchAndWarn(messages::close));
|
||||
}
|
||||
|
||||
static void register(Runnable r) {}
|
||||
|
||||
private static void catchAndWarn(ThrowableRunnable runnable) {
|
||||
try {
|
||||
runnable.run();
|
||||
}
|
||||
catch (IOException e) {}
|
||||
}
|
||||
|
||||
interface ThrowableRunnable {
|
||||
void run() throws IOException;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -217,6 +217,16 @@ public class MultipleJdksHighlightingTest extends UsefulTestCase {
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
public void testMethodReferencePointingToDifferentJdk() throws Exception {
|
||||
ModuleRootModificationUtil.addDependency(myJava8Module, myJava3Module);
|
||||
final String testName = getTestName(false);
|
||||
myFixture.copyFileToProject("java3/p/" + testName + ".java");
|
||||
myFixture.copyFileToProject("java8/p/" + testName + ".java");
|
||||
|
||||
myFixture.configureByFiles("java8/p/" + testName + ".java", "java3/p/" + testName + ".java");
|
||||
myFixture.checkHighlighting();
|
||||
}
|
||||
|
||||
public void testInheritorsOfJdkClassOnlyInModulesWithThatJdk() {
|
||||
ModuleRootModificationUtil.addDependency(myJava8Module, myJava7Module);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user