| author | Stephan Herrmann | 2012-09-16 12:00:39 (EDT) |
|---|---|---|
| committer | Jayaprakash Arthanareeswaran | 2012-10-19 00:49:02 (EDT) |
| commit | e1812b866d1aaf7628da21a301ca4fda773a9ad2 (patch) (side-by-side diff) | |
| tree | 110cb5327c9e49b2cc6522735e7a4d56a038da04 | |
| parent | 8fbbf9aa76d3a9fa45835c898076a78909f57f56 (diff) | |
| download | eclipse.jdt.core-e1812b866d1aaf7628da21a301ca4fda773a9ad2.zip eclipse.jdt.core-e1812b866d1aaf7628da21a301ca4fda773a9ad2.tar.gz eclipse.jdt.core-e1812b866d1aaf7628da21a301ca4fda773a9ad2.tar.bz2 | |
Bug 379834 - Wrong "method can be static" in presence of
qualified super and different staticness of nested super class.
2 files changed, 39 insertions, 1 deletions
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java index fa7f923..7b83a1d 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ProblemTypeAndMethodTest.java @@ -10,6 +10,7 @@ * Stephan Herrmann <stephan@cs.tu-berlin.de> - Contributions for * bug 328281 - visibility leaks not detected when analyzing unused field in private class * bug 379784 - [compiler] "Method can be static" is not getting reported + * bug 379834 - Wrong "method can be static" in presence of qualified super and different staticness of nested super class. *******************************************************************************/ package org.eclipse.jdt.core.tests.compiler.regression; @@ -8031,6 +8032,42 @@ public void test376550_12() { compilerOptions /* custom options */ ); } + +// https://bugs.eclipse.org/bugs/show_bug.cgi?id=376550 +// https://bugs.eclipse.org/379834 - Wrong "method can be static" in presence of qualified super and different staticness of nested super class. +public void test376550_13() { + if (this.complianceLevel < ClassFileConstants.JDK1_5) + return; + Map compilerOptions = getCompilerOptions(); + compilerOptions.put(CompilerOptions.OPTION_ReportMethodCanBeStatic, CompilerOptions.ERROR); + compilerOptions.put(CompilerOptions.OPTION_ReportMethodCanBePotentiallyStatic, CompilerOptions.ERROR); + compilerOptions.put(CompilerOptions.OPTION_ReportUnusedPrivateMember, CompilerOptions.IGNORE); + this.runConformTest( + new String[] { + "QualifiedSuper.java", + "public class QualifiedSuper {\n" + + " class InnerS {\n" + + " void flub() {}\n" + + " }\n" + + " static class InnerT extends InnerS {\n" + + " InnerT(QualifiedSuper qs) {\n" + + " qs.super();\n" + + " }\n" + + " final void schlumpf() {\n" + + " InnerT.super.flub();\n" + + " }\n" + + " } \n" + + "}\n" + }, + "", + null /* no extra class libraries */, + true /* flush output directory */, + null, + compilerOptions /* custom options */, + null + ); +} + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=379530 public void test379530() { if (this.complianceLevel < ClassFileConstants.JDK1_5) diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java index e0beace..1349445 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java @@ -17,6 +17,7 @@ * bug 345305 - [compiler][null] Compiler misidentifies a case of "variable can only be null" * bug 388996 - [compiler][resource] Incorrect 'potential resource leak' * bug 379784 - [compiler] "Method can be static" is not getting reported + * bug 379834 - Wrong "method can be static" in presence of qualified super and different staticness of nested super class. *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; @@ -87,7 +88,7 @@ public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, Fl if (nonStatic) { this.receiver.checkNPE(currentScope, flowContext, flowInfo); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=318682 - if (this.receiver.isThis()) { + if (this.receiver.isThis() || this.receiver.isSuper()) { // accessing non-static method without an object currentScope.resetDeclaringClassMethodStaticFlag(this.actualReceiverType); } |

