Files
kotlin-fork/compiler/testData/diagnostics/tests/generics/kt5508.kt
T
Denis Zharkov 7ca84649d7 Fix implicit type arguments resolution for inner classes
When resolving arguments on inner classifier, one can omit the arguments
for outer class 'Outer' if they are present implicitly in the scope:
- One of the supertypes of current class is Outer
- One of the outer classes or one of their supertypes is Outer

Relevant arguments are obtained from the first type found by
the algorithm above

Note that before this commit implicit arguments were only been searched
in containing classes

 #KT-11123 Fixed
2016-09-15 10:33:19 +03:00

24 lines
985 B
Kotlin
Vendored

// 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()
}
}
}
}