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"
|
||||||
|
}
|
||||||
@@ -2783,6 +2783,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt3285.kt")
|
||||||
|
public void testKt3285() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/extensionFunctions/kt3285.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt3298.kt")
|
@TestMetadata("kt3298.kt")
|
||||||
public void testKt3298() throws Exception {
|
public void testKt3298() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/extensionFunctions/kt3298.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/extensionFunctions/kt3298.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user