[NI] Fix exception on capturing type with inner typealiased typed

This commit is contained in:
Mikhail Zarechenskiy
2018-06-05 12:16:08 +03:00
parent 4883fbfd23
commit 04c13aeae8
5 changed files with 35 additions and 7 deletions
@@ -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
}
}
@@ -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()
@@ -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");
@@ -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");