From b0a7706812c6ef61a52f9a122ebb87c702534f34 Mon Sep 17 00:00:00 2001 From: Michael Bogdanov Date: Tue, 15 Dec 2015 13:58:35 +0300 Subject: [PATCH] Test for obsolete KT-5445: Bad access to protected data in getfield #KT-5445 Obsolete --- .../testData/codegen/boxMultiFile/kt5445/1.kt | 16 ++++++++++++++++ .../testData/codegen/boxMultiFile/kt5445/2.kt | 5 +++++ .../testData/codegen/boxMultiFile/kt5445_2/1.kt | 13 +++++++++++++ .../testData/codegen/boxMultiFile/kt5445_2/2.kt | 5 +++++ .../BlackBoxMultiFileCodegenTestGenerated.java | 12 ++++++++++++ 5 files changed, 51 insertions(+) create mode 100644 compiler/testData/codegen/boxMultiFile/kt5445/1.kt create mode 100644 compiler/testData/codegen/boxMultiFile/kt5445/2.kt create mode 100644 compiler/testData/codegen/boxMultiFile/kt5445_2/1.kt create mode 100644 compiler/testData/codegen/boxMultiFile/kt5445_2/2.kt diff --git a/compiler/testData/codegen/boxMultiFile/kt5445/1.kt b/compiler/testData/codegen/boxMultiFile/kt5445/1.kt new file mode 100644 index 00000000000..2e6c53cf188 --- /dev/null +++ b/compiler/testData/codegen/boxMultiFile/kt5445/1.kt @@ -0,0 +1,16 @@ +package test2 + +import test.A + +public fun box(): String { + return B().test(B()) +} + +public class B : A() { + public fun test(other:Any): String { + if (other is B && other.s == 2) { + return "OK" + } + return "fail" + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxMultiFile/kt5445/2.kt b/compiler/testData/codegen/boxMultiFile/kt5445/2.kt new file mode 100644 index 00000000000..e0d6465bd51 --- /dev/null +++ b/compiler/testData/codegen/boxMultiFile/kt5445/2.kt @@ -0,0 +1,5 @@ +package test + +open class A { + @JvmField protected val s = 2; +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxMultiFile/kt5445_2/1.kt b/compiler/testData/codegen/boxMultiFile/kt5445_2/1.kt new file mode 100644 index 00000000000..5d5aee157c1 --- /dev/null +++ b/compiler/testData/codegen/boxMultiFile/kt5445_2/1.kt @@ -0,0 +1,13 @@ +package test2 + +import test.A + +class C : A() { + fun a(): String { + return this.s + } +} + +public fun box(): String { + return C().a() +} diff --git a/compiler/testData/codegen/boxMultiFile/kt5445_2/2.kt b/compiler/testData/codegen/boxMultiFile/kt5445_2/2.kt new file mode 100644 index 00000000000..fd1aa049951 --- /dev/null +++ b/compiler/testData/codegen/boxMultiFile/kt5445_2/2.kt @@ -0,0 +1,5 @@ +package test + +open class A { + @JvmField protected val s = "OK"; +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxMultiFileCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxMultiFileCodegenTestGenerated.java index 9e07479f9ff..041cb9170ef 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxMultiFileCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxMultiFileCodegenTestGenerated.java @@ -95,6 +95,18 @@ public class BlackBoxMultiFileCodegenTestGenerated extends AbstractBlackBoxCodeg doTestMultiFile(fileName); } + @TestMetadata("kt5445") + public void testKt5445() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt5445/"); + doTestMultiFile(fileName); + } + + @TestMetadata("kt5445_2") + public void testKt5445_2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt5445_2/"); + doTestMultiFile(fileName); + } + @TestMetadata("kt9717") public void testKt9717() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxMultiFile/kt9717/");