Allow to turn the first parameter of a SAM-converted lambda into the receiver (KT-12848)
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
@SamWithReceiver
|
||||
public interface Sam {
|
||||
void run();
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
annotation class SamWithReceiver
|
||||
|
||||
fun test() {
|
||||
Sam {
|
||||
System.out.println("Hello, world!")
|
||||
}
|
||||
|
||||
Sam {
|
||||
val a: String = <!NO_THIS!>this<!>
|
||||
System.out.println(a)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
@SamWithReceiver public /*synthesized*/ fun Sam(/*0*/ function: () -> kotlin.Unit): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
@SamWithReceiver public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class SamWithReceiver : kotlin.Annotation {
|
||||
public constructor SamWithReceiver()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
@SamWithReceiver
|
||||
public interface Sam {
|
||||
void run(String a, String b);
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
annotation class SamWithReceiver
|
||||
|
||||
fun test() {
|
||||
Sam { <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>a, <!CANNOT_INFER_PARAMETER_TYPE!>b<!><!> ->
|
||||
System.out.println(a)
|
||||
}
|
||||
|
||||
Sam { b ->
|
||||
val a: String = this
|
||||
System.out.println(a)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
@SamWithReceiver public /*synthesized*/ fun Sam(/*0*/ function: kotlin.String!.(b: kotlin.String!) -> kotlin.Unit): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
@SamWithReceiver public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(/*0*/ a: kotlin.String!, /*1*/ b: kotlin.String!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class SamWithReceiver : kotlin.Annotation {
|
||||
public constructor SamWithReceiver()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
@SamWithReceiver
|
||||
public interface Sam {
|
||||
void run();
|
||||
}
|
||||
|
||||
// FILE: Exec.java
|
||||
public class Exec {
|
||||
void exec(Sam sam) {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
annotation class SamWithReceiver
|
||||
|
||||
fun test() {
|
||||
val e = Exec()
|
||||
|
||||
e.exec {
|
||||
System.out.println("Hello, world!")
|
||||
}
|
||||
|
||||
e.exec {
|
||||
val a: String = <!NO_THIS!>this<!>
|
||||
System.out.println(a)
|
||||
}
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
package
|
||||
|
||||
@SamWithReceiver public /*synthesized*/ fun Sam(/*0*/ function: () -> kotlin.Unit): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class Exec {
|
||||
public constructor Exec()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public/*package*/ open fun exec(/*0*/ sam: Sam!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@SamWithReceiver public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class SamWithReceiver : kotlin.Annotation {
|
||||
public constructor SamWithReceiver()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
@SamWithReceiver
|
||||
public interface Sam {
|
||||
void run(String a);
|
||||
}
|
||||
|
||||
// FILE: Exec.java
|
||||
public class Exec {
|
||||
void exec(Sam sam) {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
annotation class SamWithReceiver
|
||||
|
||||
fun test() {
|
||||
val e = Exec()
|
||||
|
||||
e.exec <!TYPE_MISMATCH!>{ <!CANNOT_INFER_PARAMETER_TYPE!>a<!> -> System.out.println(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>) }<!>
|
||||
e.exec { System.out.println(this) }
|
||||
}
|
||||
Vendored
+26
@@ -0,0 +1,26 @@
|
||||
package
|
||||
|
||||
@SamWithReceiver public /*synthesized*/ fun Sam(/*0*/ function: kotlin.String!.() -> kotlin.Unit): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class Exec {
|
||||
public constructor Exec()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public/*package*/ open fun exec(/*0*/ sam: Sam!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@SamWithReceiver public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(/*0*/ a: kotlin.String!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class SamWithReceiver : kotlin.Annotation {
|
||||
public constructor SamWithReceiver()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
void run(String a);
|
||||
}
|
||||
|
||||
// FILE: Exec.java
|
||||
public class Exec {
|
||||
void exec(Sam sam) {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
fun test() {
|
||||
val e = Exec()
|
||||
|
||||
e.exec { a -> System.out.println(a) }
|
||||
e.exec { System.out.println(<!NO_THIS!>this<!>) }
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public /*synthesized*/ fun Sam(/*0*/ function: (a: kotlin.String!) -> kotlin.Unit): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public open class Exec {
|
||||
public constructor Exec()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public/*package*/ open fun exec(/*0*/ sam: Sam!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(/*0*/ a: kotlin.String!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
@SamWithReceiver
|
||||
public interface Sam {
|
||||
String run(String a, String b);
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
annotation class SamWithReceiver
|
||||
|
||||
fun test() {
|
||||
Sam { <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>a, <!CANNOT_INFER_PARAMETER_TYPE!>b<!><!> ->
|
||||
System.out.println(a)
|
||||
""
|
||||
}
|
||||
|
||||
Sam { b ->
|
||||
val a: String = this
|
||||
System.out.println(a)
|
||||
""
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
@SamWithReceiver public /*synthesized*/ fun Sam(/*0*/ function: kotlin.String!.(b: kotlin.String!) -> kotlin.String!): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
@SamWithReceiver public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(/*0*/ a: kotlin.String!, /*1*/ b: kotlin.String!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class SamWithReceiver : kotlin.Annotation {
|
||||
public constructor SamWithReceiver()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
String run(String a, String b);
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
fun test() {
|
||||
Sam { a, b ->
|
||||
System.out.println(a)
|
||||
""
|
||||
}
|
||||
|
||||
Sam { <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!>b<!> ->
|
||||
val a = <!NO_THIS!>this@Sam<!>
|
||||
System.out.println(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>)
|
||||
""
|
||||
}
|
||||
}
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public /*synthesized*/ fun Sam(/*0*/ function: (a: kotlin.String!, b: kotlin.String!) -> kotlin.String!): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(/*0*/ a: kotlin.String!, /*1*/ b: kotlin.String!): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
@SamWithReceiver
|
||||
public interface Sam {
|
||||
void run(String a);
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
annotation class SamWithReceiver
|
||||
|
||||
fun test() {
|
||||
Sam { <!EXPECTED_PARAMETERS_NUMBER_MISMATCH, CANNOT_INFER_PARAMETER_TYPE!>a<!> ->
|
||||
System.out.println(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>)
|
||||
}
|
||||
|
||||
Sam {
|
||||
val a: String = this
|
||||
val a2: String = <!UNRESOLVED_REFERENCE!>it<!>
|
||||
System.out.println(a)
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package
|
||||
|
||||
@SamWithReceiver public /*synthesized*/ fun Sam(/*0*/ function: kotlin.String!.() -> kotlin.Unit): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
@SamWithReceiver public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(/*0*/ a: kotlin.String!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class SamWithReceiver : kotlin.Annotation {
|
||||
public constructor SamWithReceiver()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
|
||||
|
||||
// FILE: Sam.java
|
||||
public interface Sam {
|
||||
void run(String a);
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
fun test() {
|
||||
Sam { a ->
|
||||
System.out.println(a)
|
||||
}
|
||||
|
||||
Sam {
|
||||
val a = <!NO_THIS!>this<!>
|
||||
System.out.println(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>)
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
public /*synthesized*/ fun Sam(/*0*/ function: (a: kotlin.String!) -> kotlin.Unit): Sam
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public interface Sam {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun run(/*0*/ a: kotlin.String!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Reference in New Issue
Block a user