[FE] Check types in canHaveCommonSubtype for intersection emptiness with erasing nullability
It doesn't affect having common subtypes check but may lead to false positives ^KT-52364 Fixed
This commit is contained in:
committed by
teamcity
parent
ba158de848
commit
11eb5ce39c
+6
@@ -15523,6 +15523,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt51016.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52364.kt")
|
||||
public void testKt52364() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableEmptyIntersection.kt")
|
||||
public void testNullableEmptyIntersection() throws Exception {
|
||||
|
||||
+6
@@ -15523,6 +15523,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt51016.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52364.kt")
|
||||
public void testKt52364() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableEmptyIntersection.kt")
|
||||
public void testNullableEmptyIntersection() throws Exception {
|
||||
|
||||
+6
@@ -15523,6 +15523,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt51016.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52364.kt")
|
||||
public void testKt52364() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableEmptyIntersection.kt")
|
||||
public void testNullableEmptyIntersection() throws Exception {
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
class FieldStyle2(val index: Int? = 0)
|
||||
|
||||
interface Foo {
|
||||
fun <Type : Comparable<*>> getProperty(): Type? = null
|
||||
}
|
||||
|
||||
class A<T : Foo> {
|
||||
fun foo(thisRef: T, property: KProperty<*>): FieldStyle2 {
|
||||
return FieldStyle2(thisRef.getProperty())
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public final class A</*0*/ T : Foo> {
|
||||
public constructor A</*0*/ T : Foo>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ thisRef: T, /*1*/ property: kotlin.reflect.KProperty<*>): FieldStyle2
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class FieldStyle2 {
|
||||
public constructor FieldStyle2(/*0*/ index: kotlin.Int? = ...)
|
||||
public final val index: kotlin.Int?
|
||||
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 Foo {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open fun </*0*/ Type : kotlin.Comparable<*>> getProperty(): Type?
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Generated
+6
@@ -15529,6 +15529,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt51016.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52364.kt")
|
||||
public void testKt52364() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nullableEmptyIntersection.kt")
|
||||
public void testNullableEmptyIntersection() throws Exception {
|
||||
|
||||
@@ -392,10 +392,10 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
|
||||
"One of the passed type should be an interface"
|
||||
}
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val firstType = firstType.withNullability(false).eraseContainingTypeParameters()
|
||||
val firstType = firstType.eraseContainingTypeParameters()
|
||||
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val secondType = secondType.withNullability(false).eraseContainingTypeParameters()
|
||||
val secondType = secondType.eraseContainingTypeParameters()
|
||||
|
||||
// interface A<K>
|
||||
// interface B: A<String>
|
||||
@@ -414,14 +414,14 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
|
||||
val typeCheckerState = newTypeCheckerState(errorTypesEqualToAnything = true, stubTypesEqualToAnything = true)
|
||||
|
||||
for (i in expandedTypes.indices) {
|
||||
val firstType = expandedTypes[i]
|
||||
val firstType = expandedTypes[i].withNullability(false)
|
||||
val firstTypeConstructor = firstType.typeConstructor()
|
||||
|
||||
if (!firstType.mayCauseEmptyIntersection())
|
||||
continue
|
||||
|
||||
for (j in i + 1 until expandedTypes.size) {
|
||||
val secondType = expandedTypes[j]
|
||||
val secondType = expandedTypes[j].withNullability(false)
|
||||
val secondTypeConstructor = secondType.typeConstructor()
|
||||
|
||||
if (!secondType.mayCauseEmptyIntersection())
|
||||
|
||||
Reference in New Issue
Block a user