From 191fb02bf65b0cc78318a520178d77f967aa4626 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Sun, 22 Mar 2020 23:25:12 +0300 Subject: [PATCH] [NI] Consider intersection type with number type as Nothing Currently, only for "in": In == In == In<*> #KT-37302 Fixed --- .../kotlin/codegen/ExpressionCodegen.java | 2 +- .../ir/FirBlackBoxCodegenTestGenerated.java | 5 ++ .../resolve/calls/inference/InferenceUtils.kt | 2 +- .../components/ResultTypeResolver.kt | 4 +- .../kotlin/resolve/calls/tower/TowerLevels.kt | 7 +- .../kotlin/types/TypeApproximator.kt | 27 +++++- .../numberLiteralCoercionToInferredType.kt | 81 ++++++++++++++++++ .../inference/completionOfMultipleLambdas.kt | 2 +- ...xibilityInCommonSuperTypeCalculation.ni.kt | 4 +- ...peArgumentsInferenceWithNestedCalls.ni.txt | 2 +- ...erOfArgumentsInTypeAliasConstructor.ni.txt | 4 +- .../inference/intersectionInputType.fir.kt | 12 +++ .../inference/intersectionInputType.kt | 3 +- .../genericCalls/inferredParameter.txt | 6 +- .../diagnostics/notLinked/dfa/pos/11.kt | 84 +++++++++---------- .../diagnostics/notLinked/dfa/pos/15.kt | 42 +++++----- .../diagnostics/notLinked/dfa/pos/51.kt | 8 +- .../codegen/BlackBoxCodegenTestGenerated.java | 5 ++ .../LightAnalysisModeTestGenerated.java | 5 ++ .../ir/IrBlackBoxCodegenTestGenerated.java | 5 ++ .../kotlin/types/KotlinTypeFactory.kt | 8 +- .../org/jetbrains/kotlin/types/TypeUtils.java | 2 +- .../typeMismatchMutableList2_ni.kt | 2 +- .../hasError_ni.kt | 2 +- .../IrJsCodegenBoxTestGenerated.java | 5 ++ .../semantics/JsCodegenBoxTestGenerated.java | 5 ++ 26 files changed, 242 insertions(+), 92 deletions(-) create mode 100644 compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/intersectionInputType.fir.kt diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java index cdc29f3b67e..6765456d265 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ExpressionCodegen.java @@ -2803,7 +2803,7 @@ public class ExpressionCodegen extends KtVisitor impleme KotlinType approximatedType = CapturedTypeConstructorKt.isCaptured(type) ? (KotlinType) approximator.approximateToSuperType( - type, TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation.INSTANCE + type, TypeApproximatorConfiguration.InternalTypesApproximation.INSTANCE ) : null; return approximatedType != null ? approximatedType : type; } else { diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 175bce90688..3e4a4e1bfc2 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -4745,6 +4745,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/constants/long.kt"); } + @TestMetadata("numberLiteralCoercionToInferredType.kt") + public void testNumberLiteralCoercionToInferredType() throws Exception { + runTest("compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt"); + } + @TestMetadata("privateConst.kt") public void testPrivateConst() throws Exception { runTest("compiler/testData/codegen/box/constants/privateConst.kt"); diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt index 67795576c0a..ed32381c6f9 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt @@ -94,7 +94,7 @@ fun CallableDescriptor.substituteAndApproximateTypes( } } - return substitute(TypeSubstitutor.create(wrappedSubstitution)) + return substitute(TypeSubstitutor.create(wrappedSubstitution)) ?: this } internal fun MutableList.trimToSize(newSize: Int) = subList(newSize, size).clear() diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt index 94fc5aacaa8..ad01d41b6be 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ResultTypeResolver.kt @@ -149,7 +149,7 @@ class ResultTypeResolver( return typeApproximator.approximateToSuperType( commonSuperType, - TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation + TypeApproximatorConfiguration.InternalTypesApproximation ) ?: commonSuperType } @@ -202,7 +202,7 @@ class ResultTypeResolver( return typeApproximator.approximateToSubType( upperType, - TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation + TypeApproximatorConfiguration.InternalTypesApproximation ) ?: upperType } return null diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt index e995f4df4da..e764e8f949d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt @@ -17,9 +17,6 @@ package org.jetbrains.kotlin.resolve.calls.tower import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.annotations.Annotations -import org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl -import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast @@ -144,11 +141,11 @@ internal class MemberScopeTowerLevel( Variance.INVARIANT -> null Variance.OUT_VARIANCE -> approximator.approximateToSuperType( topLevelType.unwrap(), - TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation + TypeApproximatorConfiguration.InternalTypesApproximation ) Variance.IN_VARIANCE -> approximator.approximateToSubType( topLevelType.unwrap(), - TypeApproximatorConfiguration.CapturedAndIntegerLiteralsTypesApproximation + TypeApproximatorConfiguration.InternalTypesApproximation ) } ?: topLevelType } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximator.kt b/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximator.kt index 199d569d1dd..9dfe0c9883d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximator.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/types/TypeApproximator.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.types.TypeApproximatorConfiguration.IntersectionStra import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor import org.jetbrains.kotlin.types.model.* import org.jetbrains.kotlin.types.model.CaptureStatus.* +import org.jetbrains.kotlin.types.typeUtil.isSignedOrUnsignedNumberType import java.util.concurrent.ConcurrentHashMap @@ -42,6 +43,7 @@ open class TypeApproximatorConfiguration { open val integerLiteralType: Boolean = false // IntegerLiteralTypeConstructor open val definitelyNotNullType get() = true open val intersection: IntersectionStrategy = TO_COMMON_SUPERTYPE + open val intersectionTypesInContravariantPositions = false open val typeVariable: (TypeVariableTypeConstructorMarker) -> Boolean = { false } open fun capturedType(ctx: TypeSystemInferenceExtensionContext, type: CapturedTypeMarker): Boolean = @@ -60,6 +62,7 @@ open class TypeApproximatorConfiguration { override val intersection get() = ALLOWED override val errorType get() = true override val integerLiteralType: Boolean get() = true + override val intersectionTypesInContravariantPositions: Boolean get() = true } object PublicDeclaration : AllFlexibleSameValue() { @@ -67,6 +70,7 @@ open class TypeApproximatorConfiguration { override val errorType get() = true override val definitelyNotNullType get() = false override val integerLiteralType: Boolean get() = true + override val intersectionTypesInContravariantPositions: Boolean get() = true } abstract class AbstractCapturedTypesApproximation(val approximatedCapturedStatus: CaptureStatus) : @@ -84,13 +88,15 @@ open class TypeApproximatorConfiguration { object IncorporationConfiguration : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FOR_INCORPORATION) object SubtypeCapturedTypesApproximation : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FOR_SUBTYPING) - object CapturedAndIntegerLiteralsTypesApproximation : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FROM_EXPRESSION) { + object InternalTypesApproximation : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FROM_EXPRESSION) { override val integerLiteralType: Boolean get() = true + override val intersectionTypesInContravariantPositions: Boolean get() = true } object FinalApproximationAfterResolutionAndInference : TypeApproximatorConfiguration.AbstractCapturedTypesApproximation(FROM_EXPRESSION) { override val integerLiteralType: Boolean get() = true + override val intersectionTypesInContravariantPositions: Boolean get() = true } object IntegerLiteralsTypesApproximation : TypeApproximatorConfiguration.AllFlexibleSameValue() { @@ -279,6 +285,13 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon } } + private fun isIntersectionTypeEffectivelyNothing(constructor: IntersectionTypeConstructor): Boolean { + // We consider intersection as Nothing only if one of it's component is a primitive number type + // It's intentional we're not trying to prove population of some type as it was in OI + + return constructor.supertypes.any { !it.isMarkedNullable && it.isSignedOrUnsignedNumberType() } + } + private fun approximateIntersectionType( type: SimpleTypeMarker, conf: TypeApproximatorConfiguration, @@ -512,6 +525,18 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon } else type.defaultResult(toSuper) } TypeVariance.OUT, TypeVariance.IN -> { + if ( + conf.intersectionTypesInContravariantPositions && + effectiveVariance == TypeVariance.IN && + argumentType.typeConstructor().isIntersection() + ) { + val intersectionTypeConstructor = argumentType.typeConstructor() as? IntersectionTypeConstructor + if (intersectionTypeConstructor != null && isIntersectionTypeEffectivelyNothing(intersectionTypeConstructor)) { + newArguments[index] = createStarProjection(parameter) + continue@loop + } + } + /** * Out <: Out * Inv <: Inv diff --git a/compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt b/compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt new file mode 100644 index 00000000000..d682ddeccec --- /dev/null +++ b/compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt @@ -0,0 +1,81 @@ +// IGNORE_BACKEND: JS, JS_IR +// IGNORE_BACKEND_FIR: JVM_IR +// WITH_RUNTIME + +// FILE: J.java + +public class J { + public static long platformLong() { + return 42; + } + + public static Comparable platformCLong() { + return new Long(42); + } +} + +// FILE: test.kt + +inline fun check(value: Any?) { + if (value !is T) throw Exception("value: $value should have type ${T::class.simpleName}") +} + +fun selectFirst(vararg xs: K): K = xs[0] + +fun takeNLong(nL: Long?) {} + +fun checkArray(array: T, copy: T.() -> T, toList: T.() -> List<*>, check: (T, T) -> Boolean, modify: T.() -> Unit) {} + +fun testFromStdlib() { + checkArray(arrayOf("a", 1, null), { copyOf() }, { toList() }, { a1, a2 -> a1 contentEquals a2 }, { reverse() }) +} + +fun box(): String { + check(selectFirst(0, 0L)) + check(selectFirst(0, 0.toByte())) + check(selectFirst(0, 0.toShort())) + + takeNLong(0) + + val cLong: Comparable = 0L + check(selectFirst(0, cLong)) + + val cByte: Comparable = 0.toByte() + check(selectFirst(0, cByte)) + + val cShort: Comparable = 0.toShort() + check(selectFirst(0, cShort)) + + val cStar: Comparable<*> = 0L + check(selectFirst(0, cStar)) + + check(selectFirst(0, J.platformLong())) + check(selectFirst(0, J.platformCLong())) + + check(selectFirst(0, 0L, "string")) + check(selectFirst(0, 0L, true)) + check(selectFirst(0, 0L, 0.toByte())) + check(selectFirst(0, 0L, 0f)) + check(selectFirst(0, 0L, 0f, 0.0)) + + val r = 0 + check( + when (r) { + 0 -> 0 + 1 -> 0L + 2 -> "string" + else -> TODO() + } + ) + + check(selectFirst(0, 0L, 0.0, null)) + + check(selectFirst(0u, 0uL)) + check(selectFirst(0u, 0.toUByte())) + check(selectFirst(0u, 0.toUShort())) + + check(selectFirst(0u, 0uL, "foo")) + check(selectFirst(0u, 0uL, "foo", null)) + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/completionOfMultipleLambdas.kt b/compiler/testData/diagnostics/tests/inference/completionOfMultipleLambdas.kt index 53cc9fea442..48f29d39ac4 100644 --- a/compiler/testData/diagnostics/tests/inference/completionOfMultipleLambdas.kt +++ b/compiler/testData/diagnostics/tests/inference/completionOfMultipleLambdas.kt @@ -18,7 +18,7 @@ fun test() { // ISSUE: KT-27999 // ISSUE: KT-30244 fun test_1() { - {Comparable<{Int & String}> & java.io.Serializable}")!>select( + {Comparable<*> & java.io.Serializable}")!>select( { 1 }, { "" } ) diff --git a/compiler/testData/diagnostics/tests/inference/upperBounds/flexibilityInCommonSuperTypeCalculation.ni.kt b/compiler/testData/diagnostics/tests/inference/upperBounds/flexibilityInCommonSuperTypeCalculation.ni.kt index 2ea53605e6f..f1978bf64d9 100644 --- a/compiler/testData/diagnostics/tests/inference/upperBounds/flexibilityInCommonSuperTypeCalculation.ni.kt +++ b/compiler/testData/diagnostics/tests/inference/upperBounds/flexibilityInCommonSuperTypeCalculation.ni.kt @@ -107,7 +107,7 @@ fun case_8() { val x3 = Test.id(A(null)) val result_1 = select(x1, x2, x3) - & java.io.Serializable}?>?")!>result_1 + ? & java.io.Serializable?}>?")!>result_1 } fun case_9() { @@ -116,7 +116,7 @@ fun case_9() { val x3 = A(Test.id(A('s'))) val result_1 = select(x1, x2, x3) - & java.io.Serializable}>?>")!>result_1 + & java.io.Serializable}>?>")!>result_1 } fun case_10() { diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.ni.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.ni.txt index 2b3f9d79b85..e22126a7d77 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.ni.txt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInferenceWithNestedCalls.ni.txt @@ -1,7 +1,7 @@ package public val test1: C /* = Cons */ -public val test2: C /* = Cons */ +public val test2: Cons public final class Cons { public constructor Cons(/*0*/ head: T, /*1*/ tail: Cons?) diff --git a/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.ni.txt b/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.ni.txt index be9b0aa0ebb..a008f589c3e 100644 --- a/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.ni.txt +++ b/compiler/testData/diagnostics/tests/typealias/wrongNumberOfArgumentsInTypeAliasConstructor.ni.txt @@ -2,7 +2,7 @@ package public val test0: P /* = Pair */ public val test0p2: P2 /* = Pair */ -public val test0p2a: Pair +public val test0p2a: Pair public val test0pr: PR /* = Pair */ public val test1: P /* = Pair */ public val test1p2: P2 /* = Pair */ @@ -13,7 +13,7 @@ public val test2pr: PR /* = Pair /* = Pair */ public val test3: P /* = Pair */ public val test3p2: P2 /* = Pair */ -public val test3pr: Pair +public val test3pr: Pair public val testMP0: MP /* = MyPair */ public val testMP1: MP /* = MyPair */ public val testMP2: MP /* = MyPair */ diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/intersectionInputType.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/intersectionInputType.fir.kt new file mode 100644 index 00000000000..0b312e318b3 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/intersectionInputType.fir.kt @@ -0,0 +1,12 @@ +// !LANGUAGE: +NewInference + +import kotlin.test.assertEquals + +fun test() { + val u = when (true) { + true -> 42 + else -> 1.0 + } + + assertEquals(42, u) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/intersectionInputType.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/intersectionInputType.kt index a1f3691d2c2..602d507134c 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/intersectionInputType.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/intersectionInputType.kt @@ -1,4 +1,3 @@ -// FIR_IDENTICAL // !LANGUAGE: +NewInference import kotlin.test.assertEquals @@ -9,5 +8,5 @@ fun test() { else -> 1.0 } - assertEquals(42, u) + assertEquals(42, u) } \ No newline at end of file diff --git a/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.txt b/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.txt index e707d27cdcb..a5dd960fa2b 100644 --- a/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.txt +++ b/compiler/testData/resolvedCalls/arguments/genericCalls/inferredParameter.txt @@ -10,7 +10,7 @@ fun test(a: Any, ls: List) { Resolved call: Candidate descriptor: fun foo(t: T, l: List): Unit defined in root package -Resulting descriptor: fun foo(t: {Comparable<{Int & String}> & java.io.Serializable}, l: List<{Comparable<{Int & String}> & java.io.Serializable}>): Unit defined in root package +Resulting descriptor: fun foo(t: {Comparable<*> & java.io.Serializable}, l: List<{Comparable<*> & java.io.Serializable}>): Unit defined in root package Explicit receiver kind = NO_EXPLICIT_RECEIVER Dispatch receiver = NO_RECEIVER @@ -18,5 +18,5 @@ Extension receiver = NO_RECEIVER Value arguments mapping: -SUCCESS t : {Comparable<{Int & String}> & java.io.Serializable} = 11 -SUCCESS l : List<{Comparable<{Int & String}> & java.io.Serializable}> = ls +SUCCESS t : {Comparable<*> & java.io.Serializable} = 11 +SUCCESS l : List<{Comparable<*> & java.io.Serializable}> = ls diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.kt index a55a2db28b4..06f1e58c716 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/11.kt @@ -18,16 +18,16 @@ fun case_1() { val x = case_1(Out(10), Inv(0.1)) if (x != null) { - & Number} & {Comparable<{Double & Int}> & Number}?")!>x - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.equals(null) - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.propT - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.propAny - & Number} & {Comparable<{Double & Int}> & Number}?")!>x.propNullableT - & Number} & {Comparable<{Double & Int}> & Number}?")!>x.propNullableAny - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.funT() - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.funAny() - & Number} & {Comparable<{Double & Int}> & Number}?")!>x.funNullableT() - & Number} & {Comparable<{Double & Int}> & Number}?")!>x.funNullableAny() + & Number} & {Comparable<*> & Number}?")!>x + & Number} & {Comparable<*> & Number}?")!>x.equals(null) + & Number} & {Comparable<*> & Number}?")!>x.propT + & Number} & {Comparable<*> & Number}?")!>x.propAny + & Number} & {Comparable<*> & Number}?")!>x.propNullableT + & Number} & {Comparable<*> & Number}?")!>x.propNullableAny + & Number} & {Comparable<*> & Number}?")!>x.funT() + & Number} & {Comparable<*> & Number}?")!>x.funAny() + & Number} & {Comparable<*> & Number}?")!>x.funNullableT() + & Number} & {Comparable<*> & Number}?")!>x.funNullableAny() } } @@ -38,16 +38,16 @@ fun case_2(y: Int) { val x = case_2(Out(y), Inv(0.1)) if (x != null) { - & Number} & {Comparable<{Double & Int}> & Number}?")!>x - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.equals(null) - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.propT - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.propAny - & Number} & {Comparable<{Double & Int}> & Number}?")!>x.propNullableT - & Number} & {Comparable<{Double & Int}> & Number}?")!>x.propNullableAny - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.funT() - & Number} & {Comparable<{Double & Int}> & Number}?"), DEBUG_INFO_SMARTCAST!>x.funAny() - & Number} & {Comparable<{Double & Int}> & Number}?")!>x.funNullableT() - & Number} & {Comparable<{Double & Int}> & Number}?")!>x.funNullableAny() + & Number} & {Comparable<*> & Number}?")!>x + & Number} & {Comparable<*> & Number}?")!>x.equals(null) + & Number} & {Comparable<*> & Number}?")!>x.propT + & Number} & {Comparable<*> & Number}?")!>x.propAny + & Number} & {Comparable<*> & Number}?")!>x.propNullableT + & Number} & {Comparable<*> & Number}?")!>x.propNullableAny + & Number} & {Comparable<*> & Number}?")!>x.funT() + & Number} & {Comparable<*> & Number}?")!>x.funAny() + & Number} & {Comparable<*> & Number}?")!>x.funNullableT() + & Number} & {Comparable<*> & Number}?")!>x.funNullableAny() } } @@ -61,32 +61,32 @@ fun case_3(a: Int?, b: Float?, c: Double?, d: Boolean?) { false -> b null -> c }.apply { - ? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}")!>this + ? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this if (this != null) { - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}")!>this - & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>this.equals(null) - & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>this.propT - & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>this.propAny - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}")!>this.propNullableT - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}")!>this.propNullableAny - & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>this.funT() - & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>this.funAny() - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}")!>this.funNullableT() - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable<{Double & Float & Int}>? & Number?}")!>this.funNullableAny() + & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this + & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.equals(null) + & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.propT + & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.propAny + & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this.propNullableT + & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this.propNullableAny + & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.funT() + & Number}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>this.funAny() + & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this.funNullableT() + & Number} & {Comparable? & Number?}"), DEBUG_INFO_EXPRESSION_TYPE("{Comparable? & Number?}")!>this.funNullableAny() } }.let { - ? & Number?}")!>it + ? & Number?}")!>it if (it != null) { - & Number} & {Comparable<{Double & Float & Int}>? & Number?}")!>it - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>it.equals(null) - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>it.propT - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>it.propAny - & Number} & {Comparable<{Double & Float & Int}>? & Number?}")!>it.propNullableT - & Number} & {Comparable<{Double & Float & Int}>? & Number?}")!>it.propNullableAny - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>it.funT() - & Number} & {Comparable<{Double & Float & Int}>? & Number?}"), DEBUG_INFO_SMARTCAST!>it.funAny() - & Number} & {Comparable<{Double & Float & Int}>? & Number?}")!>it.funNullableT() - & Number} & {Comparable<{Double & Float & Int}>? & Number?}")!>it.funNullableAny() + & Number} & {Comparable? & Number?}")!>it + & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.equals(null) + & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.propT + & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.propAny + & Number} & {Comparable? & Number?}")!>it.propNullableT + & Number} & {Comparable? & Number?}")!>it.propNullableAny + & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.funT() + & Number} & {Comparable? & Number?}"), DEBUG_INFO_SMARTCAST!>it.funAny() + & Number} & {Comparable? & Number?}")!>it.funNullableT() + & Number} & {Comparable? & Number?}")!>it.funNullableAny() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.kt index e5494c6369c..58dac5d0d7d 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/15.kt @@ -100,9 +100,9 @@ fun case_6() { val x = select(Case6_1(), Case6_2(), null) if (x != null) { - & Number}>> & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>?}")!>x - & Number}>> & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>?}")!>x.ip1test1() - & Number}>> & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>?}")!>x.ip1test2() + & Number}>> & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>?}")!>x + & Number}>> & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>?}")!>x.ip1test1() + & Number}>> & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>} & {InterfaceWithTypeParameter1 & Number}>>? & InterfaceWithTypeParameter2 & Number}>> & InterfaceWithTypeParameter2 & InterfaceWithTypeParameter2}>>}>>?}")!>x.ip1test2() } } @@ -114,8 +114,8 @@ fun case_7() { val x = select(Case7_1(), Case7_2(), null) if (x != null) { - & java.io.Serializable}>, out Inv & java.io.Serializable}>> & InterfaceWithTwoTypeParameters & java.io.Serializable}>, out Inv & java.io.Serializable}>>?")!>x - & java.io.Serializable}>, out Inv & java.io.Serializable}>> & InterfaceWithTwoTypeParameters & java.io.Serializable}>, out Inv & java.io.Serializable}>>?")!>x.ip2test() + & java.io.Serializable}>, out Inv & java.io.Serializable}>> & InterfaceWithTwoTypeParameters & java.io.Serializable}>, out Inv & java.io.Serializable}>>?")!>x + & java.io.Serializable}>, out Inv & java.io.Serializable}>> & InterfaceWithTwoTypeParameters & java.io.Serializable}>, out Inv & java.io.Serializable}>>?")!>x.ip2test() } } @@ -127,24 +127,24 @@ fun case_8() { val x = select(Case8_1(), Case8_2(), null) if (x != null) { - & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>x - & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>x.test1() - val y = & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>x.test2() + & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}>?")!>x + & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}>?")!>x.test1() + val y = & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>, out {Comparable<*> & java.io.Serializable}>?")!>x.test2() if (y != null) { - & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>y - & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>y.test1() - val z = & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<{Char & Float}> & java.io.Serializable}>?")!>y.test2() + & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>?")!>y + & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>?")!>y.test1() + val z = & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}> & ClassWithTwoTypeParameters & java.io.Serializable}, out {Comparable<*> & java.io.Serializable}>?")!>y.test2() if (z != null) { - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z.equals(null) - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z.propT - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z.propAny - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z.propNullableT - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z.propNullableAny - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z.funT() - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?"), DEBUG_INFO_SMARTCAST!>z.funAny() - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z.funNullableT() - & java.io.Serializable} & {Comparable<{Int & String}> & java.io.Serializable}?")!>z.funNullableAny() + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.equals(null) + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.propT + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.propAny + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.propNullableT + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.propNullableAny + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.funT() + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.funAny() + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.funNullableT() + & java.io.Serializable} & {Comparable<*> & java.io.Serializable}?")!>z.funNullableAny() } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/51.kt b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/51.kt index e6fb2e1792a..1ec53518047 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/51.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/dfa/pos/51.kt @@ -143,8 +143,8 @@ fun case_12(z: Any?) { return@let it as Int it as? Float ?: 10f } - & Number}")!>y - & Number}")!>y.toByte() + & Number}")!>y + & Number}")!>y.toByte() } /* @@ -167,8 +167,8 @@ fun case_14(z: Any?) { return@run this as Int this as? Float ?: 10f } - & Number}")!>y - & Number}")!>y.toByte() + & Number}")!>y + & Number}")!>y.toByte() } /* diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index e1edc1fc7f3..8faabe61189 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -4775,6 +4775,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/constants/long.kt"); } + @TestMetadata("numberLiteralCoercionToInferredType.kt") + public void testNumberLiteralCoercionToInferredType() throws Exception { + runTest("compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt"); + } + @TestMetadata("privateConst.kt") public void testPrivateConst() throws Exception { runTest("compiler/testData/codegen/box/constants/privateConst.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 6cea7f6be2a..41962901bdc 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -4775,6 +4775,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/constants/long.kt"); } + @TestMetadata("numberLiteralCoercionToInferredType.kt") + public void testNumberLiteralCoercionToInferredType() throws Exception { + runTest("compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt"); + } + @TestMetadata("privateConst.kt") public void testPrivateConst() throws Exception { runTest("compiler/testData/codegen/box/constants/privateConst.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index b625db521e7..d4856904d0f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -4745,6 +4745,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/constants/long.kt"); } + @TestMetadata("numberLiteralCoercionToInferredType.kt") + public void testNumberLiteralCoercionToInferredType() throws Exception { + runTest("compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt"); + } + @TestMetadata("privateConst.kt") public void testPrivateConst() throws Exception { runTest("compiler/testData/codegen/box/constants/privateConst.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeFactory.kt b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeFactory.kt index 7e4b4622eb0..0fec61ef099 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeFactory.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinTypeFactory.kt @@ -56,7 +56,13 @@ object KotlinTypeFactory { ) } is TypeAliasDescriptor -> ErrorUtils.createErrorScope("Scope for abbreviation: ${descriptor.name}", true) - else -> throw IllegalStateException("Unsupported classifier: $descriptor for constructor: $constructor") + else -> { + if (constructor is IntersectionTypeConstructor) { + return constructor.createScopeForKotlinType() + } + + throw IllegalStateException("Unsupported classifier: $descriptor for constructor: $constructor") + } } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java index d8a8945837a..78d3c424297 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeUtils.java @@ -545,7 +545,7 @@ public class TypeUtils { return literalTypeConstructor.getApproximatedType(); } - // If approximated type does not mathc expected type then expected type is very + // If approximated type does not match expected type then expected type is very // specific type (e.g. Comparable), so only one of possible types could match it KotlinType approximatedType = literalTypeConstructor.getApproximatedType(); if (KotlinTypeChecker.DEFAULT.isSubtypeOf(approximatedType, expectedType)) { diff --git a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2_ni.kt b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2_ni.kt index e836138da84..000b48c21f4 100644 --- a/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2_ni.kt +++ b/idea/testData/inspectionsLocal/liftOut/ifToAssignment/typeMismatchMutableList2_ni.kt @@ -1,6 +1,6 @@ // COMPILER_ARGUMENTS: -XXLanguage:+NewInference // PROBLEM: none -// ERROR: Type mismatch: inferred type is List<{Comparable<{Int & Long}> & Number}> but MutableList was expected +// ERROR: Type mismatch: inferred type is List<{Comparable<*> & Number}> but MutableList was expected // ERROR: Val cannot be reassigned // WITH_RUNTIME diff --git a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError_ni.kt b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError_ni.kt index de4fe603c9c..690858baf72 100644 --- a/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError_ni.kt +++ b/idea/testData/inspectionsLocal/suspiciousCollectionReassignment/hasError_ni.kt @@ -1,6 +1,6 @@ // PROBLEM: none // WITH_RUNTIME -// ERROR: Type mismatch: inferred type is List<{Comparable<{Int & String}> & java.io.Serializable}> but List was expected +// ERROR: Type mismatch: inferred type is List<{Comparable<*> & java.io.Serializable}> but List was expected // COMPILER_ARGUMENTS: -XXLanguage:+NewInference fun test() { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 369df0195a6..8663af21de5 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -3895,6 +3895,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/constants/long.kt"); } + @TestMetadata("numberLiteralCoercionToInferredType.kt") + public void testNumberLiteralCoercionToInferredType() throws Exception { + runTest("compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt"); + } + @TestMetadata("privateConst.kt") public void testPrivateConst() throws Exception { runTest("compiler/testData/codegen/box/constants/privateConst.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index d30c626eadc..529d183c8b1 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -3895,6 +3895,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/constants/long.kt"); } + @TestMetadata("numberLiteralCoercionToInferredType.kt") + public void testNumberLiteralCoercionToInferredType() throws Exception { + runTest("compiler/testData/codegen/box/constants/numberLiteralCoercionToInferredType.kt"); + } + @TestMetadata("privateConst.kt") public void testPrivateConst() throws Exception { runTest("compiler/testData/codegen/box/constants/privateConst.kt");