From b84b8902505812e7e0f7160c2c835d731c821dad Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 22 May 2019 14:36:23 +0300 Subject: [PATCH] Add tests to preserve current behavior for upcoming changes ##KT-30983 In Progress --- .../fir/FirDiagnosticsSmokeTestGenerated.java | 15 ++++ .../typealias/importMemberFromJavaViaAlias.kt | 27 +++++++ .../importMemberFromJavaViaAlias.txt | 23 ++++++ .../typeAliasesInImportDirectives.kt | 47 ++++++++++++ .../typeAliasesInImportDirectives.txt | 63 ++++++++++++++++ .../typealias/typeAliasesInQualifiers.kt | 75 +++++++++++++++++++ .../typealias/typeAliasesInQualifiers.txt | 69 +++++++++++++++++ .../checkers/DiagnosticsTestGenerated.java | 15 ++++ .../DiagnosticsUsingJavacTestGenerated.java | 15 ++++ 9 files changed, 349 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.kt create mode 100644 compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.txt create mode 100644 compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.kt create mode 100644 compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.txt create mode 100644 compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.kt create mode 100644 compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.txt diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index ff35d831f51..303622b99c0 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -22376,6 +22376,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/typealias/importFromTypeAliasObject.kt"); } + @TestMetadata("importMemberFromJavaViaAlias.kt") + public void testImportMemberFromJavaViaAlias() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.kt"); + } + @TestMetadata("inGenerics.kt") public void testInGenerics() throws Exception { runTest("compiler/testData/diagnostics/tests/typealias/inGenerics.kt"); @@ -22711,6 +22716,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/typealias/typeAliasShouldExpandToClass.kt"); } + @TestMetadata("typeAliasesInImportDirectives.kt") + public void testTypeAliasesInImportDirectives() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.kt"); + } + + @TestMetadata("typeAliasesInQualifiers.kt") + public void testTypeAliasesInQualifiers() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.kt"); + } + @TestMetadata("typealiasRhsAnnotations.kt") public void testTypealiasRhsAnnotations() throws Exception { runTest("compiler/testData/diagnostics/tests/typealias/typealiasRhsAnnotations.kt"); diff --git a/compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.kt b/compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.kt new file mode 100644 index 00000000000..28aa08a87d7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.kt @@ -0,0 +1,27 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +// FILE: test/jv/JavaSample.java + +package test.jv; + +public class JavaSample { + public static void member() {} +} + +// FILE: foo.kt + +package test.kot + +typealias JavaAlias = test.jv.JavaSample + +// FILE: test.kt + +import test.kot.JavaAlias +import test.kot.JavaAlias.member + +fun foo( + sample: JavaSample, + alias: JavaAlias +) { + member() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.txt b/compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.txt new file mode 100644 index 00000000000..b0a8f6f8045 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.txt @@ -0,0 +1,23 @@ +package + +public fun foo(/*0*/ sample: [ERROR : JavaSample], /*1*/ alias: test.kot.JavaAlias /* = test.jv.JavaSample */): kotlin.Unit + +package test { + + package test.jv { + + public open class JavaSample { + public constructor JavaSample() + 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 + + // Static members + public open fun member(): kotlin.Unit + } + } + + package test.kot { + public typealias JavaAlias = test.jv.JavaSample + } +} diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.kt new file mode 100644 index 00000000000..2342a9d5fd4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.kt @@ -0,0 +1,47 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION + +// FILE: foo.kt + +package test + +typealias ClassAlias = ClassSample +typealias ObjectAlias = ObjectSample +typealias EnumAlias = EnumSample + +class ClassSample { + class Nested1 +} + +object ObjectSample { + class Nested2 +} + +enum class EnumSample { + Entry; + + class Nested3 +} + +// FILE: test.kt + +import test.ClassAlias +import test.ClassAlias.Nested1 + +import test.ClassSample.Nested1.* +import test.ClassAlias.Nested1.* + +import test.ObjectAlias +import test.ObjectAlias.Nested2 + +import test.ObjectSample.Nested2.* +import test.ObjectAlias.Nested2.* + +import test.EnumAlias +import test.EnumAlias.Nested3 + +import test.EnumSample.Nested3.* +import test.EnumAlias.Nested3.* + +import test.EnumAlias.Entry + +fun f() {} diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.txt new file mode 100644 index 00000000000..8f6f1d28916 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.txt @@ -0,0 +1,63 @@ +package + +public fun f(): kotlin.Unit + +package test { + + public final class ClassSample { + public constructor ClassSample() + 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 Nested1 { + public constructor Nested1() + 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 enum class EnumSample : kotlin.Enum { + enum entry Entry + + private constructor EnumSample() + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.EnumSample): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Nested3 { + public constructor Nested3() + 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 + } + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.EnumSample + public final /*synthesized*/ fun values(): kotlin.Array + } + + public object ObjectSample { + private constructor ObjectSample() + 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 Nested2 { + public constructor Nested2() + 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 ClassAlias = test.ClassSample + public typealias EnumAlias = test.EnumSample + public typealias ObjectAlias = test.ObjectSample +} diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.kt new file mode 100644 index 00000000000..057e762c472 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.kt @@ -0,0 +1,75 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION + +// FILE: foo.kt + +package test + +typealias ClassAlias = ClassSample +typealias ObjectAlias = ObjectSample +typealias EnumAlias = EnumSample + +class ClassSample { + class Nested { + fun func() {} + } + + fun func() {} +} + +object ObjectSample { + class Nested { + fun func() {} + } + + fun func() {} +} + +enum class EnumSample { + Entry; + + class Nested { + fun func() {} + } + + fun func() {} +} + +// FILE: test.kt + +fun foo( + a0: test.ClassSample.Nested, + a1: test.ClassAlias.Nested, + + b0: test.ObjectSample.Nested, + b1: test.ObjectAlias.Nested, + + c0: test.EnumSample.Nested, + c1: test.EnumAlias.Nested +) { + test.ClassSample::Nested + test.ClassAlias::Nested + + test.ClassSample::func + test.ClassAlias::func + + test.ClassSample.Nested::func + test.ClassAlias.Nested::func + + test.ObjectSample::Nested + test.ObjectAlias::Nested + + test.ObjectSample::func + test.ObjectAlias::func + + test.ObjectSample.Nested::func + test.ObjectAlias.Nested::func + + test.EnumSample::Nested + test.EnumAlias::Nested + + test.EnumSample::func + test.EnumAlias::func + + test.EnumSample.Nested::func + test.EnumAlias.Nested::func +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.txt b/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.txt new file mode 100644 index 00000000000..65226d254ca --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.txt @@ -0,0 +1,69 @@ +package + +public fun foo(/*0*/ a0: test.ClassSample.Nested, /*1*/ a1: [ERROR : test.ClassAlias.Nested], /*2*/ b0: test.ObjectSample.Nested, /*3*/ b1: [ERROR : test.ObjectAlias.Nested], /*4*/ c0: test.EnumSample.Nested, /*5*/ c1: [ERROR : test.EnumAlias.Nested]): kotlin.Unit + +package test { + + public final class ClassSample { + public constructor ClassSample() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun func(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Nested { + public constructor Nested() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun func(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public final enum class EnumSample : kotlin.Enum { + enum entry Entry + + private constructor EnumSample() + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: test.EnumSample): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final fun func(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Nested { + public constructor Nested() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun func(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): test.EnumSample + public final /*synthesized*/ fun values(): kotlin.Array + } + + public object ObjectSample { + private constructor ObjectSample() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun func(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class Nested { + public constructor Nested() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun func(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + public typealias ClassAlias = test.ClassSample + public typealias EnumAlias = test.EnumSample + public typealias ObjectAlias = test.ObjectSample +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index bcb8d657a70..03ad4c6f582 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -22458,6 +22458,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/typealias/importFromTypeAliasObject.kt"); } + @TestMetadata("importMemberFromJavaViaAlias.kt") + public void testImportMemberFromJavaViaAlias() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.kt"); + } + @TestMetadata("inGenerics.kt") public void testInGenerics() throws Exception { runTest("compiler/testData/diagnostics/tests/typealias/inGenerics.kt"); @@ -22793,6 +22798,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/typealias/typeAliasShouldExpandToClass.kt"); } + @TestMetadata("typeAliasesInImportDirectives.kt") + public void testTypeAliasesInImportDirectives() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.kt"); + } + + @TestMetadata("typeAliasesInQualifiers.kt") + public void testTypeAliasesInQualifiers() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.kt"); + } + @TestMetadata("typealiasRhsAnnotations.kt") public void testTypealiasRhsAnnotations() throws Exception { runTest("compiler/testData/diagnostics/tests/typealias/typealiasRhsAnnotations.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 7fe46339fe1..72dda0aa0b2 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -22378,6 +22378,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/typealias/importFromTypeAliasObject.kt"); } + @TestMetadata("importMemberFromJavaViaAlias.kt") + public void testImportMemberFromJavaViaAlias() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/importMemberFromJavaViaAlias.kt"); + } + @TestMetadata("inGenerics.kt") public void testInGenerics() throws Exception { runTest("compiler/testData/diagnostics/tests/typealias/inGenerics.kt"); @@ -22713,6 +22718,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/typealias/typeAliasShouldExpandToClass.kt"); } + @TestMetadata("typeAliasesInImportDirectives.kt") + public void testTypeAliasesInImportDirectives() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/typeAliasesInImportDirectives.kt"); + } + + @TestMetadata("typeAliasesInQualifiers.kt") + public void testTypeAliasesInQualifiers() throws Exception { + runTest("compiler/testData/diagnostics/tests/typealias/typeAliasesInQualifiers.kt"); + } + @TestMetadata("typealiasRhsAnnotations.kt") public void testTypealiasRhsAnnotations() throws Exception { runTest("compiler/testData/diagnostics/tests/typealias/typealiasRhsAnnotations.kt");