diff --git a/plugins/sam-with-receiver/test/org/jetbrains/kotlin/samWithReceiver/SamWithReceiverTests.kt b/plugins/sam-with-receiver/test/org/jetbrains/kotlin/samWithReceiver/SamWithReceiverTests.kt index 5c0f021bb13..f06fb8db213 100644 --- a/plugins/sam-with-receiver/test/org/jetbrains/kotlin/samWithReceiver/SamWithReceiverTests.kt +++ b/plugins/sam-with-receiver/test/org/jetbrains/kotlin/samWithReceiver/SamWithReceiverTests.kt @@ -16,6 +16,7 @@ import org.jetbrains.kotlin.test.runners.AbstractDiagnosticTest import org.jetbrains.kotlin.test.runners.AbstractFirDiagnosticTest import org.jetbrains.kotlin.test.runners.codegen.AbstractFirBlackBoxCodegenTest import org.jetbrains.kotlin.test.runners.codegen.AbstractIrBlackBoxCodegenTest +import org.jetbrains.kotlin.test.runners.configurationForClassicAndFirTestsAlongside import org.jetbrains.kotlin.test.services.EnvironmentConfigurator import org.jetbrains.kotlin.test.services.TestServices @@ -24,14 +25,19 @@ import org.jetbrains.kotlin.test.services.TestServices abstract class AbstractSamWithReceiverTest : AbstractDiagnosticTest() { override fun configure(builder: TestConfigurationBuilder) { super.configure(builder) - builder.configurePlugin() + with(builder) { + configurePlugin() + } } } abstract class AbstractFirSamWithReceiverTest : AbstractFirDiagnosticTest() { override fun configure(builder: TestConfigurationBuilder) { super.configure(builder) - builder.configurePlugin() + with(builder) { + configurePlugin() + configurationForClassicAndFirTestsAlongside() + } } } diff --git a/plugins/sam-with-receiver/testData/diagnostics/noParameters.kt b/plugins/sam-with-receiver/testData/diagnostics/noParameters.kt index d545f204117..fe52563f9bf 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/noParameters.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/noParameters.kt @@ -1,6 +1,6 @@ // FIR_IDENTICAL -// FILE: SamConstructor.kt +// FILE: Sam.java @SamWithReceiver public interface Sam { void run(); diff --git a/plugins/sam-with-receiver/testData/diagnostics/noReturnType.fir.kt b/plugins/sam-with-receiver/testData/diagnostics/noReturnType.fir.kt new file mode 100644 index 00000000000..60fc42ccea6 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/noReturnType.fir.kt @@ -0,0 +1,19 @@ +// FILE: Sam.java +@SamWithReceiver +public interface Sam { + void run(String a, String b); +} + +// FILE: test.kt +annotation class SamWithReceiver + +fun test() { + Sam { a, b -> + System.out.println(a) + } + + Sam { b -> + val a: String = this + System.out.println(a) + } +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/noReturnType.fir.txt b/plugins/sam-with-receiver/testData/diagnostics/noReturnType.fir.txt new file mode 100644 index 00000000000..732e64de71b --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/noReturnType.fir.txt @@ -0,0 +1,17 @@ +package + +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 +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/noReturnType.kt b/plugins/sam-with-receiver/testData/diagnostics/noReturnType.kt index ead3e06f959..e4135ac86bf 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/noReturnType.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/noReturnType.kt @@ -1,4 +1,4 @@ -// FILE: SamConstructor.kt +// FILE: Sam.java @SamWithReceiver public interface Sam { void run(String a, String b); @@ -8,7 +8,7 @@ public interface Sam { annotation class SamWithReceiver fun test() { - Sam { a, b -> + Sam { a, b -> System.out.println(a) } diff --git a/plugins/sam-with-receiver/testData/diagnostics/samConversionNoParameters.kt b/plugins/sam-with-receiver/testData/diagnostics/samConversionNoParameters.kt index 4a694901e04..f62da5b5e78 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/samConversionNoParameters.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/samConversionNoParameters.kt @@ -1,6 +1,6 @@ // FIR_IDENTICAL -// FILE: SamConstructor.kt +// FILE: Sam.java @SamWithReceiver public interface Sam { void run(); diff --git a/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.fir.kt b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.fir.kt new file mode 100644 index 00000000000..b34db45bd1e --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.fir.kt @@ -0,0 +1,20 @@ +// 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 { a -> System.out.println(a) } + e.exec { System.out.println(this) } +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.fir.txt b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.fir.txt new file mode 100644 index 00000000000..5686d9a78f0 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.fir.txt @@ -0,0 +1,25 @@ +package + +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 +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.kt b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.kt index 44fc9cc25cf..d2bd61ce458 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.kt @@ -1,4 +1,4 @@ -// FILE: SamConstructor.kt +// FILE: Sam.java @SamWithReceiver public interface Sam { void run(String a); @@ -15,6 +15,6 @@ annotation class SamWithReceiver fun test() { val e = Exec() - e.exec { a -> System.out.println(a) } + e.exec { a -> System.out.println(a) } e.exec { System.out.println(this) } } diff --git a/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.fir.kt b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.fir.kt new file mode 100644 index 00000000000..98ea106e786 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.fir.kt @@ -0,0 +1,17 @@ +// 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(this) } +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.fir.txt b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.fir.txt new file mode 100644 index 00000000000..7b4f5486250 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.fir.txt @@ -0,0 +1,18 @@ +package + +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 +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.kt b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.kt index 692ccecab3f..e5e57340350 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.kt @@ -1,4 +1,4 @@ -// FILE: SamConstructor.kt +// FILE: Sam.java public interface Sam { void run(String a); } @@ -13,5 +13,5 @@ fun test() { val e = Exec() e.exec { a -> System.out.println(a) } - e.exec { System.out.println(this) } + e.exec { System.out.println(this) } } diff --git a/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.fir.kt b/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.fir.kt new file mode 100644 index 00000000000..d07ee0cffc6 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.fir.kt @@ -0,0 +1,21 @@ +// FILE: Sam.java +@SamWithReceiver +public interface Sam { + String run(String a, String b); +} + +// FILE: test.kt +annotation class SamWithReceiver + +fun test() { + Sam { a, b -> + System.out.println(a) + "" + } + + Sam { b -> + val a: String = this + System.out.println(a) + "" + } +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.fir.txt b/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.fir.txt new file mode 100644 index 00000000000..348b72e16bc --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.fir.txt @@ -0,0 +1,17 @@ +package + +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 +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.kt b/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.kt index 62c4e69e065..849b4aa3861 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.kt @@ -1,4 +1,4 @@ -// FILE: SamConstructor.kt +// FILE: Sam.java @SamWithReceiver public interface Sam { String run(String a, String b); @@ -8,7 +8,7 @@ public interface Sam { annotation class SamWithReceiver fun test() { - Sam { a, b -> + Sam { a, b -> System.out.println(a) "" } diff --git a/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.fir.kt b/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.fir.kt new file mode 100644 index 00000000000..a604a8996d0 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.fir.kt @@ -0,0 +1,18 @@ +// 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 { b -> + val a = this@Sam + System.out.println(a) + "" + } +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.fir.txt b/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.fir.txt new file mode 100644 index 00000000000..7130d649562 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.fir.txt @@ -0,0 +1,10 @@ +package + +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 +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.kt b/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.kt index 61df99eefd7..1ee8df3bd2a 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.kt @@ -1,4 +1,4 @@ -// FILE: SamConstructor.kt +// FILE: Sam.java public interface Sam { String run(String a, String b); } @@ -10,9 +10,9 @@ fun test() { "" } - Sam { b -> - val a = this@Sam - System.out.println(a) + Sam { b -> + val a = this@Sam + System.out.println(a) "" } } diff --git a/plugins/sam-with-receiver/testData/diagnostics/singleParameter.fir.kt b/plugins/sam-with-receiver/testData/diagnostics/singleParameter.fir.kt new file mode 100644 index 00000000000..0ab8a2863ef --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/singleParameter.fir.kt @@ -0,0 +1,20 @@ +// FILE: Sam.java +@SamWithReceiver +public interface Sam { + void run(String a); +} + +// FILE: test.kt +annotation class SamWithReceiver + +fun test() { + Sam { a -> + System.out.println(a) + } + + Sam { + val a: String = this + val a2: String = it + System.out.println(a) + } +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/singleParameter.fir.txt b/plugins/sam-with-receiver/testData/diagnostics/singleParameter.fir.txt new file mode 100644 index 00000000000..79a3df990e1 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/singleParameter.fir.txt @@ -0,0 +1,17 @@ +package + +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 +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/singleParameter.kt b/plugins/sam-with-receiver/testData/diagnostics/singleParameter.kt index 9d4d8405689..78844ea051e 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/singleParameter.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/singleParameter.kt @@ -1,4 +1,4 @@ -// FILE: SamConstructor.kt +// FILE: Sam.java @SamWithReceiver public interface Sam { void run(String a); @@ -8,8 +8,8 @@ public interface Sam { annotation class SamWithReceiver fun test() { - Sam { a -> - System.out.println(a) + Sam { a -> + System.out.println(a) } Sam { diff --git a/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.fir.kt b/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.fir.kt new file mode 100644 index 00000000000..0601a128cdc --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.fir.kt @@ -0,0 +1,16 @@ +// FILE: Sam.java +public interface Sam { + void run(String a); +} + +// FILE: test.kt +fun test() { + Sam { a -> + System.out.println(a) + } + + Sam { + val a = this + System.out.println(a) + } +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.fir.txt b/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.fir.txt new file mode 100644 index 00000000000..fb30fe1a890 --- /dev/null +++ b/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.fir.txt @@ -0,0 +1,10 @@ +package + +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 +} diff --git a/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.kt b/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.kt index b186637d32d..7e28a9067e1 100644 --- a/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.kt +++ b/plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.kt @@ -1,4 +1,4 @@ -// FILE: SamConstructor.kt +// FILE: Sam.java public interface Sam { void run(String a); } @@ -11,6 +11,6 @@ fun test() { Sam { val a = this - System.out.println(a) + System.out.println(a) } } diff --git a/plugins/sam-with-receiver/testData/script/samConversionSimple.kts b/plugins/sam-with-receiver/testData/script/samConversionSimple.kts index f7f31351e60..3f41451c051 100644 --- a/plugins/sam-with-receiver/testData/script/samConversionSimple.kts +++ b/plugins/sam-with-receiver/testData/script/samConversionSimple.kts @@ -8,7 +8,7 @@ import java.lang.annotation.RetentionPolicy; public @interface SamWithReceiver1 { } -// FILE: SamConstructor.kt +// FILE: Sam.java @SamWithReceiver1 public interface Sam { void run(String a, String b);