From af72cea8b3f701f8af5d61298c975690d362e2e0 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Tue, 22 Oct 2019 12:51:19 +0300 Subject: [PATCH] FIR: Add simple test on SAM conversion for callable receivers ^KT-32725 In Progress --- .../diagnostics/callableReferences/sam.kt | 14 +++++++++++++ .../diagnostics/callableReferences/sam.txt | 20 +++++++++++++++++++ .../fir/FirDiagnosticsTestGenerated.java | 5 +++++ 3 files changed, 39 insertions(+) create mode 100644 compiler/fir/resolve/testData/diagnostics/callableReferences/sam.kt create mode 100644 compiler/fir/resolve/testData/diagnostics/callableReferences/sam.txt diff --git a/compiler/fir/resolve/testData/diagnostics/callableReferences/sam.kt b/compiler/fir/resolve/testData/diagnostics/callableReferences/sam.kt new file mode 100644 index 00000000000..64ee64950f2 --- /dev/null +++ b/compiler/fir/resolve/testData/diagnostics/callableReferences/sam.kt @@ -0,0 +1,14 @@ +interface MySam { + fun run(x: String): Int +} + +class A { + fun bar(x: String): Int {} +} + +fun foo(x: MySam) {} + +fun main() { + val a = A() + foo(a::bar) +} diff --git a/compiler/fir/resolve/testData/diagnostics/callableReferences/sam.txt b/compiler/fir/resolve/testData/diagnostics/callableReferences/sam.txt new file mode 100644 index 00000000000..23b64359bae --- /dev/null +++ b/compiler/fir/resolve/testData/diagnostics/callableReferences/sam.txt @@ -0,0 +1,20 @@ +FILE: sam.kt + public abstract interface MySam : R|kotlin/Any| { + public abstract fun run(x: R|kotlin/String|): R|kotlin/Int| + + } + public final class A : R|kotlin/Any| { + public constructor(): R|A| { + super() + } + + public final fun bar(x: R|kotlin/String|): R|kotlin/Int| { + } + + } + public final fun foo(x: R|MySam|): R|kotlin/Unit| { + } + public final fun main(): R|kotlin/Unit| { + lval a: R|A| = R|/A.A|() + R|/foo|(R|/a|::R|/A.bar|) + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index be9a6057b09..2a5593cacec 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -100,6 +100,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { runTest("compiler/fir/resolve/testData/diagnostics/callableReferences/properties.kt"); } + @TestMetadata("sam.kt") + public void testSam() throws Exception { + runTest("compiler/fir/resolve/testData/diagnostics/callableReferences/sam.kt"); + } + @TestMetadata("simpleClassReceiver.kt") public void testSimpleClassReceiver() throws Exception { runTest("compiler/fir/resolve/testData/diagnostics/callableReferences/simpleClassReceiver.kt");