Fix common super type calculation for captured dynamic types
^KT-32499 Fixed
This commit is contained in:
+5
-1
@@ -41,7 +41,11 @@ object NewCommonSuperTypeCalculator {
|
||||
|
||||
val lowers = types.map {
|
||||
when (it) {
|
||||
is SimpleTypeMarker -> it
|
||||
is SimpleTypeMarker -> {
|
||||
if (it.isCapturedDynamic()) return it
|
||||
|
||||
it
|
||||
}
|
||||
is FlexibleTypeMarker -> {
|
||||
if (it.isDynamic()) return it
|
||||
// raw types are allowed here and will be transformed to FlexibleTypes
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// SKIP_TXT
|
||||
|
||||
fun case_1(vararg args: dynamic) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf(null) + args<!>).toTypedArray()
|
||||
}
|
||||
|
||||
fun case_2(vararg args: dynamic) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf<Nothing>() + args<!>).toTypedArray()
|
||||
}
|
||||
|
||||
fun case_3(vararg args: dynamic) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf(1) + args<!>).toTypedArray()
|
||||
}
|
||||
|
||||
fun case_4(vararg args: dynamic) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf<Any?>() + args<!>).toTypedArray()
|
||||
}
|
||||
|
||||
fun case_5(x: Any?) {
|
||||
fun foo(x: List<dynamic>) = x
|
||||
|
||||
foo(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf(null) + x as MutableList<out dynamic><!>)
|
||||
}
|
||||
|
||||
fun case_6(x: Any?) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<kotlin.Any?>")!>listOf(null) + x as MutableList<in dynamic><!>).toTypedArray()
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// SKIP_TXT
|
||||
|
||||
fun case_1(vararg args: dynamic) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf(null) + args<!>).toTypedArray()
|
||||
}
|
||||
|
||||
fun case_2(vararg args: dynamic) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf<Nothing>() + args<!>).toTypedArray()
|
||||
}
|
||||
|
||||
fun case_3(vararg args: dynamic) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf(1) + args<!>).toTypedArray()
|
||||
}
|
||||
|
||||
fun case_4(vararg args: dynamic) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf<Any?>() + args<!>).toTypedArray()
|
||||
}
|
||||
|
||||
fun case_5(x: Any?) {
|
||||
fun foo(x: List<dynamic>) = x
|
||||
|
||||
foo(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<dynamic>")!>listOf(null) + x as MutableList<out dynamic><!>)
|
||||
}
|
||||
|
||||
fun case_6(x: Any?) {
|
||||
(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.List<kotlin.Any?>")!>listOf(null) + x as MutableList<in dynamic><!>).toTypedArray()
|
||||
}
|
||||
+10
@@ -113,6 +113,16 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
runTest("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/callableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedDynamic.kt")
|
||||
public void testСapturedDynamic() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/capturedDynamic.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedDynamicNI.kt")
|
||||
public void testCapturedDynamicNI() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/capturedDynamicNI.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("classDelegateBy.kt")
|
||||
public void testClassDelegateBy() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/classDelegateBy.kt");
|
||||
|
||||
@@ -232,6 +232,9 @@ interface TypeSystemContext : TypeSystemOptimizationContext {
|
||||
fun KotlinTypeMarker.isFlexible(): Boolean = asFlexibleType() != null
|
||||
|
||||
fun KotlinTypeMarker.isDynamic(): Boolean = asFlexibleType()?.asDynamicType() != null
|
||||
fun KotlinTypeMarker.isCapturedDynamic(): Boolean =
|
||||
asSimpleType()?.asCapturedType()?.typeConstructor()?.projection()?.getType()?.isDynamic() == true
|
||||
|
||||
fun KotlinTypeMarker.isDefinitelyNotNullType(): Boolean = asSimpleType()?.asDefinitelyNotNullType() != null
|
||||
|
||||
fun KotlinTypeMarker.hasFlexibleNullability() =
|
||||
|
||||
Reference in New Issue
Block a user