[FE 1.0] Don't capture projections during compatibility check of supertypes to determine intersection type emptiness
This commit is contained in:
committed by
teamcity
parent
73be9d0a20
commit
6c54b78574
+6
@@ -15223,6 +15223,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/contravariance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("covariance.kt")
|
||||
public void testCovariance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt45461.kt")
|
||||
public void testKt45461() throws Exception {
|
||||
|
||||
+6
@@ -15223,6 +15223,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/contravariance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("covariance.kt")
|
||||
public void testCovariance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt45461.kt")
|
||||
public void testKt45461() throws Exception {
|
||||
|
||||
+6
@@ -15223,6 +15223,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/contravariance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("covariance.kt")
|
||||
public void testCovariance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt45461.kt")
|
||||
public void testKt45461() throws Exception {
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FIR_IDENTICAL
|
||||
class KotlinSharedNativeCompilation() : KotlinMetadataCompilation<KotlinCommonOptions>, AbstractKotlinCompilation<KotlinCommonOptions>()
|
||||
|
||||
interface KotlinCommonOptions
|
||||
|
||||
interface KotlinMetadataCompilation<T : KotlinCommonOptions> : KotlinCompilation<T>
|
||||
|
||||
interface KotlinCompilation<out T : KotlinCommonOptions>
|
||||
|
||||
class KotlinCommonCompilation : KotlinMetadataCompilation<KotlinMultiplatformCommonOptions>, AbstractKotlinCompilation<KotlinMultiplatformCommonOptions>()
|
||||
|
||||
interface KotlinMultiplatformCommonOptions : KotlinCommonOptions
|
||||
|
||||
abstract class AbstractKotlinCompilation<T : KotlinCommonOptions> : KotlinCompilation<T>
|
||||
|
||||
fun main() {
|
||||
val compilation = when {
|
||||
true -> {
|
||||
KotlinSharedNativeCompilation()
|
||||
}
|
||||
else -> KotlinCommonCompilation()
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package
|
||||
|
||||
public fun main(): kotlin.Unit
|
||||
|
||||
public abstract class AbstractKotlinCompilation</*0*/ T : KotlinCommonOptions> : KotlinCompilation<T> {
|
||||
public constructor AbstractKotlinCompilation</*0*/ T : KotlinCommonOptions>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class KotlinCommonCompilation : KotlinMetadataCompilation<KotlinMultiplatformCommonOptions>, AbstractKotlinCompilation<KotlinMultiplatformCommonOptions> {
|
||||
public constructor KotlinCommonCompilation()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinCommonOptions {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinCompilation</*0*/ out T : KotlinCommonOptions> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinMetadataCompilation</*0*/ T : KotlinCommonOptions> : KotlinCompilation<T> {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface KotlinMultiplatformCommonOptions : KotlinCommonOptions {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class KotlinSharedNativeCompilation : KotlinMetadataCompilation<KotlinCommonOptions>, AbstractKotlinCompilation<KotlinCommonOptions> {
|
||||
public constructor KotlinSharedNativeCompilation()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Generated
+6
@@ -15229,6 +15229,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/contravariance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("covariance.kt")
|
||||
public void testCovariance() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/covariance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt45461.kt")
|
||||
public void testKt45461() throws Exception {
|
||||
|
||||
@@ -30,19 +30,20 @@ import org.jetbrains.kotlin.utils.sure
|
||||
import java.util.*
|
||||
|
||||
class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor: TypeSubstitutor) : MemberScope {
|
||||
val substitutor = givenSubstitutor.substitution.wrapWithCapturingSubstitution().buildSubstitutor()
|
||||
val substitutor by lazy { givenSubstitutor.substitution.buildSubstitutor() }
|
||||
|
||||
private val capturingSubstitutor = givenSubstitutor.substitution.wrapWithCapturingSubstitution().buildSubstitutor()
|
||||
private var substitutedDescriptors: MutableMap<DeclarationDescriptor, DeclarationDescriptor>? = null
|
||||
|
||||
private val _allDescriptors by lazy { substitute(workerScope.getContributedDescriptors()) }
|
||||
|
||||
fun substitute(type: KotlinType): KotlinType {
|
||||
if (substitutor.isEmpty) return type
|
||||
return substitutor.safeSubstitute(type) as KotlinType
|
||||
if (capturingSubstitutor.isEmpty) return type
|
||||
return capturingSubstitutor.safeSubstitute(type) as KotlinType
|
||||
}
|
||||
|
||||
private fun <D : DeclarationDescriptor> substitute(descriptor: D): D {
|
||||
if (substitutor.isEmpty) return descriptor
|
||||
if (capturingSubstitutor.isEmpty) return descriptor
|
||||
|
||||
if (substitutedDescriptors == null) {
|
||||
substitutedDescriptors = HashMap<DeclarationDescriptor, DeclarationDescriptor>()
|
||||
@@ -50,7 +51,7 @@ class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor:
|
||||
|
||||
val substituted = substitutedDescriptors!!.getOrPut(descriptor) {
|
||||
when (descriptor) {
|
||||
is Substitutable<*> -> descriptor.substitute(substitutor).sure {
|
||||
is Substitutable<*> -> descriptor.substitute(capturingSubstitutor).sure {
|
||||
"We expect that no conflict should happen while substitution is guaranteed to generate invariant projection, " +
|
||||
"but $descriptor substitution fails"
|
||||
}
|
||||
@@ -63,7 +64,7 @@ class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor:
|
||||
}
|
||||
|
||||
private fun <D : DeclarationDescriptor> substitute(descriptors: Collection<D>): Collection<D> {
|
||||
if (substitutor.isEmpty) return descriptors
|
||||
if (capturingSubstitutor.isEmpty) return descriptors
|
||||
if (descriptors.isEmpty()) return descriptors
|
||||
|
||||
val result = newLinkedHashSetWithExpectedSize<D>(descriptors.size)
|
||||
@@ -97,7 +98,7 @@ class SubstitutingScope(private val workerScope: MemberScope, givenSubstitutor:
|
||||
|
||||
p.println("substitutor = ")
|
||||
p.pushIndent()
|
||||
p.println(substitutor)
|
||||
p.println(capturingSubstitutor)
|
||||
p.popIndent()
|
||||
|
||||
p.print("workerScope = ")
|
||||
|
||||
Reference in New Issue
Block a user