From 2645b4463b4fd6eb3e4fd73d8b733af5595509d4 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Fri, 27 Mar 2026 16:17:31 +0100 Subject: [PATCH] IDEA-331038 [java]: better error message for "attempting to assign weaker access privileges" GitOrigin-RevId: 9edbeca1895c09e471200dc4d31ad587c382045a --- .../messages/JavaCompilationErrorBundle.properties | 2 +- .../advHighlighting/AccessLevelClash.java | 8 ++++---- .../advHighlighting/StaticOverride.java | 6 +++--- .../advHighlighting9/PrivateInInterfacesOverriding.java | 2 +- .../DontReportWeakerVisibilityProblemUpInHierarchy.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/java/codeserver/highlighting/resources/messages/JavaCompilationErrorBundle.properties b/java/codeserver/highlighting/resources/messages/JavaCompilationErrorBundle.properties index 4e0d41c96291..298c08ba9865 100644 --- a/java/codeserver/highlighting/resources/messages/JavaCompilationErrorBundle.properties +++ b/java/codeserver/highlighting/resources/messages/JavaCompilationErrorBundle.properties @@ -218,7 +218,7 @@ method.should.have.body=Method body expected method.instance.overrides.static=Instance method ''{0}'' in ''{1}'' cannot override static method ''{2}'' in ''{3}'' method.static.overrides.instance=Static method ''{0}'' in ''{1}'' cannot override instance method ''{2}'' in ''{3}'' method.overrides.final=''{0}'' cannot override ''{1}'' in ''{2}''; overridden method is final -method.inheritance.weaker.privileges={0}; attempting to assign weaker access privileges (''{1}''); was ''{2}'' +method.inheritance.weaker.privileges={0}; cannot reduce visibility from ''{2}'' to ''{1}'' method.inheritance.clash.unrelated.return.types={0}; methods have unrelated return types method.inheritance.clash.incompatible.return.types={0}; incompatible return type method.inheritance.clash.does.not.throw={0}; overridden method does not throw ''{1}'' diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessLevelClash.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessLevelClash.java index 077b6873bcc6..636871a602de 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessLevelClash.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/AccessLevelClash.java @@ -4,7 +4,7 @@ interface i { } public class a implements i { - void ff() {} + void ff() {} } class ai implements i { public int ff() { return 0;} @@ -25,7 +25,7 @@ class c3 extends c2 { class c4 extends c3 { private c4() {} - private void g() {} + private void g() {} private String fff(String s) throws java.io.IOException { return null; } } class c4i extends c3 { @@ -55,7 +55,7 @@ interface A { interface ConflictWithObject { Object clone() throws CloneNotSupportedException; } -class s implements ConflictWithObject { +class s implements ConflictWithObject { } @@ -67,7 +67,7 @@ interface InderFace { interface SubInderFace extends InderFace { } -class Implementation implements SubInderFace { +class Implementation implements SubInderFace { } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java index 3db96fb51612..1b81a6e999e6 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting/StaticOverride.java @@ -34,13 +34,13 @@ interface i2 { class weak { void f1() {} } -class a2 extends weak implements i { +class a2 extends weak implements i { } class a3 { protected void f1() {} } -class a4 extends a3 implements i { +class a4 extends a3 implements i { // public void f1() {} } class a5 extends a3 implements i { @@ -104,7 +104,7 @@ class Foo { protected static void foo(String s) {} } class Bar extends Foo{ - private static void foo(String s) {} + private static void foo(String s) {} } diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting9/PrivateInInterfacesOverriding.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting9/PrivateInInterfacesOverriding.java index 091b779ac2a6..9429dbf1ea2f 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting9/PrivateInInterfacesOverriding.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting9/PrivateInInterfacesOverriding.java @@ -5,7 +5,7 @@ interface A1 extends A { private static void m() {} } interface A2 extends A { - private void m() {} + private void m() {} } interface B { diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DontReportWeakerVisibilityProblemUpInHierarchy.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DontReportWeakerVisibilityProblemUpInHierarchy.java index 2f17edfb3e93..732d5274e03b 100644 --- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DontReportWeakerVisibilityProblemUpInHierarchy.java +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/DontReportWeakerVisibilityProblemUpInHierarchy.java @@ -5,7 +5,7 @@ class F { class E extends F { @Override - protected void f() { + protected void f() { super.f(); } }