FE: fix visibility check in LazyImportScope #KT-23727 Fixed
This commit is contained in:
+6
@@ -6910,6 +6910,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("internalLeakBug.kt")
|
||||||
|
public void testInternalLeakBug() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/internalLeakBug.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("internalSetterOverridden.kt")
|
@TestMetadata("internalSetterOverridden.kt")
|
||||||
public void testInternalSetterOverridden() throws Exception {
|
public void testInternalSetterOverridden() throws Exception {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableListMultimap
|
|||||||
import com.google.common.collect.ListMultimap
|
import com.google.common.collect.ListMultimap
|
||||||
import gnu.trove.THashSet
|
import gnu.trove.THashSet
|
||||||
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMapper
|
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMapper
|
||||||
|
import org.jetbrains.kotlin.config.LanguageFeature
|
||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilityUtils.isVisibleIgnoringReceiver
|
import org.jetbrains.kotlin.descriptors.DescriptorVisibilityUtils.isVisibleIgnoringReceiver
|
||||||
@@ -241,7 +242,15 @@ class LazyImportScope(
|
|||||||
val visibility = (descriptor as DeclarationDescriptorWithVisibility).visibility
|
val visibility = (descriptor as DeclarationDescriptorWithVisibility).visibility
|
||||||
val includeVisible = filteringKind == FilteringKind.VISIBLE_CLASSES
|
val includeVisible = filteringKind == FilteringKind.VISIBLE_CLASSES
|
||||||
if (!visibility.mustCheckInImports()) return includeVisible
|
if (!visibility.mustCheckInImports()) return includeVisible
|
||||||
return isVisibleIgnoringReceiver(descriptor, components.moduleDescriptor, components.languageVersionSettings) == includeVisible
|
val fromDescriptor =
|
||||||
|
if (components.languageVersionSettings.supportsFeature(LanguageFeature.ProperInternalVisibilityCheckInImportingScope)) {
|
||||||
|
packageFragment ?: components.moduleDescriptor
|
||||||
|
} else {
|
||||||
|
components.moduleDescriptor
|
||||||
|
}
|
||||||
|
return isVisibleIgnoringReceiver(
|
||||||
|
descriptor, fromDescriptor, components.languageVersionSettings
|
||||||
|
) == includeVisible
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// !LANGUAGE: +ProperInternalVisibilityCheckInImportingScope
|
||||||
|
// See also: KT-23727
|
||||||
|
// WITH_STDLIB
|
||||||
|
// MODULE: m1
|
||||||
|
// FILE: Foo.kt
|
||||||
|
|
||||||
|
package foo
|
||||||
|
|
||||||
|
internal annotation class Volatile
|
||||||
|
|
||||||
|
// MODULE: m2(m1)
|
||||||
|
// FILE: Bar.kt
|
||||||
|
|
||||||
|
import foo.*
|
||||||
|
|
||||||
|
class Bar {
|
||||||
|
@Volatile
|
||||||
|
var v = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
val bar = Bar()
|
||||||
|
return if (bar.v == 0) "OK" else "FAIL: ${bar.v}"
|
||||||
|
}
|
||||||
+6
@@ -6838,6 +6838,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("internalLeakBug.kt")
|
||||||
|
public void testInternalLeakBug() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/internalLeakBug.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("internalSetterOverridden.kt")
|
@TestMetadata("internalSetterOverridden.kt")
|
||||||
public void testInternalSetterOverridden() throws Exception {
|
public void testInternalSetterOverridden() throws Exception {
|
||||||
|
|||||||
+6
@@ -6910,6 +6910,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("internalLeakBug.kt")
|
||||||
|
public void testInternalLeakBug() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/internalLeakBug.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("internalSetterOverridden.kt")
|
@TestMetadata("internalSetterOverridden.kt")
|
||||||
public void testInternalSetterOverridden() throws Exception {
|
public void testInternalSetterOverridden() throws Exception {
|
||||||
|
|||||||
+6
@@ -187,6 +187,12 @@ public class JvmIrAgainstOldBoxTestGenerated extends AbstractJvmIrAgainstOldBoxT
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("internalLeakBug.kt")
|
||||||
|
public void testInternalLeakBug() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/internalLeakBug.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("internalSetterOverridden.kt")
|
@TestMetadata("internalSetterOverridden.kt")
|
||||||
public void testInternalSetterOverridden() throws Exception {
|
public void testInternalSetterOverridden() throws Exception {
|
||||||
|
|||||||
+6
@@ -187,6 +187,12 @@ public class JvmOldAgainstIrBoxTestGenerated extends AbstractJvmOldAgainstIrBoxT
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("internalLeakBug.kt")
|
||||||
|
public void testInternalLeakBug() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/internalLeakBug.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("internalSetterOverridden.kt")
|
@TestMetadata("internalSetterOverridden.kt")
|
||||||
public void testInternalSetterOverridden() throws Exception {
|
public void testInternalSetterOverridden() throws Exception {
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ enum class LanguageFeature(
|
|||||||
EliminateAmbiguitiesWithExternalTypeParameters(KOTLIN_1_7),
|
EliminateAmbiguitiesWithExternalTypeParameters(KOTLIN_1_7),
|
||||||
EliminateAmbiguitiesOnInheritedSamInterfaces(KOTLIN_1_7),
|
EliminateAmbiguitiesOnInheritedSamInterfaces(KOTLIN_1_7),
|
||||||
ConsiderExtensionReceiverFromConstrainsInLambda(KOTLIN_1_7, kind = BUG_FIX), // KT-49832
|
ConsiderExtensionReceiverFromConstrainsInLambda(KOTLIN_1_7, kind = BUG_FIX), // KT-49832
|
||||||
|
ProperInternalVisibilityCheckInImportingScope(KOTLIN_1_7, kind = BUG_FIX),
|
||||||
|
|
||||||
// 1.8
|
// 1.8
|
||||||
|
|
||||||
|
|||||||
+6
@@ -6987,6 +6987,12 @@ public class NativeExtBlackBoxTestGenerated extends AbstractNativeBlackBoxTest {
|
|||||||
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/interfaceDelegationAndBridgesProcessing.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("internalLeakBug.kt")
|
||||||
|
public void testInternalLeakBug() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/compileKotlinAgainstKotlin/internalLeakBug.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("internalSetterOverridden.kt")
|
@TestMetadata("internalSetterOverridden.kt")
|
||||||
public void testInternalSetterOverridden() throws Exception {
|
public void testInternalSetterOverridden() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user