Obsolete KT-3285: "A receiver of type ... is required" when using extension functions
#KT-5467 Obsolete
This commit is contained in:
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user