From d02785806daf1334382ff229bb8fd4ac2f092c1b Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 9 Jun 2016 17:15:42 +0300 Subject: [PATCH] Type alias shouldn't capture type parameters of inaccessible outer classes. --- .../capturingTypeParametersFromOuterClass.kt | 29 ++++++++++++++++++ .../capturingTypeParametersFromOuterClass.txt | 30 +++++++++++++++++++ .../checkers/DiagnosticsTestGenerated.java | 6 ++++ 3 files changed, 65 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.kt create mode 100644 compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.txt diff --git a/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.kt b/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.kt new file mode 100644 index 00000000000..80e6fb8b3c5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.kt @@ -0,0 +1,29 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER + +class Outer { + typealias LTO = List + + class Nested { + typealias LTO = List<TO> + typealias LTN = List + + inner class Inner { + typealias LTO = List<TO> + typealias LTN = List + typealias LTI = List + } + } +} + +fun foo() { + class Local { + typealias LTF = List + typealias LTL = List + } + + fun localfun() = + object { + typealias LTF = List + typealias LTLF = List + } +} diff --git a/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.txt b/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.txt new file mode 100644 index 00000000000..420c20a0f60 --- /dev/null +++ b/compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.txt @@ -0,0 +1,30 @@ +package + +public fun foo(): kotlin.Unit + +public final class Outer { + public typealias LTO /*captured type parameters: /*0*/ TO*/ = kotlin.collections.List + public constructor Outer() + 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 Nested { + public typealias LTN /*captured type parameters: /*0*/ TN*/ = kotlin.collections.List + public typealias LTO /*captured type parameters: /*0*/ TN*/ = kotlin.collections.List<[ERROR : TO]> + public constructor Nested() + 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 inner class Inner /*captured type parameters: /*1*/ TN*/ { + public typealias LTI /*captured type parameters: /*0*/ TI, /*1*/ TN*/ = kotlin.collections.List + public typealias LTN /*captured type parameters: /*0*/ TI, /*1*/ TN*/ = kotlin.collections.List + public typealias LTO /*captured type parameters: /*0*/ TI, /*1*/ TN*/ = kotlin.collections.List<[ERROR : TO]> + public constructor Inner() + 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 f2ee9ae8cbc..f9b7ff353c9 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -19479,6 +19479,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("capturingTypeParametersFromOuterClass.kt") + public void testCapturingTypeParametersFromOuterClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.kt"); + doTest(fileName); + } + @TestMetadata("conflictingProjections.kt") public void testConflictingProjections() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/conflictingProjections.kt");