Files
kotlin-fork/compiler/testData/diagnostics/tests/generics/kt5508.kt
T
Ilya Kirillov 1bbcae5ed2 [FIR] fix resolve contract violation from scopes
We cannot call lazy resolve to STATUS phase from scopes as scopes may be accessed on a STATUS phase or earlier

^KT-54890
^KTIJ-23587 fixed
2023-01-13 21:32:51 +00:00

25 lines
1002 B
Kotlin
Vendored

// FIR_IDENTICAL
// KT-5508 Stackoverflow in type substitution
abstract class A<T> {
public abstract fun foo(x: T)
public abstract fun bar(x: T)
public inner abstract class B<S> : A<B<S>>() {
public inner <!ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED!>class C<!><U> : B<C<U>>()
{
// Here B<C<U>> means A<A<A<T>.B<S>>.B<A<T>.B<S>.C<U>>>.B<A<A<T>.B<S>>.B<A<T>.B<S>.C<U>>.C<U>>
// while for being a correct override it should be A<A<T>.B<S>>.B<A<T>.B<S>.C<U>>
// It happens because at the beginning we search implicit arguments for an outer classes through supertypes
// See TypeResolver.computeImplicitOuterClassArguments for clarifications
<!NOTHING_TO_OVERRIDE!>override<!> fun foo(x: B<C<U>>) {
throw UnsupportedOperationException()
}
override fun bar(x: A<A<T>.B<S>>.B<A<T>.B<S>.C<U>>) {
throw UnsupportedOperationException()
}
}
}
}