From f55f880726a777a3106b60944690bfab1f81e434 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Mon, 29 Nov 2021 17:13:29 +0300 Subject: [PATCH] Minor: regenerate tests, update testData --- ...CompilerTestFE10TestdataTestGenerated.java | 18 ++-- ...unInterfaceConstructorReference.fir.ir.txt | 90 +++++++++++++++++++ ...unInterfaceConstructorReference.fir.kt.txt | 45 ++++++++++ .../funInterfaceConstructorReference.kt.txt | 14 +-- 4 files changed, 154 insertions(+), 13 deletions(-) create mode 100644 compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt create mode 100644 compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index c6d78a64921..66c2422c54d 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -10919,6 +10919,18 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/funInterface/basicFunInterfaceDisabled.kt"); } + @Test + @TestMetadata("funInterfaceConstructorReferences_after.kt") + public void testFunInterfaceConstructorReferences_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_after.kt"); + } + + @Test + @TestMetadata("funInterfaceConstructorReferences_before.kt") + public void testFunInterfaceConstructorReferences_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/funInterface/funInterfaceConstructorReferences_before.kt"); + } + @Test @TestMetadata("funInterfaceConversionOnReceiver.kt") public void testFunInterfaceConversionOnReceiver() throws Exception { @@ -10961,12 +10973,6 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/funInterface/noCompatibilityResolveForFunInterfaces.kt"); } - @Test - @TestMetadata("prohibitFunInterfaceConstructorReferences.kt") - public void testProhibitFunInterfaceConstructorReferences() throws Exception { - runTest("compiler/testData/diagnostics/tests/funInterface/prohibitFunInterfaceConstructorReferences.kt"); - } - @Test @TestMetadata("resolveFunInterfaceWithoutMainMethod.kt") public void testResolveFunInterfaceWithoutMainMethod() throws Exception { diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt new file mode 100644 index 00000000000..d97d7d81950 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.ir.txt @@ -0,0 +1,90 @@ +FILE fqName: fileName:/funInterfaceConstructorReference.kt + TYPEALIAS name:KR visibility:public expandedType:.KRunnable + TYPEALIAS name:KSS visibility:public expandedType:.KSupplier + TYPEALIAS name:KCS visibility:public expandedType:.KConsumer + CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KRunnable + FUN name:run visibility:public modality:ABSTRACT <> ($this:.KRunnable) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.KRunnable + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:KSupplier modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KSupplier.KSupplier> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + FUN name:get visibility:public modality:ABSTRACT <> ($this:.KSupplier.KSupplier>) returnType:T of .KSupplier + $this: VALUE_PARAMETER name: type:.KSupplier.KSupplier> + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS INTERFACE name:KConsumer modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KConsumer.KConsumer> + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + FUN name:accept visibility:public modality:ABSTRACT <> ($this:.KConsumer.KConsumer>, x:T of .KConsumer) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.KConsumer.KConsumer> + VALUE_PARAMETER name:x index:0 type:T of .KConsumer + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1, .KRunnable> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.reflect.KFunction1, .KRunnable> declared in ' + FUNCTION_REFERENCE 'public final fun KRunnable (function: kotlin.Function0): .KRunnable declared in ' type=kotlin.reflect.KFunction1, .KRunnable> origin=null reflectionTarget= + FUN name:test1a visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1, .KRunnable> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test1a (): kotlin.reflect.KFunction1, .KRunnable> declared in ' + FUNCTION_REFERENCE 'public final fun KRunnable (function: kotlin.Function0): .KRunnable declared in ' type=kotlin.reflect.KFunction1, .KRunnable> origin=null reflectionTarget= + FUN name:test1b visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test1b (): kotlin.reflect.KFunction declared in ' + FUNCTION_REFERENCE 'public final fun Runnable (function: kotlin.Function0): java.lang.Runnable declared in java.lang' type=kotlin.reflect.KFunction1, java.lang.Runnable> origin=null reflectionTarget= + FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test2 (): kotlin.Function1, .KSupplier> declared in ' + FUNCTION_REFERENCE 'public final fun KSupplier (function: kotlin.Function0.KSupplier>): .KSupplier.KSupplier> declared in ' type=kotlin.reflect.KFunction1, .KSupplier> origin=null reflectionTarget= + : kotlin.String + FUN name:test2a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KSupplier> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test2a (): kotlin.Function1, .KSupplier> declared in ' + FUNCTION_REFERENCE 'public final fun KSupplier (function: kotlin.Function0.KSupplier>): .KSupplier.KSupplier> declared in ' type=kotlin.reflect.KFunction1, .KSupplier> origin=null reflectionTarget= + : kotlin.String + FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.Function1, .KConsumer> declared in ' + FUNCTION_REFERENCE 'public final fun KConsumer (function: kotlin.Function1.KConsumer, kotlin.Unit>): .KConsumer.KConsumer> declared in ' type=kotlin.reflect.KFunction1, .KConsumer> origin=null reflectionTarget= + : kotlin.String + FUN name:test3a visibility:public modality:FINAL <> () returnType:kotlin.Function1, .KConsumer> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun test3a (): kotlin.Function1, .KConsumer> declared in ' + FUNCTION_REFERENCE 'public final fun KConsumer (function: kotlin.Function1.KConsumer, kotlin.Unit>): .KConsumer.KConsumer> declared in ' type=kotlin.reflect.KFunction1, .KConsumer> origin=null reflectionTarget= + : kotlin.String diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt new file mode 100644 index 00000000000..a252547c84f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.fir.kt.txt @@ -0,0 +1,45 @@ +typealias KR = KRunnable +typealias KSS = KSupplier +typealias KCS = KConsumer +fun interface KRunnable { + abstract fun run() + +} + +fun interface KSupplier { + abstract fun get(): T + +} + +fun interface KConsumer { + abstract fun accept(x: T) + +} + +fun test1(): KFunction1, KRunnable> { + return ::KRunnable +} + +fun test1a(): KFunction1, KRunnable> { + return ::KRunnable +} + +fun test1b(): KFunction { + return ::Runnable +} + +fun test2(): Function1, KSupplier> { + return ::KSupplier/*()*/ +} + +fun test2a(): Function1, KSupplier> { + return ::KSupplier/*()*/ +} + +fun test3(): Function1, KConsumer> { + return ::KConsumer/*()*/ +} + +fun test3a(): Function1, KConsumer> { + return ::KConsumer/*()*/ +} diff --git a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt index af71f6aaf7b..c41934bd1ba 100644 --- a/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt +++ b/compiler/testData/ir/irText/expressions/funInterfaceConstructorReference.kt.txt @@ -18,7 +18,7 @@ fun interface KConsumer { typealias KCS = KConsumer fun test1(): KFunction1<@ParameterName(name = "function") Function0, KRunnable> { return { // BLOCK - local fun KRunnable(fn: Function0): KRunnable fn /*-> KRunnable */ + local fun KRunnable(function: Function0): KRunnable function /*-> KRunnable */ ::KRunnable } @@ -26,7 +26,7 @@ fun test1(): KFunction1<@ParameterName(name = "function") Function0, KRunn fun test1a(): KFunction1<@ParameterName(name = "function") Function0, KRunnable> { return { // BLOCK - local fun KRunnable(fn: Function0): KRunnable fn /*-> KRunnable */ + local fun KRunnable(function: Function0): KRunnable function /*-> KRunnable */ ::KRunnable } @@ -34,7 +34,7 @@ fun test1a(): KFunction1<@ParameterName(name = "function") Function0, KRun fun test1b(): KFunction { return { // BLOCK - local fun Runnable(fn: Function0): Runnable fn /*-> Runnable */ + local fun Runnable(function: Function0): Runnable function /*-> Runnable */ ::Runnable } @@ -42,7 +42,7 @@ fun test1b(): KFunction { fun test2(): Function1, KSupplier> { return { // BLOCK - local fun KSupplier(fn: Function0): KSupplier fn /*-> KSupplier */ + local fun KSupplier(function: Function0): KSupplier function /*-> KSupplier */ ::KSupplier } @@ -50,7 +50,7 @@ fun test2(): Function1, KSupplier> { fun test2a(): Function1, KSupplier> { return { // BLOCK - local fun KSupplier(fn: Function0): KSupplier fn /*-> KSupplier */ + local fun KSupplier(function: Function0): KSupplier function /*-> KSupplier */ ::KSupplier } @@ -58,7 +58,7 @@ fun test2a(): Function1, KSupplier> { fun test3(): Function1, KConsumer> { return { // BLOCK - local fun KConsumer(fn: Function1<@ParameterName(name = "x") String, Unit>): KConsumer fn /*-> KConsumer */ + local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer function /*-> KConsumer */ ::KConsumer } @@ -66,7 +66,7 @@ fun test3(): Function1, KConsumer> { fun test3a(): Function1, KConsumer> { return { // BLOCK - local fun KConsumer(fn: Function1<@ParameterName(name = "x") String, Unit>): KConsumer fn /*-> KConsumer */ + local fun KConsumer(function: Function1<@ParameterName(name = "x") String, Unit>): KConsumer function /*-> KConsumer */ ::KConsumer }