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 195479 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]
experimental patch
patch345559.txt (text/plain), 6.89 KB, created by
Ayushman Jain
on 2011-05-12 05:42:33 EDT
(
hide
)
Description:
experimental patch
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-05-12 05:42:33 EDT
Size:
6.89 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 12 May 2011 09:41:59 -0000 >@@ -373,12 +373,20 @@ > scope.problemReporter().cannotInstantiate(this.type, this.resolvedType); > return this.resolvedType; > } >- if (isDiamond) { >- TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope); >- this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType()); >- } >+ >+// if (isDiamond) { >+// TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope); >+// this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType()); >+//// allocationType = (ReferenceBinding) this.resolvedType; >+// } >+ > ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType; >- if (!(this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { >+ if (isDiamond) { >+ this.binding = scope.getConstructor(((ParameterizedTypeBinding)allocationType).genericType(), argumentTypes, this); >+ } else { >+ this.binding = scope.getConstructor(allocationType, argumentTypes, this); >+ } >+ if (!this.binding.isValidBinding()) { > if (this.binding.declaringClass == null) { > this.binding.declaringClass = allocationType; > } >@@ -387,7 +395,11 @@ > } > scope.problemReporter().invalidConstructor(this, this.binding); > return this.resolvedType; >- } >+ } else if (isDiamond) { >+ TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) this.resolvedType).genericType(), argumentTypes, scope); >+ this.resolvedType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) this.resolvedType).genericType(), inferredTypes, ((ParameterizedTypeBinding) this.resolvedType).enclosingType()); >+ allocationType = (ReferenceBinding) this.resolvedType; >+ } > if ((this.binding.tagBits & TagBits.HasMissingType) != 0) { > scope.problemReporter().missingTypeInConstructor(this, this.binding); > } >@@ -399,7 +411,7 @@ > if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { > scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); > } >- return allocationType; >+ return this.resolvedType; > } > > public TypeBinding[] inferElidedTypes(ReferenceBinding allocationType, TypeBinding[] argumentTypes, final BlockScope scope) { >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.8 >diff -u -r1.101.2.8 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 11 May 2011 08:25:19 -0000 1.101.2.8 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 12 May 2011 09:41:59 -0000 >@@ -302,6 +302,7 @@ > } > > // resolve type arguments (for generic constructor call) >+ boolean isDiamond = this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0; > if (this.typeArguments != null) { > int length = this.typeArguments.length; > boolean argHasError = scope.compilerOptions().sourceLevel < ClassFileConstants.JDK1_5; >@@ -315,7 +316,7 @@ > scope.problemReporter().illegalUsageOfWildcard(typeReference); > } > } >- if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) { >+ if (isDiamond) { > scope.problemReporter().diamondNotWithExplicitTypeArguments(this.typeArguments); > return null; > } >@@ -390,12 +391,22 @@ > scope.problemReporter().cannotInstantiate(this.type, receiverType); > return this.resolvedType = receiverType; > } >- if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) { >- TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope); >- receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType()); >- } >+// if (isDiamond) { >+// TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope); >+// receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType()); >+// } > ReferenceBinding allocationType = (ReferenceBinding) receiverType; >+ if (isDiamond) { >+ this.binding = scope.getConstructor(((ParameterizedTypeBinding)allocationType).genericType(), argumentTypes, this); >+ } else { >+ this.binding = scope.getConstructor(allocationType, argumentTypes, this); >+ } > if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { >+ if (isDiamond) { >+ TypeBinding [] inferredTypes = inferElidedTypes(((ParameterizedTypeBinding) receiverType).genericType(), argumentTypes, scope); >+ receiverType = this.type.resolvedType = scope.environment().createParameterizedType(((ParameterizedTypeBinding) receiverType).genericType(), inferredTypes, ((ParameterizedTypeBinding) receiverType).enclosingType()); >+ allocationType = (ReferenceBinding) receiverType; >+ } > if (isMethodUseDeprecated(this.binding, scope, true)) { > scope.problemReporter().deprecatedMethod(this.binding, this); > } >@@ -430,7 +441,7 @@ > scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance, null); > return this.resolvedType = receiverType; > } else { >- if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) { >+ if (isDiamond) { > scope.problemReporter().diamondNotWithAnoymousClasses(this.type); > return null; > }
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