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. --- src/testA/java/a/pkg/A.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/testA/java') diff --git a/src/testA/java/a/pkg/A.java b/src/testA/java/a/pkg/A.java index f4a30ef..1a0dcac 100644 --- a/src/testA/java/a/pkg/A.java +++ b/src/testA/java/a/pkg/A.java @@ -67,6 +67,11 @@ public class A extends AParent implements AInterface { return conflictingField; } + protected int protectedField; + public int getProtectedFieldWithoutConflict() { + return protectedField; + } + public void aOverloaded() { } -- cgit