[FE 1.0] Take into account import aliases during hidden member resolution
This commit is contained in:
+6
@@ -24437,6 +24437,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt36264.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49736.kt")
|
||||
public void testKt49736() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt49736.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localObject.kt")
|
||||
public void testLocalObject() throws Exception {
|
||||
|
||||
+6
@@ -24437,6 +24437,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt36264.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49736.kt")
|
||||
public void testKt49736() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt49736.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localObject.kt")
|
||||
public void testLocalObject() throws Exception {
|
||||
|
||||
+6
@@ -24437,6 +24437,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt36264.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49736.kt")
|
||||
public void testKt49736() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt49736.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localObject.kt")
|
||||
public void testLocalObject() throws Exception {
|
||||
|
||||
+3
@@ -370,6 +370,9 @@ class NewResolutionOldInference(
|
||||
cache.getOrPut(it) { resolutionContext.transformToReceiverWithSmartCastInfo(it) }
|
||||
}
|
||||
|
||||
override fun getNameForGivenImportAlias(name: Name): Name? =
|
||||
resolutionContext.call.callElement.containingKtFile.getNameForGivenImportAlias(name)
|
||||
|
||||
override val lexicalScope: LexicalScope get() = resolutionContext.scope
|
||||
|
||||
override val isDebuggerContext: Boolean get() = resolutionContext.isDebuggerContext
|
||||
|
||||
@@ -408,6 +408,9 @@ class PSICallResolver(
|
||||
}
|
||||
}
|
||||
|
||||
override fun getNameForGivenImportAlias(name: Name): Name? =
|
||||
context.call.callElement.containingKtFile.getNameForGivenImportAlias(name)
|
||||
|
||||
override fun interceptFunctionCandidates(
|
||||
resolutionScope: ResolutionScope,
|
||||
name: Name,
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.parsing.KotlinParserDefinition
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||
@@ -179,6 +180,9 @@ open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) :
|
||||
it.alias != null && fqName == it.importedFqName
|
||||
}?.alias
|
||||
|
||||
fun getNameForGivenImportAlias(name: Name): Name? =
|
||||
importDirectives.find { it.importedName == name }?.importedFqName?.pathSegments()?.last()
|
||||
|
||||
@Deprecated("") // getPackageFqName should be used instead
|
||||
override fun getPackageName(): String {
|
||||
return packageFqName.asString()
|
||||
|
||||
@@ -39,6 +39,8 @@ interface ImplicitScopeTower {
|
||||
|
||||
fun getImplicitReceiver(scope: LexicalScope): ReceiverValueWithSmartCastInfo?
|
||||
|
||||
fun getNameForGivenImportAlias(name: Name): Name?
|
||||
|
||||
val dynamicScope: MemberScope
|
||||
|
||||
val syntheticScopes: SyntheticScopes
|
||||
|
||||
@@ -358,7 +358,8 @@ internal class HidesMembersTowerLevel(scopeTower: ImplicitScopeTower) : Abstract
|
||||
extensionReceiver: ReceiverValueWithSmartCastInfo?,
|
||||
collectCandidates: LexicalScope.(Name, LookupLocation) -> Collection<CallableDescriptor>
|
||||
): Collection<CandidateWithBoundDispatchReceiver> {
|
||||
if (extensionReceiver == null || name !in HIDES_MEMBERS_NAME_LIST) return emptyList()
|
||||
if (extensionReceiver == null) return emptyList()
|
||||
if (name !in HIDES_MEMBERS_NAME_LIST && scopeTower.getNameForGivenImportAlias(name) !in HIDES_MEMBERS_NAME_LIST) return emptyList()
|
||||
|
||||
return scopeTower.lexicalScope.collectCandidates(name, location).filter {
|
||||
it.extensionReceiverParameter != null && it.hasHidesMembersAnnotation()
|
||||
|
||||
@@ -107,7 +107,8 @@ class TowerResolver {
|
||||
private val useOrder: Boolean,
|
||||
private val name: Name
|
||||
) {
|
||||
private val isNameForHidesMember = name in HIDES_MEMBERS_NAME_LIST
|
||||
private val isNameForHidesMember =
|
||||
name in HIDES_MEMBERS_NAME_LIST || implicitScopeTower.getNameForGivenImportAlias(name) in HIDES_MEMBERS_NAME_LIST
|
||||
private val skippedDataForLookup = mutableListOf<TowerData>()
|
||||
|
||||
private val localLevels: Collection<ScopeTowerLevel> by lazy(LazyThreadSafetyMode.NONE) {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.collections.forEach as forEach1
|
||||
|
||||
fun foo() {
|
||||
<!UNRESOLVED_REFERENCE!>z<!>.a.forEach1 { }
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.collections.forEach as forEach1
|
||||
|
||||
fun foo() {
|
||||
<!UNRESOLVED_REFERENCE!>z<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>a<!>.<!OVERLOAD_RESOLUTION_AMBIGUITY!>forEach1<!> { }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
public fun foo(): kotlin.Unit
|
||||
Generated
+6
@@ -24449,6 +24449,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt36264.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt49736.kt")
|
||||
public void testKt49736() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/kt49736.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("localObject.kt")
|
||||
public void testLocalObject() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user