[FIR] Only let supertypes of ILTs include Number when it's not unsigned
#KT-64607 Fixed
This commit is contained in:
committed by
Space Team
parent
81d6615915
commit
fd12f24725
+6
@@ -39266,6 +39266,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/lateinitUnsignedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("numberReceiverNotValid.kt")
|
||||
public void testNumberReceiverNotValid() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/numberReceiverNotValid.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionOfBasicOperations.kt")
|
||||
public void testOverloadResolutionOfBasicOperations() throws Exception {
|
||||
|
||||
+6
@@ -39266,6 +39266,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/lateinitUnsignedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("numberReceiverNotValid.kt")
|
||||
public void testNumberReceiverNotValid() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/numberReceiverNotValid.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionOfBasicOperations.kt")
|
||||
public void testOverloadResolutionOfBasicOperations() throws Exception {
|
||||
|
||||
+6
@@ -36992,6 +36992,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/lateinitUnsignedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("numberReceiverNotValid.kt")
|
||||
public void testNumberReceiverNotValid() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/numberReceiverNotValid.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionOfBasicOperations.kt")
|
||||
public void testOverloadResolutionOfBasicOperations() throws Exception {
|
||||
|
||||
+6
@@ -37112,6 +37112,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/lateinitUnsignedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("numberReceiverNotValid.kt")
|
||||
public void testNumberReceiverNotValid() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/numberReceiverNotValid.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionOfBasicOperations.kt")
|
||||
public void testOverloadResolutionOfBasicOperations() throws Exception {
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.types.AbstractTypeChecker
|
||||
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||
|
||||
class ConeIntegerLiteralConstantTypeImpl(
|
||||
value: Long,
|
||||
@@ -139,10 +140,17 @@ fun ConeKotlinType.approximateIntegerLiteralType(expectedType: ConeKotlinType? =
|
||||
|
||||
private object ConeIntegerLiteralTypeExtensions {
|
||||
fun createSupertypeList(type: ConeIntegerLiteralType): List<ConeClassLikeType> {
|
||||
return listOf(
|
||||
createClassLikeType(StandardClassIds.Number),
|
||||
val comparableSuperType =
|
||||
ConeClassLikeTypeImpl(StandardClassIds.Comparable.toLookupTag(), arrayOf(ConeKotlinTypeProjectionIn(type)), false)
|
||||
)
|
||||
|
||||
return if (type.possibleTypes.none { it.isUnsignedTypeOrNullableUnsignedType }) {
|
||||
listOf(
|
||||
createClassLikeType(StandardClassIds.Number),
|
||||
comparableSuperType,
|
||||
)
|
||||
} else {
|
||||
listOf(comparableSuperType)
|
||||
}
|
||||
}
|
||||
|
||||
fun createClassLikeType(classId: ClassId): ConeClassLikeType {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// FIR_IDENTICAL
|
||||
// WITH_STDLIB
|
||||
// LANGUAGE: +ContextReceivers
|
||||
// ISSUE: KT-64607
|
||||
|
||||
val Number.a get() = ""
|
||||
fun Number.b() = ""
|
||||
context(Number) val c get() = ""
|
||||
context(Number) fun d() = ""
|
||||
|
||||
fun test() {
|
||||
2U.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>a<!>
|
||||
2U.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>b<!>()
|
||||
with (2U) {
|
||||
<!NO_CONTEXT_RECEIVER!>c<!>
|
||||
<!NO_CONTEXT_RECEIVER!>d<!>()
|
||||
}
|
||||
}
|
||||
Generated
+6
@@ -39266,6 +39266,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/lateinitUnsignedType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("numberReceiverNotValid.kt")
|
||||
public void testNumberReceiverNotValid() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/unsignedTypes/numberReceiverNotValid.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionOfBasicOperations.kt")
|
||||
public void testOverloadResolutionOfBasicOperations() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user