From f7203da2d68bc8e66e592c3b35e9281cfab01f36 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Mon, 14 Nov 2016 14:31:18 +0300 Subject: [PATCH] Type inference SHOULD NOT work for type alias constructor in supertypes list (same as for classes: type arguments should be provided explicitly). --- ...iasConstructorInferenceInSupertypesList.kt | 7 ++++++ ...asConstructorInferenceInSupertypesList.txt | 25 +++++++++++++++++++ .../checkers/DiagnosticsTestGenerated.java | 6 +++++ 3 files changed, 38 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.kt create mode 100644 compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.txt diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.kt new file mode 100644 index 00000000000..93d7d7740be --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.kt @@ -0,0 +1,7 @@ +open class Ref(var x: T) + +typealias R = Ref + +// Type inference SHOULD NOT work for type alias constructor in supertypes list +class Test1 : R(0) +class Test2 : R(0) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.txt new file mode 100644 index 00000000000..ba7a3f6310f --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.txt @@ -0,0 +1,25 @@ +package + +public open class Ref { + public constructor Ref(/*0*/ x: T) + public final var x: T + 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 Test1 { + public constructor Test1() + 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 Test2 : R /* = Ref */ { + public constructor Test2() + public final override /*1*/ /*fake_override*/ var x: kotlin.Int + 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 typealias R = Ref diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index bca2fb1f626..78bdf86f06e 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -21154,6 +21154,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("typeAliasConstructorInferenceInSupertypesList.kt") + public void testTypeAliasConstructorInferenceInSupertypesList() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasConstructorInferenceInSupertypesList.kt"); + doTest(fileName); + } + @TestMetadata("typeAliasConstructorTypeArgumentsInference.kt") public void testTypeAliasConstructorTypeArgumentsInference() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasConstructorTypeArgumentsInference.kt");