Obsolete KT-3285: "A receiver of type ... is required" when using extension functions

#KT-5467 Obsolete
This commit is contained in:
Michael Bogdanov
2014-10-07 15:46:44 +04:00
parent bb3f1f1fb7
commit 278e682595
2 changed files with 38 additions and 0 deletions
@@ -0,0 +1,32 @@
var sayResult = ""
class NoiseMaker {
fun say(str: String) { sayResult += str }
}
fun noiseMaker(f: NoiseMaker.() -> Unit) {
val noiseMaker = NoiseMaker()
noiseMaker.f()
}
abstract class Pet {
fun <T> NoiseMaker.playWith(friend: T) {
say("Playing with " + friend)
}
abstract fun play(): Unit
}
class Doggy(): Pet() {
override fun play() = noiseMaker {
say("Time to play! ")
playWith("my owner!")
}
}
fun box(): String {
Doggy().play()
if (sayResult != "Time to play! Playing with my owner!") return "fail: $result"
return "OK"
}