[SAM with receiver] Add implementation for K2

This commit is contained in:
Dmitriy Novozhilov
2022-06-22 15:24:15 +03:00
committed by teamcity
parent 49c836e706
commit 65ac82ee46
20 changed files with 306 additions and 39 deletions
@@ -0,0 +1,17 @@
// FILE: Sam.java
@SamWithReceiver
public interface Sam {
String run(String argument);
}
// FILE: test.kt
annotation class SamWithReceiver
fun takeSam(argument: String, sam: Sam): String {
return sam.run(argument)
}
fun box(): String {
val sam = Sam { this }
return takeSam("OK", sam)
}
@@ -0,0 +1,16 @@
// FILE: Sam.java
@SamWithReceiver
public interface Sam {
String run(String argument);
}
// FILE: test.kt
annotation class SamWithReceiver
fun takeSam(argument: String, sam: Sam): String {
return sam.run(argument)
}
fun box(): String {
return takeSam("OK") { this }
}