[FE 1.0] Fix subtyping for captured integer literal types
^KT-50877 Fixed
This commit is contained in:
committed by
teamcity
parent
7395f8e019
commit
ec6ec20728
+6
@@ -22956,6 +22956,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/javaEmptyList.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/javaEmptyList.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt50877.kt")
|
||||||
|
public void testKt50877() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/kt50877.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodTypeParameterDefaultBound.kt")
|
@TestMetadata("methodTypeParameterDefaultBound.kt")
|
||||||
public void testMethodTypeParameterDefaultBound() throws Exception {
|
public void testMethodTypeParameterDefaultBound() throws Exception {
|
||||||
|
|||||||
+6
@@ -22956,6 +22956,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/javaEmptyList.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/javaEmptyList.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt50877.kt")
|
||||||
|
public void testKt50877() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/kt50877.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodTypeParameterDefaultBound.kt")
|
@TestMetadata("methodTypeParameterDefaultBound.kt")
|
||||||
public void testMethodTypeParameterDefaultBound() throws Exception {
|
public void testMethodTypeParameterDefaultBound() throws Exception {
|
||||||
|
|||||||
+6
@@ -22956,6 +22956,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/javaEmptyList.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/javaEmptyList.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt50877.kt")
|
||||||
|
public void testKt50877() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/kt50877.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodTypeParameterDefaultBound.kt")
|
@TestMetadata("methodTypeParameterDefaultBound.kt")
|
||||||
public void testMethodTypeParameterDefaultBound() throws Exception {
|
public void testMethodTypeParameterDefaultBound() throws Exception {
|
||||||
|
|||||||
@@ -2,6 +2,8 @@
|
|||||||
// IGNORE_BACKEND: JVM, JVM_IR, ANDROID, ANDROID_IR
|
// IGNORE_BACKEND: JVM, JVM_IR, ANDROID, ANDROID_IR
|
||||||
// IGNORE_LIGHT_ANALYSIS
|
// IGNORE_LIGHT_ANALYSIS
|
||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
|
// JVM_TARGET: 1.8
|
||||||
|
// IGNORE_BACKEND: ANDROID
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
|
|
||||||
// This test fails on FE 1.0, but works in production compiler (see KT-49191):
|
// This test fails on FE 1.0, but works in production compiler (see KT-49191):
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// FULL_JDK
|
||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
// FILE: Schematic.kt
|
||||||
|
class Schematic {
|
||||||
|
var name: String? = null
|
||||||
|
|
||||||
|
var error: String? = null
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return name!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: SortedListModel.java
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class SortedListModel<T> {
|
||||||
|
public SortedListModel(Comparator<? super T> comparator) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
val model = SortedListModel<Schematic>(Comparator.comparing { b1: Schematic ->
|
||||||
|
when {
|
||||||
|
b1.error != null -> 2
|
||||||
|
b1.name!!.contains(":") -> 1
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
}.thenComparing { b1: Schematic -> b1.name!! })
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
// FULL_JDK
|
||||||
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
// FILE: Schematic.kt
|
||||||
|
class Schematic {
|
||||||
|
var name: String? = null
|
||||||
|
|
||||||
|
var error: String? = null
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return name!!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: SortedListModel.java
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
public class SortedListModel<T> {
|
||||||
|
public SortedListModel(Comparator<? super T> comparator) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// FILE: main.kt
|
||||||
|
val model = SortedListModel<Schematic>(Comparator.comparing { b1: Schematic ->
|
||||||
|
when {
|
||||||
|
b1.error != null -> 2
|
||||||
|
b1.name!!.contains(":") -> 1
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
}.thenComparing { b1: Schematic -> b1.name!! })
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public val model: SortedListModel<Schematic>
|
||||||
|
|
||||||
|
public final class Schematic {
|
||||||
|
public constructor Schematic()
|
||||||
|
public final var error: kotlin.String?
|
||||||
|
public final var name: kotlin.String?
|
||||||
|
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*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class SortedListModel</*0*/ T : kotlin.Any!> {
|
||||||
|
public constructor SortedListModel</*0*/ T : kotlin.Any!>(/*0*/ comparator: java.util.Comparator<in 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
|
||||||
|
}
|
||||||
Generated
+6
@@ -22962,6 +22962,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/platformTypes/javaEmptyList.kt");
|
runTest("compiler/testData/diagnostics/tests/platformTypes/javaEmptyList.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt50877.kt")
|
||||||
|
public void testKt50877() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/platformTypes/kt50877.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("methodTypeParameterDefaultBound.kt")
|
@TestMetadata("methodTypeParameterDefaultBound.kt")
|
||||||
public void testMethodTypeParameterDefaultBound() throws Exception {
|
public void testMethodTypeParameterDefaultBound() throws Exception {
|
||||||
|
|||||||
@@ -313,8 +313,16 @@ object AbstractTypeChecker {
|
|||||||
&& typeConstructor.supertypes().any { it.asSimpleType()?.isIntegerLiteralType() == true }
|
&& typeConstructor.supertypes().any { it.asSimpleType()?.isIntegerLiteralType() == true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isCapturedIntegerLiteralType(type: SimpleTypeMarker): Boolean {
|
||||||
|
if (type !is CapturedTypeMarker) return false
|
||||||
|
val projection = type.typeConstructor().projection()
|
||||||
|
return !projection.isStarProjection() && projection.getType().upperBoundIfFlexible().isIntegerLiteralType()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isIntegerLiteralTypeOrCapturedOne(type: SimpleTypeMarker) = type.isIntegerLiteralType() || isCapturedIntegerLiteralType(type)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
subType.isIntegerLiteralType() && superType.isIntegerLiteralType() -> {
|
isIntegerLiteralTypeOrCapturedOne(subType) && isIntegerLiteralTypeOrCapturedOne(superType) -> {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -900,6 +900,8 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
|
|||||||
override fun KotlinTypeMarker.isTypeVariableType(): Boolean {
|
override fun KotlinTypeMarker.isTypeVariableType(): Boolean {
|
||||||
return this is UnwrappedType && constructor is NewTypeVariableConstructor
|
return this is UnwrappedType && constructor is NewTypeVariableConstructor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WA // Workaround for KT-52313
|
||||||
}
|
}
|
||||||
|
|
||||||
fun TypeVariance.convertVariance(): Variance {
|
fun TypeVariance.convertVariance(): Variance {
|
||||||
|
|||||||
Reference in New Issue
Block a user