Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 168713 Details for
Bug 312989
Accepts illegal method-local classes if hidden by generics parameters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch under consideration
patch.txt (text/plain), 6.33 KB, created by
Srikanth Sankaran
on 2010-05-17 07:36:26 EDT
(
hide
)
Description:
Patch under consideration
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2010-05-17 07:36:26 EDT
Size:
6.33 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java,v >retrieving revision 1.162 >diff -u -r1.162 TypeDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 25 Nov 2009 04:56:02 -0000 1.162 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 17 May 2010 11:35:06 -0000 >@@ -1187,6 +1187,21 @@ > ReferenceBinding existingType = (ReferenceBinding) existing; > if (existingType instanceof TypeVariableBinding) { > blockScope.problemReporter().typeHiding(this, (TypeVariableBinding) existingType); >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=312989, check for collision with enclosing type. >+ Scope outerScope = blockScope.parent; >+checkOuterScope:while (outerScope != null) { >+ Binding existing2 = outerScope.getType(this.name); >+ if (existing2 == null) >+ break checkOuterScope; >+ if (existing2 instanceof ReferenceBinding >+ && existing2 != existing >+ && existing2.isValidBinding() >+ && existing2.kind() != Binding.TYPE_PARAMETER) { >+ blockScope.problemReporter().typeCollidesWithEnclosingType(this); >+ break checkOuterScope; >+ } >+ outerScope = outerScope.parent; >+ } > } else if (existingType instanceof LocalTypeBinding > && ((LocalTypeBinding) existingType).scope.methodScope() == blockScope.methodScope()) { > // dup in same method >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java >=================================================================== >RCS file: src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java >diff -N src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/InnerClass15Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,116 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jdt.core.tests.compiler.regression; >+ >+import java.util.Map; >+ >+import junit.framework.Test; >+ >+import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; >+ >+public class InnerClass15Test extends AbstractRegressionTest { >+public InnerClass15Test(String name) { >+ super(name); >+} >+static { >+// TESTS_NUMBERS = new int[] { 2 }; >+} >+public static Test suite() { >+ return buildMinimalComplianceTestSuite(testClass(), F_1_5); >+} >+protected Map getCompilerOptions() { >+ Map options = super.getCompilerOptions(); >+ options.put(CompilerOptions.OPTION_ReportRawTypeReference, CompilerOptions.IGNORE); >+ return options; >+} >+public void test001() { >+ this.runNegativeTest(new String[] { >+ "X.java", >+ "class X {\n" + >+ " <X> void foo() {\n" + >+ " class X {}\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " <X> void foo() {\n" + >+ " ^\n" + >+ "The type parameter X is hiding the type X\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " class X {}\n" + >+ " ^\n" + >+ "The nested type X is hiding the type parameter X of the generic method foo() of type X\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 3)\n" + >+ " class X {}\n" + >+ " ^\n" + >+ "The nested type X cannot hide an enclosing type\n" + >+ "----------\n"); >+} >+public void test002() { >+ this.runNegativeTest(new String[] { >+ "X.java", >+ "class X<X> {\n" + >+ " void foo() {\n" + >+ " class X {}\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 1)\n" + >+ " class X<X> {\n" + >+ " ^\n" + >+ "The type parameter X is hiding the type X<X>\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 3)\n" + >+ " class X {}\n" + >+ " ^\n" + >+ "The nested type X is hiding the type parameter X of type X<X>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 3)\n" + >+ " class X {}\n" + >+ " ^\n" + >+ "The nested type X cannot hide an enclosing type\n" + >+ "----------\n"); >+} >+public void test003() { >+ this.runNegativeTest(new String[] { >+ "Y.java", >+ "class Y {\n" + >+ "class X {}\n" + >+ " <X> void foo() {\n" + >+ " class X {}\n" + >+ " }\n" + >+ "}", >+ }, >+ "----------\n" + >+ "1. WARNING in Y.java (at line 3)\n" + >+ " <X> void foo() {\n" + >+ " ^\n" + >+ "The type parameter X is hiding the type Y.X\n" + >+ "----------\n" + >+ "2. WARNING in Y.java (at line 4)\n" + >+ " class X {}\n" + >+ " ^\n" + >+ "The nested type X is hiding the type parameter X of the generic method foo() of type Y\n" + >+ "----------\n" + >+ "3. ERROR in Y.java (at line 4)\n" + >+ " class X {}\n" + >+ " ^\n" + >+ "The nested type X cannot hide an enclosing type\n" + >+ "----------\n"); >+} >+public static Class testClass() { >+ return InnerClass15Test.class; >+} >+} >Index: src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java,v >retrieving revision 1.85 >diff -u -r1.85 TestAll.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java 11 May 2010 18:53:50 -0000 1.85 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/TestAll.java 17 May 2010 11:35:15 -0000 >@@ -94,6 +94,7 @@ > since_1_5.add(Deprecated15Test.class); > since_1_5.add(InnerEmulationTest_1_5.class); > since_1_5.add(AssignmentTest_1_5.class); >+ since_1_5.add(InnerClass15Test.class); > > // Tests to run when compliance is greater than 1.5 > ArrayList since_1_6 = new ArrayList();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 312989
:
168624
|
168713
|
168727