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 195691 Details for
Bug 345559
[1.7][compiler] Type inference for generic allocation can be avoided for invalid constructor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
proposed fix
patch345559.txt (text/plain), 4.43 KB, created by
Ayushman Jain
on 2011-05-16 03:02:18 EDT
(
hide
)
Description:
proposed fix
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-05-16 03:02:18 EDT
Size:
4.43 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java,v >retrieving revision 1.84.2.9 >diff -u -r1.84.2.9 AllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 11 May 2011 08:25:19 -0000 1.84.2.9 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 16 May 2011 06:58:13 -0000 >@@ -375,6 +375,11 @@ > } > if (isDiamond) { > TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope); >+ if (inferredTypes == null) { >+ // inference failed because no the number of arguments did not match the number in any constructor >+ this.resolvedType = null; >+ return null; >+ } > this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType()); > } > ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType; >@@ -413,6 +418,8 @@ > return ((ParameterizedTypeBinding)factory.returnType).arguments; > } > scope.problemReporter().cannotInferElidedTypes(this); >+ if (factory == null) >+ return null; > int arity = allocationType.typeVariables().length; > TypeBinding [] inferredTypes = new TypeBinding[arity]; > for (int i = 0; i < arity; i++) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java,v >retrieving revision 1.101.2.9 >diff -u -r1.101.2.9 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 12 May 2011 06:32:46 -0000 1.101.2.9 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 16 May 2011 06:58:14 -0000 >@@ -400,6 +400,11 @@ > } > if (isDiamond) { > TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope); >+ if (inferredTypes == null) { >+ // inference failed because no the number of arguments did not match the number in any constructor >+ this.resolvedType = null; >+ return null; >+ } > receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType()); > } > ReferenceBinding allocationType = (ReferenceBinding) receiverType; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v >retrieving revision 1.380.2.5 >diff -u -r1.380.2.5 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 10 May 2011 10:22:36 -0000 1.380.2.5 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 16 May 2011 06:58:20 -0000 >@@ -4036,7 +4036,11 @@ > int sfi = 0; > for (int i = 0, length = methods.length; i < length; i++) { > MethodBinding method = methods[i]; >- >+ int paramLength = method.parameters.length; >+ boolean isVarArgs = method.isVarargs(); >+ if (argumentTypes.length != paramLength) >+ if (!isVarArgs || argumentTypes.length < paramLength - 1) >+ continue; // this method has number of arguments different from that used in the allocation > TypeVariableBinding[] methodTypeVariables = method.typeVariables(); > int methodTypeVariablesArity = methodTypeVariables.length; > >@@ -4114,6 +4118,8 @@ > staticFactories[sfi++] = new ParameterizedMethodBinding((ParameterizedTypeBinding) environment.convertToParameterizedType(staticFactory.declaringClass), > staticFactory); > } >+ if (sfi == 0) >+ return null; // no possible static factory methods found. So bail out. > if (sfi != methods.length) { > System.arraycopy(staticFactories, 0, staticFactories = new MethodBinding[sfi], 0, sfi); > }
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 345559
:
195479
|
195691
|
195699
|
195879