[NI] Fix CST calculation for covariant type projections
This commit is contained in:
+2
-1
@@ -388,7 +388,8 @@ object NewCommonSuperTypeCalculator {
|
||||
return if (equalToEachOtherType == null) {
|
||||
createTypeArgument(commonSuperType(argumentTypes, depth + 1), TypeVariance.OUT)
|
||||
} else {
|
||||
createTypeArgument(equalToEachOtherType.getType(), TypeVariance.INV)
|
||||
val thereIsNotInv = arguments.any { it.getVariance() != TypeVariance.INV }
|
||||
createTypeArgument(equalToEachOtherType.getType(), if (thereIsNotInv) TypeVariance.OUT else TypeVariance.INV)
|
||||
}
|
||||
} else {
|
||||
val type = intersectTypes(arguments.map { it.getType() })
|
||||
|
||||
Vendored
+1
-1
@@ -16,5 +16,5 @@ fun <R> foo(f: () -> R): R = f()
|
||||
fun test(n: Number) {
|
||||
val a = select(foo { JavaTest.createNumberArray() }, emptyArray())
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(kotlin.Array<(kotlin.Number..kotlin.Number?)>..kotlin.Array<(kotlin.Number..kotlin.Number?)>?)")!>a<!>
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("(kotlin.Array<(kotlin.Number..kotlin.Number?)>..kotlin.Array<out (kotlin.Number..kotlin.Number?)>?)")!>a<!>
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
|
||||
|
||||
// FILE: Foo.java
|
||||
|
||||
public class Foo {
|
||||
public static <K, V> void create(java.util.Map<? extends K, ? extends V> m) { return null; }
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test(properties: Map<String, String>, nullableProperties: Map<String, String>?) {
|
||||
val f1 = Foo.create(select1(properties, myEmptyMap()))
|
||||
val f2 = Foo.create(nullableProperties ?: myEmptyMap())
|
||||
}
|
||||
|
||||
fun <T, R> myEmptyMap(): Map<T, R> = TODO()
|
||||
|
||||
@Suppress("INVISIBLE_REFERENCE")
|
||||
fun <S> select1(x: S, y: S): @kotlin.internal.Exact S = y
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T, /*1*/ R> myEmptyMap(): kotlin.collections.Map<T, R>
|
||||
@kotlin.Suppress(names = {"INVISIBLE_REFERENCE"}) public fun </*0*/ S> select1(/*0*/ x: S, /*1*/ y: S): S
|
||||
public fun test(/*0*/ properties: kotlin.collections.Map<kotlin.String, kotlin.String>, /*1*/ nullableProperties: kotlin.collections.Map<kotlin.String, kotlin.String>?): kotlin.Unit
|
||||
|
||||
public open class Foo {
|
||||
public constructor Foo()
|
||||
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
|
||||
|
||||
// Static members
|
||||
public open fun </*0*/ K : kotlin.Any!, /*1*/ V : kotlin.Any!> create(/*0*/ m: (kotlin.collections.MutableMap<out K!, out V!>..kotlin.collections.Map<out K!, V!>?)): kotlin.Unit
|
||||
}
|
||||
+5
@@ -1902,6 +1902,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("elvisOperatorAgainstFlexibleType.kt")
|
||||
public void testElvisOperatorAgainstFlexibleType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionPriority.kt")
|
||||
public void testExtensionPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -1902,6 +1902,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/correctMember.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("elvisOperatorAgainstFlexibleType.kt")
|
||||
public void testElvisOperatorAgainstFlexibleType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/elvisOperatorAgainstFlexibleType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionPriority.kt")
|
||||
public void testExtensionPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/extensionPriority.kt");
|
||||
|
||||
Reference in New Issue
Block a user