From d3e3039eb2289c9c0bb84f5f654903d4c8954344 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 16 Oct 2014 18:08:41 +0400 Subject: [PATCH] Add tests for obsolete "nested class is inaccessible" #KT-3535 Obsolete #KT-3647 Obsolete #KT-3731 Obsolete --- .../diagnostics/tests/regressions/kt3535.kt | 9 +++++++ .../diagnostics/tests/regressions/kt3535.txt | 17 +++++++++++++ .../diagnostics/tests/regressions/kt3647.kt | 9 +++++++ .../diagnostics/tests/regressions/kt3647.txt | 17 +++++++++++++ .../diagnostics/tests/regressions/kt3731.kt | 17 +++++++++++++ .../diagnostics/tests/regressions/kt3731.txt | 24 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 18 ++++++++++++++ 7 files changed, 111 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/regressions/kt3535.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt3535.txt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt3647.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt3647.txt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt3731.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt3731.txt diff --git a/compiler/testData/diagnostics/tests/regressions/kt3535.kt b/compiler/testData/diagnostics/tests/regressions/kt3535.kt new file mode 100644 index 00000000000..4b027cb07d4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt3535.kt @@ -0,0 +1,9 @@ +// KT-3535 Functional value-parametr in nested class is inaccessible + +class Foo { + class Bar(val p: (Any) -> Any) { + fun f() { + p(1) + } + } +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt3535.txt b/compiler/testData/diagnostics/tests/regressions/kt3535.txt new file mode 100644 index 00000000000..73cc9479f8d --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt3535.txt @@ -0,0 +1,17 @@ +package + +internal final class Foo { + public constructor Foo() + 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 + + internal final class Bar { + public constructor Bar(/*0*/ p: (kotlin.Any) -> kotlin.Any) + internal final val p: (kotlin.Any) -> kotlin.Any + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt3647.kt b/compiler/testData/diagnostics/tests/regressions/kt3647.kt new file mode 100644 index 00000000000..d9cbb3c9fd7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt3647.kt @@ -0,0 +1,9 @@ +// KT-3647 Unexpected compilation error: "Expression is inaccessible from a nested class" + +class Test(val value: Int) { + class object { + fun create(init: () -> Int): Test { + return Test(init()) + } + } +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt3647.txt b/compiler/testData/diagnostics/tests/regressions/kt3647.txt new file mode 100644 index 00000000000..a388370f059 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt3647.txt @@ -0,0 +1,17 @@ +package + +internal final class Test { + public constructor Test(/*0*/ value: kotlin.Int) + internal final val value: 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 + + internal class object { + private constructor () + internal final fun create(/*0*/ init: () -> kotlin.Int): Test + 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 + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt3731.kt b/compiler/testData/diagnostics/tests/regressions/kt3731.kt new file mode 100644 index 00000000000..da5751f21ce --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt3731.kt @@ -0,0 +1,17 @@ +// KT-3731 Resolve & inner class + +class A { + fun foo() {} + fun bar(f: A.() -> Unit = {}) = f() +} + +class B { + class D { + { + A().bar { + this.foo() + foo() + } + } + } +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt3731.txt b/compiler/testData/diagnostics/tests/regressions/kt3731.txt new file mode 100644 index 00000000000..733736a5c39 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt3731.txt @@ -0,0 +1,24 @@ +package + +internal final class A { + public constructor A() + internal final fun bar(/*0*/ f: A.() -> kotlin.Unit = ...): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + internal final fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +internal 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 + + internal final class D { + public constructor D() + 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 + } +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 537a849be51..72d5a195361 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -8399,6 +8399,24 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt3535.kt") + public void testKt3535() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt3535.kt"); + doTest(fileName); + } + + @TestMetadata("kt3647.kt") + public void testKt3647() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt3647.kt"); + doTest(fileName); + } + + @TestMetadata("kt3731.kt") + public void testKt3731() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt3731.kt"); + doTest(fileName); + } + @TestMetadata("kt385.109.441.kt") public void testKt385_109_441() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt385.109.441.kt");