[SAM with receiver] Add implementation for K2
This commit is contained in:
committed by
teamcity
parent
49c836e706
commit
65ac82ee46
@@ -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 }
|
||||
}
|
||||
Reference in New Issue
Block a user