From 358136a97feff6fd0586fe04a39adbc7ced381c1 Mon Sep 17 00:00:00 2001 From: Jonas Herzig Date: Fri, 12 Nov 2021 14:19:18 +0100 Subject: Consider location of expression when determining field accessibility A protected field is not accessible unless we are referencing it from within a class which extends its owner. Therefore, we may use a synthetic property with the same name as long as we do not have access to the field. --- .../remap/mapper/kotlin/TestKotlinSyntheticProperties.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/test/kotlin/com/replaymod') diff --git a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt index 20b65b9..65459f2 100644 --- a/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt +++ b/src/test/kotlin/com/replaymod/gradle/remap/mapper/kotlin/TestKotlinSyntheticProperties.kt @@ -103,9 +103,15 @@ class TestKotlinSyntheticProperties { TestData.remapKt(""" import a.pkg.A val v = A().getConflictingFieldWithoutConflict() + class C : A() { + val v = getProtectedFieldWithoutConflict() + } """.trimIndent()) shouldBe """ import b.pkg.B val v = B().getConflictingField() + class C : B() { + val v = getProtectedField() + } """.trimIndent() } @@ -114,9 +120,11 @@ class TestKotlinSyntheticProperties { TestData.remapKt(""" import a.pkg.A val v = A().getA() + val v = A().getProtectedFieldWithoutConflict() """.trimIndent()) shouldBe """ import b.pkg.B val v = B().b + val v = B().protectedField """.trimIndent() } @@ -125,9 +133,15 @@ class TestKotlinSyntheticProperties { TestData.remapKt(""" import a.pkg.A val v = A().conflictingFieldWithoutConflict + class C : A() { + val v = protectedFieldWithoutConflict + } """.trimIndent()) shouldBe """ import b.pkg.B val v = B().getConflictingField() + class C : B() { + val v = getProtectedField() + } """.trimIndent() } @@ -136,9 +150,11 @@ class TestKotlinSyntheticProperties { TestData.remapKt(""" import a.pkg.A val v = A().a + val v = A().protectedFieldWithoutConflict """.trimIndent()) shouldBe """ import b.pkg.B val v = B().b + val v = B().protectedField """.trimIndent() } -- cgit