[FIR] Fix setting file in supertypes resolution
^KT-49652 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
e11ffc75e4
commit
499b97d51e
+6
@@ -3989,6 +3989,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/kotlinJavaKotlinHierarchy.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/kotlinJavaKotlinHierarchy.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("privateAliasInSamePackage.kt")
|
||||||
|
public void testPrivateAliasInSamePackage() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/privateAliasInSamePackage.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("protectedInCompanion.kt")
|
@TestMetadata("protectedInCompanion.kt")
|
||||||
public void testProtectedInCompanion() throws Exception {
|
public void testProtectedInCompanion() throws Exception {
|
||||||
|
|||||||
+5
@@ -3574,6 +3574,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/kotlinJavaKotlinHierarchy.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/kotlinJavaKotlinHierarchy.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateAliasInSamePackage.kt")
|
||||||
|
public void testPrivateAliasInSamePackage() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/privateAliasInSamePackage.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("protectedInCompanion.kt")
|
@TestMetadata("protectedInCompanion.kt")
|
||||||
public void testProtectedInCompanion() throws Exception {
|
public void testProtectedInCompanion() throws Exception {
|
||||||
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/protectedInCompanion.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/protectedInCompanion.kt");
|
||||||
|
|||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
FILE: First.kt
|
||||||
|
package first
|
||||||
|
|
||||||
|
private final typealias Key = R|kotlin/String|
|
||||||
|
FILE: Third.kt
|
||||||
|
package first
|
||||||
|
|
||||||
|
public open class Base<T> : R|kotlin/Any| {
|
||||||
|
public constructor<T>(): R|first/Base<T>| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final fun get(): R|T?| {
|
||||||
|
^get Null(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class Derived : R|first/Base<second/Second.Key>| {
|
||||||
|
public constructor(): R|first/Derived| {
|
||||||
|
super<R|first/Base<second/Second.Key>|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final fun test(d: R|first/Derived|): R|kotlin/Unit| {
|
||||||
|
R|<local>/d|.R|SubstitutionOverride<first/Derived.get: R|second/Second.Key?|>|()?.{ $subj$.R|second/Second.Key.foo|() }
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
// ISSUE: KT-49652
|
||||||
|
// FILE: First.kt
|
||||||
|
package first
|
||||||
|
|
||||||
|
private typealias Key = String
|
||||||
|
|
||||||
|
// FILE: second/Second.java
|
||||||
|
package second
|
||||||
|
|
||||||
|
public class Second {
|
||||||
|
public static class Key {
|
||||||
|
public void foo() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bar() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Third.kt
|
||||||
|
package first
|
||||||
|
|
||||||
|
import second.Second.*
|
||||||
|
import second.Second
|
||||||
|
|
||||||
|
open class Base<T> {
|
||||||
|
fun get(): T? = null
|
||||||
|
}
|
||||||
|
|
||||||
|
// Key is resolved to first.Key. In fact, should be second.Second.Key, because first.Key is private-in-file
|
||||||
|
class Derived : Base<Key>()
|
||||||
|
|
||||||
|
fun test(d: Derived) {
|
||||||
|
d.get()?.foo()
|
||||||
|
}
|
||||||
+6
@@ -3989,6 +3989,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/kotlinJavaKotlinHierarchy.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/kotlinJavaKotlinHierarchy.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("privateAliasInSamePackage.kt")
|
||||||
|
public void testPrivateAliasInSamePackage() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/privateAliasInSamePackage.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("protectedInCompanion.kt")
|
@TestMetadata("protectedInCompanion.kt")
|
||||||
public void testProtectedInCompanion() throws Exception {
|
public void testProtectedInCompanion() throws Exception {
|
||||||
|
|||||||
+6
@@ -3989,6 +3989,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
|||||||
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/kotlinJavaKotlinHierarchy.kt");
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/kotlinJavaKotlinHierarchy.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("privateAliasInSamePackage.kt")
|
||||||
|
public void testPrivateAliasInSamePackage() throws Exception {
|
||||||
|
runTest("compiler/fir/analysis-tests/testData/resolve/visibility/privateAliasInSamePackage.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("protectedInCompanion.kt")
|
@TestMetadata("protectedInCompanion.kt")
|
||||||
public void testProtectedInCompanion() throws Exception {
|
public void testProtectedInCompanion() throws Exception {
|
||||||
|
|||||||
+14
-2
@@ -211,7 +211,7 @@ open class FirSupertypeResolverVisitor(
|
|||||||
private val scopeForLocalClass: PersistentList<FirScope>? = null,
|
private val scopeForLocalClass: PersistentList<FirScope>? = null,
|
||||||
private val localClassesNavigationInfo: LocalClassesNavigationInfo? = null,
|
private val localClassesNavigationInfo: LocalClassesNavigationInfo? = null,
|
||||||
private val firProviderInterceptor: FirProviderInterceptor? = null,
|
private val firProviderInterceptor: FirProviderInterceptor? = null,
|
||||||
private val useSiteFile: FirFile? = null,
|
private var useSiteFile: FirFile? = null,
|
||||||
containingDeclarations: List<FirDeclaration> = emptyList(),
|
containingDeclarations: List<FirDeclaration> = emptyList(),
|
||||||
) : FirDefaultVisitor<Unit, Any?>() {
|
) : FirDefaultVisitor<Unit, Any?>() {
|
||||||
private val supertypeGenerationExtensions = session.extensionService.supertypeGenerators
|
private val supertypeGenerationExtensions = session.extensionService.supertypeGenerators
|
||||||
@@ -225,6 +225,16 @@ open class FirSupertypeResolverVisitor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private inline fun <R> withFile(file: FirFile, block: () -> R): R {
|
||||||
|
val oldFile = useSiteFile
|
||||||
|
try {
|
||||||
|
useSiteFile = file
|
||||||
|
return block()
|
||||||
|
} finally {
|
||||||
|
useSiteFile = oldFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getFirClassifierContainerFileIfAny(symbol: FirClassLikeSymbol<*>): FirFile? =
|
private fun getFirClassifierContainerFileIfAny(symbol: FirClassLikeSymbol<*>): FirFile? =
|
||||||
if (firProviderInterceptor != null) firProviderInterceptor.getFirClassifierContainerFileIfAny(symbol)
|
if (firProviderInterceptor != null) firProviderInterceptor.getFirClassifierContainerFileIfAny(symbol)
|
||||||
else session.firProvider.getFirClassifierContainerFileIfAny(symbol.classId)
|
else session.firProvider.getFirClassifierContainerFileIfAny(symbol.classId)
|
||||||
@@ -454,7 +464,9 @@ open class FirSupertypeResolverVisitor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitFile(file: FirFile, data: Any?) {
|
override fun visitFile(file: FirFile, data: Any?) {
|
||||||
visitDeclarationContent(file, null)
|
withFile(file) {
|
||||||
|
visitDeclarationContent(file, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user