From 7e982fed4f75c2bc08e4615f378978c71b3ee222 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Fri, 23 Mar 2018 14:57:53 +0300 Subject: [PATCH] Add complex test on delegated properties --- .../resultTypeOfLambdaForConventionMethods.kt | 17 +++++++++++ ...resultTypeOfLambdaForConventionMethods.txt | 28 +++++++++++++++++++ .../checkers/DiagnosticsTestGenerated.java | 6 ++++ .../DiagnosticsUsingJavacTestGenerated.java | 6 ++++ 4 files changed, 57 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.kt create mode 100644 compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.txt diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.kt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.kt new file mode 100644 index 00000000000..0e4b41d5ec0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +import kotlin.reflect.KProperty + +class A +class B + +fun A.toB(f: (V) -> K, g: (K) -> V): B = B() + +operator fun B.getValue(o: Any, desc: KProperty<*>): E1 = TODO() +operator fun B.setValue(o: Any, desc: KProperty<*>, value: E2) {} + +val q = A() + +class Test { + var prop by q.toB({ "abc" }, { "cde" }) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.txt b/compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.txt new file mode 100644 index 00000000000..c4dcd432d43 --- /dev/null +++ b/compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.txt @@ -0,0 +1,28 @@ +package + +public val q: A +public operator fun B.getValue(/*0*/ o: kotlin.Any, /*1*/ desc: kotlin.reflect.KProperty<*>): E1 +public operator fun B.setValue(/*0*/ o: kotlin.Any, /*1*/ desc: kotlin.reflect.KProperty<*>, /*2*/ value: E2): kotlin.Unit +public fun A.toB(/*0*/ f: (V) -> K, /*1*/ g: (K) -> V): B + +public final class A { + public constructor A() + 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 +} + +public final class B { + public constructor B() + 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 +} + +public final class Test { + public constructor Test() + public final var prop: kotlin.String + 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/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 7fa73c5fabc..23281741cda 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -6277,6 +6277,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("resultTypeOfLambdaForConventionMethods.kt") + public void testResultTypeOfLambdaForConventionMethods() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.kt"); + doTest(fileName); + } + @TestMetadata("typeOfLazyDelegatedPropertyWithObject.kt") public void testTypeOfLazyDelegatedPropertyWithObject() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/inference/typeOfLazyDelegatedPropertyWithObject.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 2ff36d9a83c..7f136af71b5 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -6277,6 +6277,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing doTest(fileName); } + @TestMetadata("resultTypeOfLambdaForConventionMethods.kt") + public void testResultTypeOfLambdaForConventionMethods() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/inference/resultTypeOfLambdaForConventionMethods.kt"); + doTest(fileName); + } + @TestMetadata("typeOfLazyDelegatedPropertyWithObject.kt") public void testTypeOfLazyDelegatedPropertyWithObject() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/delegatedProperty/inference/typeOfLazyDelegatedPropertyWithObject.kt");