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 71771 Details for
Bug 149590
[model] bindings for duplicate local variables share same key
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed fix and regression tests
149590.txt (text/plain), 13.46 KB, created by
Jerome Lanneluc
on 2007-06-19 12:31:47 EDT
(
hide
)
Description:
Proposed fix and regression tests
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2007-06-19 12:31:47 EDT
Size:
13.46 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java,v >retrieving revision 1.40 >diff -u -r1.40 LocalVariableBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 11 May 2007 14:55:28 -0000 1.40 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/LocalVariableBinding.java 19 Jun 2007 16:30:09 -0000 >@@ -88,6 +88,9 @@ > buffer.append('#'); > buffer.append(this.name); > >+ // add source pos to avoid same key for duplicate variables >+ buffer.append(this.declaration.sourceStart); >+ > int length = buffer.length(); > char[] uniqueKey = new char[length]; > buffer.getChars(0, length, uniqueKey, 0); >Index: model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java,v >retrieving revision 1.40 >diff -u -r1.40 BindingKeyResolver.java >--- model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java 10 May 2007 00:16:04 -0000 1.40 >+++ model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java 19 Jun 2007 16:30:09 -0000 >@@ -229,7 +229,11 @@ > } > for (int i = 0; i < this.scope.localIndex; i++) { > LocalVariableBinding local = this.scope.locals[i]; >- if (CharOperation.equals(varName, local.name)) { >+ char[] localName = local.name; >+ int localLength = localName.length; >+ char[] localPos = Integer.toString(local.declaration.sourceStart).toCharArray(); >+ if (CharOperation.equals(local.name, varName, 0, localLength) >+ && CharOperation.equals(localPos, varName, localLength, varName.length)) { > this.methodBinding = null; > this.compilerBinding = local; > return; >#P org.eclipse.jdt.core.tests.model >Index: src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java,v >retrieving revision 1.75 >diff -u -r1.75 BatchASTCreationTests.java >--- src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 14 Mar 2007 09:32:48 -0000 1.75 >+++ src/org/eclipse/jdt/core/tests/dom/BatchASTCreationTests.java 19 Jun 2007 16:30:16 -0000 >@@ -830,7 +830,7 @@ > " }\n" + > "}", > }, >- "Lp1/X;.foo()V#i"); >+ "Lp1/X;.foo()V#i52"); > } > > /* >@@ -852,7 +852,7 @@ > " }\n" + > "}", > }, >- "Lp1/X;.foo()V#1#b"); >+ "Lp1/X;.foo()V#1#b113"); > } > > /* >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java,v >retrieving revision 1.179 >diff -u -r1.179 ASTConverterTest2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 14 Mar 2007 08:18:40 -0000 1.179 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTest2.java 19 Jun 2007 16:30:12 -0000 >@@ -2831,7 +2831,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement)getASTNode(unit, 0, 0, 0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;#0#i", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;#0#i45", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -2847,7 +2847,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) block.statements().get(0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;#0#0#j", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;#0#0#j75", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -2861,7 +2861,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement)getASTNode(unit, 0, 1, 0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;.foo()V#i", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;.foo()V#i110", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -2877,7 +2877,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) block.statements().get(0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;.foo()V#0#j", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;.foo()V#0#j140", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -2893,7 +2893,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) block.statements().get(0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;.foo()V#1#j", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;.foo()V#1#j165", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >Index: src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java,v >retrieving revision 1.122 >diff -u -r1.122 ASTConverterTestAST3_2.java >--- src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 10 May 2007 00:16:14 -0000 1.122 >+++ src/org/eclipse/jdt/core/tests/dom/ASTConverterTestAST3_2.java 19 Jun 2007 16:30:15 -0000 >@@ -2905,7 +2905,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement)getASTNode(unit, 0, 0, 0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;#0#i", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;#0#i45", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -2921,7 +2921,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) block.statements().get(0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;#0#0#j", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;#0#0#j75", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -2935,7 +2935,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement)getASTNode(unit, 0, 1, 0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;.foo()V#i", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;.foo()V#i110", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -2951,7 +2951,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) block.statements().get(0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;.foo()V#0#j", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;.foo()V#0#j140", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -2967,7 +2967,7 @@ > VariableDeclarationStatement variableDeclarationStatement = (VariableDeclarationStatement) block.statements().get(0); > VariableDeclarationFragment fragment = (VariableDeclarationFragment) variableDeclarationStatement.fragments().get(0); > IVariableBinding localBinding = fragment.resolveBinding(); >- assertEquals("Unexpected key", "Ltest0502/A;.foo()V#1#j", localBinding.getKey()); //$NON-NLS-1$ >+ assertEquals("Unexpected key", "Ltest0502/A;.foo()V#1#j165", localBinding.getKey()); //$NON-NLS-1$ > } > > /** >@@ -8305,7 +8305,6 @@ > > /** > * http://dev.eclipse.org/bugs/show_bug.cgi?id=144858 >- * TODO (frederic) check that keys are different (PR 149590) > */ > public void test0660() throws JavaModelException { > ICompilationUnit workingCopy = null; >@@ -8336,9 +8335,9 @@ > assertNotNull("No binding", variableBinding); > assertEquals("Wrong name", "x", variableBinding.getName()); > // (PR 149590) >- // String key = variableBinding.getKey(); >+ String key = variableBinding.getKey(); > >- node = getASTNode(unit, 0, 0, 0); >+ node = getASTNode(unit, 0, 0, 1); > assertEquals("Not a variable declaration statement", ASTNode.VARIABLE_DECLARATION_STATEMENT, node.getNodeType()); > statement = (VariableDeclarationStatement) node; > fragments = statement.fragments(); >@@ -8348,8 +8347,8 @@ > assertNotNull("No binding", variableBinding); > assertEquals("Wrong name", "x", variableBinding.getName()); > // (PR 149590) >- // String key2 = variableBinding.getKey(); >- //assertFalse("Keys should not be equals", key2.equals(key)); >+ String key2 = variableBinding.getKey(); >+ assertFalse("Keys should not be equals", key2.equals(key)); > } finally { > if (workingCopy != null) > workingCopy.discardWorkingCopy(); >@@ -8358,7 +8357,6 @@ > > /** > * http://dev.eclipse.org/bugs/show_bug.cgi?id=144858 >- * TODO (frederic) check that keys are different (PR 149590) > */ > public void test0661() throws JavaModelException { > ICompilationUnit workingCopy = null; >@@ -8392,7 +8390,7 @@ > assertNotNull("No binding", variableBinding); > assertEquals("Wrong name", "x", variableBinding.getName()); > // (PR 149590) >- // String key = variableBinding.getKey(); >+ String key = variableBinding.getKey(); > > node = getASTNode(unit, 0, 0, 1); > assertEquals("Not a try statement", ASTNode.TRY_STATEMENT, node.getNodeType()); >@@ -8405,8 +8403,8 @@ > assertNotNull("No binding", variableBinding); > assertEquals("Wrong name", "x", variableBinding.getName()); > // (PR 149590) >- // String key2 = variableBinding.getKey(); >- //assertFalse("Keys should not be equals", key2.equals(key)); >+ String key2 = variableBinding.getKey(); >+ assertFalse("Keys should not be equals", key2.equals(key)); > } finally { > if (workingCopy != null) > workingCopy.discardWorkingCopy(); >@@ -8415,7 +8413,6 @@ > > /** > * http://dev.eclipse.org/bugs/show_bug.cgi?id=144858 >- * TODO (frederic) check that keys are different (PR 149590) > */ > public void test0662() throws JavaModelException { > ICompilationUnit workingCopy = null; >@@ -8451,7 +8448,7 @@ > assertNotNull("No binding", variableBinding); > assertEquals("Wrong name", "x", variableBinding.getName()); > // (PR 149590) >- // String key = variableBinding.getKey(); >+ String key = variableBinding.getKey(); > > node = getASTNode(unit, 0, 0, 1); > assertEquals("Not an if statement", ASTNode.IF_STATEMENT, node.getNodeType()); >@@ -8470,8 +8467,8 @@ > assertEquals("Wrong name", "x", variableBinding.getName()); > > // (PR 149590) >- // String key2 = variableBinding.getKey(); >- //assertFalse("Keys should not be equals", key2.equals(key)); >+ String key2 = variableBinding.getKey(); >+ assertFalse("Keys should not be equals", key2.equals(key)); > } finally { > if (workingCopy != null) > workingCopy.discardWorkingCopy(); >@@ -8480,7 +8477,6 @@ > > /** > * http://dev.eclipse.org/bugs/show_bug.cgi?id=144858 >- * TODO (frederic) check that keys are different (PR 149590) > */ > public void test0663() throws JavaModelException { > ICompilationUnit workingCopy = null; >@@ -8519,7 +8515,7 @@ > assertNotNull("No binding", variableBinding); > assertEquals("Wrong name", "i", variableBinding.getName()); > // (PR 149590) >- // String key = variableBinding.getKey(); >+ String key = variableBinding.getKey(); > > Block block = (Block) statement.getBody(); > List statements = block.statements(); >@@ -8540,8 +8536,8 @@ > assertEquals("Wrong name", "i", variableBinding.getName()); > > // (PR 149590) >- // String key2 = variableBinding.getKey(); >- //assertFalse("Keys should not be equals", key2.equals(key)); >+ String key2 = variableBinding.getKey(); >+ assertFalse("Keys should not be equals", key2.equals(key)); > } finally { > if (workingCopy != null) > workingCopy.discardWorkingCopy();
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 149590
:
71771
|
72870
|
72935