[LL FIR, Java] fix resolve contract violation from java symbol provider from supertypes
To create a smart psi type pointer, IJ Platform uses resolve We cannot use resolve from JavaSymbolProvider, as it may lead to resolve contract violation ^KT-59240 Fixed
This commit is contained in:
committed by
Space Team
parent
67d933185a
commit
6992a707dc
+8
@@ -60,3 +60,11 @@ internal class JavaElementDelegatingTypeParameterBoundTypeSourceWithSmartPointer
|
||||
return psi.bounds[boundIndex] as TYPE
|
||||
}
|
||||
}
|
||||
|
||||
internal class JavaElementDelegatingSuperTypeSourceWithSmartPointer(
|
||||
override val psiPointer: SmartPsiElementPointer<out PsiClass>,
|
||||
private val superTypeIndex: Int,
|
||||
override val factory: JavaElementSourceFactory,
|
||||
) : JavaElementDelegatingTypeSourceWithSmartPointer<PsiClass, PsiClassType>() {
|
||||
override fun getType(psi: PsiClass): PsiClassType = psi.superTypes[superTypeIndex]
|
||||
}
|
||||
|
||||
+12
@@ -45,6 +45,18 @@ class JavaElementSourceWithSmartPointerFactory(project: Project) : JavaElementSo
|
||||
)
|
||||
}
|
||||
|
||||
override fun createSuperTypeSource(
|
||||
psiTypeParameterSource: JavaElementPsiSource<out PsiClass>,
|
||||
superTypeIndex: Int
|
||||
): JavaElementTypeSource<PsiClassType> {
|
||||
require(psiTypeParameterSource is JavaElementPsiSourceWithSmartPointer)
|
||||
return JavaElementDelegatingSuperTypeSourceWithSmartPointer(
|
||||
psiTypeParameterSource.pointer,
|
||||
superTypeIndex,
|
||||
psiTypeParameterSource.factory,
|
||||
)
|
||||
}
|
||||
|
||||
override fun <TYPE : PsiType> createExpressionTypeSource(psiExpressionSource: JavaElementPsiSource<out PsiExpression>): JavaElementTypeSource<TYPE> {
|
||||
require(psiExpressionSource is JavaElementPsiSourceWithSmartPointer)
|
||||
return JavaElementDelegatingExpressionTypeSourceWithSmartPointer(psiExpressionSource.pointer, psiExpressionSource.factory)
|
||||
|
||||
+12
@@ -27,6 +27,18 @@ public class DiagnosticCompilerTestFirTestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/accessJavaFromKotlinViaImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("accessJavaFromKotlinViaStaticImport.kt")
|
||||
public void testAccessJavaFromKotlinViaStaticImport() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/accessJavaFromKotlinViaStaticImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("accessJavaFromKotlinViaStaticImport2.kt")
|
||||
public void testAccessJavaFromKotlinViaStaticImport2() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/accessJavaFromKotlinViaStaticImport2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInResolve() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
|
||||
+12
@@ -27,6 +27,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFirTestDataTestGenerated
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/accessJavaFromKotlinViaImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("accessJavaFromKotlinViaStaticImport.kt")
|
||||
public void testAccessJavaFromKotlinViaStaticImport() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/accessJavaFromKotlinViaStaticImport.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("accessJavaFromKotlinViaStaticImport2.kt")
|
||||
public void testAccessJavaFromKotlinViaStaticImport2() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/accessJavaFromKotlinViaStaticImport2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllFilesPresentInResolve() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
|
||||
Reference in New Issue
Block a user