Implement makeNullableAsSpecified for TypeTemplate properly

This change fixes an SOE in isCastErased:
    @JvmStatic
    fun isCastErased(supertype: KotlinType, subtype: KotlinType, typeChecker: KotlinTypeChecker): Boolean {
        if (supertype.isMarkedNullable || subtype.isMarkedNullable) {
            return isCastErased(TypeUtils.makeNotNullable(supertype), TypeUtils.makeNotNullable(subtype), typeChecker)
        }

TypeUtils.makeNotNullable(TypeTemplate) should not return the same object
if isMarkedNullable returned true on the instance


 #KT-15516 Fixed
This commit is contained in:
Denis Zharkov
2017-01-31 16:18:31 +03:00
parent dc57f97196
commit e9262b875b
3 changed files with 31 additions and 3 deletions
@@ -0,0 +1,18 @@
// SKIP_TXT
class StateMachine<Q> internal constructor() {
fun getInputStub(): Q = null as Q
}
fun <T> stateMachine(<!UNUSED_PARAMETER!>block<!>: suspend StateMachine<T>.() -> Unit): StateMachine<T> {
return StateMachine<T>()
}
class Problem<F>(){
fun getInputStub(): F = null as F
fun createStateMachine(): StateMachine<F> = stateMachine {
val letter = getInputStub()
if (letter is Any)
println("yes")
}
}