[NI] Fix exception on capturing type with inner typealiased typed
This commit is contained in:
+8
-7
@@ -46,13 +46,14 @@ interface NewTypeSubstitutor {
|
||||
if (type is AbbreviatedType) {
|
||||
val substitutedExpandedType = substitute(type.expandedType, keepAnnotation, runCapturedChecks)
|
||||
val substitutedAbbreviation = substitute(type.abbreviation, keepAnnotation, runCapturedChecks)
|
||||
if (substitutedExpandedType is SimpleType? && substitutedAbbreviation is SimpleType?) {
|
||||
return AbbreviatedType(
|
||||
substitutedExpandedType ?: type.expandedType,
|
||||
substitutedAbbreviation ?: type.abbreviation
|
||||
)
|
||||
} else {
|
||||
return substitutedExpandedType
|
||||
return when {
|
||||
substitutedExpandedType == null && substitutedAbbreviation == null -> null
|
||||
substitutedExpandedType is SimpleType? && substitutedAbbreviation is SimpleType? ->
|
||||
AbbreviatedType(
|
||||
substitutedExpandedType ?: type.expandedType,
|
||||
substitutedAbbreviation ?: type.abbreviation
|
||||
)
|
||||
else -> substitutedExpandedType
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
typealias MyString = String
|
||||
|
||||
fun test(k: KClass<out MyString>) {
|
||||
k::class.java
|
||||
}
|
||||
|
||||
@Suppress("UPPER_BOUND_VIOLATED")
|
||||
public val <T> KClass<T>.java: Class<T> get() = TODO()
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
@kotlin.Suppress(names = {"UPPER_BOUND_VIOLATED"}) public val </*0*/ T> kotlin.reflect.KClass<T>.java: java.lang.Class<T>
|
||||
public fun test(/*0*/ k: kotlin.reflect.KClass<out MyString /* = kotlin.String */>): kotlin.Unit
|
||||
public typealias MyString = kotlin.String
|
||||
@@ -9396,6 +9396,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeSubstitutedIntoOppositeProjection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedTypeWithInnerTypealias.kt")
|
||||
public void testCapturedTypeWithInnerTypealias() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedTypeWithTypeVariableSubtyping.kt")
|
||||
public void testCapturedTypeWithTypeVariableSubtyping() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithTypeVariableSubtyping.kt");
|
||||
|
||||
Generated
+5
@@ -9396,6 +9396,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeSubstitutedIntoOppositeProjection.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedTypeWithInnerTypealias.kt")
|
||||
public void testCapturedTypeWithInnerTypealias() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithInnerTypealias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedTypeWithTypeVariableSubtyping.kt")
|
||||
public void testCapturedTypeWithTypeVariableSubtyping() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithTypeVariableSubtyping.kt");
|
||||
|
||||
Reference in New Issue
Block a user