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 62086 Details for
Bug 179477
[compiler] problem in first element of array initializer suppresses further problems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch
179477.txt (text/plain), 6.98 KB, created by
Philipe Mulet
on 2007-03-27 09:38:06 EDT
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2007-03-27 09:38:06 EDT
Size:
6.98 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java,v >retrieving revision 1.46 >diff -u -r1.46 ArrayInitializer.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java 28 Oct 2006 04:11:27 -0000 1.46 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ArrayInitializer.java 27 Mar 2007 11:29:24 -0000 >@@ -155,29 +155,28 @@ > for (int i = 0, length = this.expressions.length; i < length; i++) { > Expression expression = this.expressions[i]; > expression.setExpectedType(elementType); >- TypeBinding exprType = expression instanceof ArrayInitializer >+ TypeBinding expressionType = expression instanceof ArrayInitializer > ? expression.resolveTypeExpecting(scope, elementType) > : expression.resolveType(scope); >- if (exprType == null) >- return null; >+ if (expressionType == null) >+ continue; > > // Compile-time conversion required? >- if (elementType != exprType) // must call before computeConversion() and typeMismatchError() >- scope.compilationUnitScope().recordTypeConversion(elementType, exprType); >+ if (elementType != expressionType) // must call before computeConversion() and typeMismatchError() >+ scope.compilationUnitScope().recordTypeConversion(elementType, expressionType); > >- if ((expression.isConstantValueOfTypeAssignableToType(exprType, elementType) >- || (elementType.isBaseType() && BaseTypeBinding.isWidening(elementType.id, exprType.id))) >- || exprType.isCompatibleWith(elementType)) { >- expression.computeConversion(scope, elementType, exprType); >- } else if (scope.isBoxingCompatibleWith(exprType, elementType) >- || (exprType.isBaseType() // narrowing then boxing ? >+ if ((expression.isConstantValueOfTypeAssignableToType(expressionType, elementType) >+ || (elementType.isBaseType() && BaseTypeBinding.isWidening(elementType.id, expressionType.id))) >+ || expressionType.isCompatibleWith(elementType)) { >+ expression.computeConversion(scope, elementType, expressionType); >+ } else if (scope.isBoxingCompatibleWith(expressionType, elementType) >+ || (expressionType.isBaseType() // narrowing then boxing ? > && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5 // autoboxing > && !elementType.isBaseType() >- && expression.isConstantValueOfTypeAssignableToType(exprType, scope.environment().computeBoxingType(elementType)))) { >- expression.computeConversion(scope, elementType, exprType); >+ && expression.isConstantValueOfTypeAssignableToType(expressionType, scope.environment().computeBoxingType(elementType)))) { >+ expression.computeConversion(scope, elementType, expressionType); > } else { >- scope.problemReporter().typeMismatchError(exprType, elementType, expression); >- return null; >+ scope.problemReporter().typeMismatchError(expressionType, elementType, expression); > } > } > return this.binding; >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java,v >retrieving revision 1.20 >diff -u -r1.20 ArrayTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java 23 Aug 2006 16:33:08 -0000 1.20 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java 27 Mar 2007 11:29:25 -0000 >@@ -357,22 +357,62 @@ > " [pc: 0, pc: 15] local: this index: 0 type: X\n" + > " [pc: 13, pc: 15] local: all index: 1 type: java.lang.Object[][]\n"; > >-try { >- File f = new File(OUTPUT_DIR + File.separator + "X.class"); >- byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >- ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); >- String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); >- int index = result.indexOf(expectedOutput); >- if (index == -1 || expectedOutput.length() == 0) { >- System.out.println(Util.displayString(result, 3)); >- } >- if (index == -1) { >- assertEquals("Wrong contents", expectedOutput, result); >- } >-} catch (org.eclipse.jdt.core.util.ClassFormatException e) { >- assertTrue(false); >-} catch (IOException e) { >- assertTrue(false); >-} >+ try { >+ File f = new File(OUTPUT_DIR + File.separator + "X.class"); >+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); >+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); >+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); >+ int index = result.indexOf(expectedOutput); >+ if (index == -1 || expectedOutput.length() == 0) { >+ System.out.println(Util.displayString(result, 3)); >+ } >+ if (index == -1) { >+ assertEquals("Wrong contents", expectedOutput, result); >+ } >+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) { >+ assertTrue(false); >+ } catch (IOException e) { >+ assertTrue(false); >+ } >+} >+//check resolution of faulty initializer >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=179477 >+public void test013() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " String[] m(String arg) {\n" + >+ " System.out.println(argument + argument);\n" + >+ " return new String[] { argument + argument, argument/*no problem*/ };\n" + >+ " }\n" + >+ "}", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " System.out.println(argument + argument);\n" + >+ " ^^^^^^^^\n" + >+ "argument cannot be resolved\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 3)\n" + >+ " System.out.println(argument + argument);\n" + >+ " ^^^^^^^^\n" + >+ "argument cannot be resolved\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 4)\n" + >+ " return new String[] { argument + argument, argument/*no problem*/ };\n" + >+ " ^^^^^^^^\n" + >+ "argument cannot be resolved\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 4)\n" + >+ " return new String[] { argument + argument, argument/*no problem*/ };\n" + >+ " ^^^^^^^^\n" + >+ "argument cannot be resolved\n" + >+ "----------\n" + >+ "5. ERROR in X.java (at line 4)\n" + >+ " return new String[] { argument + argument, argument/*no problem*/ };\n" + >+ " ^^^^^^^^\n" + >+ "argument cannot be resolved\n" + >+ "----------\n"); > } > }
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 179477
: 62086 |
62375