Files
kotlin/compiler/testData/psi/examples/PolymorphicClassObjects.kt
Pavel V. Talanov 59f192ef90 Replace 'class object' with 'default object' in renderers and test data
Includes changes to decompiled text
Old syntax is used in builtins and project code for now
2015-03-06 19:36:54 +03:00

27 lines
473 B
Kotlin

open class Builder<E, R> {
[operator] fun plusAssign(item : E)
fun result() : R
}
open class Buildable {
fun newBuilder<E, R>() : Builder<E, R>
}
class List<T> {
default object : Buildable {
override fun newBuilder<E, R>() : Builder<E, R>
}
}
fun <E, T, R> Map<E, T>.map(f : (E) -> R) : T<R> where
T : Iterable<E>,
class object T : Buildable<E, T> = {
val builder = T.newBuilder()
for (e in this) {
builder += f(e)
}
builder.result()
}