Files
kotlin-fork/compiler/testData/diagnostics/tests/generics/innerClasses/iterator.kt
T
Denis Zharkov deea0643ad Refine type arguments resolution and rendering
In case of type constructors captured parameters from outer classes

 #KT-5510 Fixed
 #KT-3112 Fixed
 #KT-6325 Fixed
 #KT-408  Fixed
 #KT-6337 Fixed
2015-11-13 14:47:28 +03:00

36 lines
921 B
Kotlin
Vendored

// !CHECK_TYPE
// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_PARAMETER -UNUSED_VARIABLE
import java.util.*
class A<T> : AbstractCollection<T>() {
override fun iterator(): MyIt = MyIt()
override val size: Int
get() = 1
inner class MyIt : MutableIterator<T> {
override fun next(): T {
throw UnsupportedOperationException()
}
override fun hasNext(): Boolean {
throw UnsupportedOperationException()
}
override fun remove() {
throw UnsupportedOperationException()
}
}
}
fun <E> commonSupertype(x: E, y: E): E = x
fun foo() {
var myIt = A<String>().iterator()
myIt = <!TYPE_MISMATCH!>A<Int>().iterator()<!>
val csIt: Iterator<CharSequence> = A<String>().iterator()
commonSupertype(A<String>().iterator(), A<Int>().iterator()).checkType { _<A<out Any>.MyIt>() }
}