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 191947 Details for
Bug 339478
[1.7][compiler] support for diamond case
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]
Unreviewed remaining patch fragment
patch.txt (text/plain), 17.27 KB, created by
Srikanth Sankaran
on 2011-03-25 18:56:14 EDT
(
hide
)
Description:
Unreviewed remaining patch fragment
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2011-03-25 18:56:14 EDT
Size:
17.27 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.2 >diff -u -r1.84.2.2 AllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 5 Mar 2011 18:12:56 -0000 1.84.2.2 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 25 Mar 2011 22:55:19 -0000 >@@ -29,7 +29,8 @@ > public TypeReference[] typeArguments; > public TypeBinding[] genericTypeArguments; > public FieldDeclaration enumConstant; // for enum constant initializations >- >+ protected TypeBinding expectedType; >+ > public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { > // check captured variables are initialized in current context (26134) > checkCapturedLocalInitializationIfNecessary((ReferenceBinding)this.binding.declaringClass.erasure(), currentScope, flowInfo); >@@ -255,7 +256,12 @@ > // initialization of an enum constant > this.resolvedType = scope.enclosingReceiverType(); > } else { >- this.resolvedType = this.type.resolveType(scope, true /* check bounds*/); >+ TypeBinding inferredArguments[] = null; >+ if ((scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7) && (this.type.bits & ASTNode.IsDiamond) != 0) { >+ if (this.expectedType != null && this.expectedType.isParameterizedTypeWithActualArguments()) >+ inferredArguments = ((ParameterizedTypeBinding)this.expectedType).arguments; >+ } >+ this.resolvedType = this.type.resolveType(scope, true /* check bounds*/, inferredArguments); > checkParameterizedAllocation: { > if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>() > ReferenceBinding currentType = (ReferenceBinding)this.resolvedType; >@@ -409,4 +415,11 @@ > } > visitor.endVisit(this, scope); > } >+/** >+ * @see org.eclipse.jdt.internal.compiler.ast.Expression#setExpectedType(org.eclipse.jdt.internal.compiler.lookup.TypeBinding) >+ */ >+public void setExpectedType(TypeBinding expectedType) { >+ this.expectedType = expectedType; >+} >+ > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java,v >retrieving revision 1.102 >diff -u -r1.102 FieldDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 5 Jan 2011 19:57:26 -0000 1.102 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldDeclaration.java 25 Mar 2011 22:55:19 -0000 >@@ -214,11 +214,19 @@ > this.initialization.computeConversion(initializationScope, fieldType, initializationType); > } > } else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) { >- >+ boolean isDiamond = false; >+ if (this.initialization instanceof AllocationExpression) { >+ AllocationExpression allocationExpression = (AllocationExpression) this.initialization; >+ if (initializationScope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_7 >+ && allocationExpression.type != null >+ && (allocationExpression.type.bits & ASTNode.IsDiamond) != 0) { >+ isDiamond = true; >+ } >+ } > if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError() > initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType); > if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType) >- || initializationType.isCompatibleWith(fieldType)) { >+ || initializationType.isCompatibleWith(fieldType, isDiamond)) { > this.initialization.computeConversion(initializationScope, fieldType, initializationType); > if (initializationType.needsUncheckedConversion(fieldType)) { > initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java,v >retrieving revision 1.77.2.3 >diff -u -r1.77.2.3 LocalDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 8 Mar 2011 17:20:09 -0000 1.77.2.3 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/LocalDeclaration.java 25 Mar 2011 22:55:20 -0000 >@@ -157,7 +157,7 @@ > } > > public void resolve(BlockScope scope) { >- >+ boolean isCompliant17 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_7; > // create a binding and add it to the scope > TypeBinding variableType = this.type.resolveType(scope, true /* check bounds*/); > >@@ -207,12 +207,17 @@ > } > } else { > this.initialization.setExpectedType(variableType); >+ boolean isDiamond = false; > TypeBinding initializationType = this.initialization.resolveType(scope); >+ if (this.initialization instanceof AllocationExpression) { >+ if (isCompliant17 && (((AllocationExpression) this.initialization).type.bits & ASTNode.IsDiamond) != 0) >+ isDiamond = true; >+ } > if (initializationType != null) { > if (variableType != initializationType) // must call before computeConversion() and typeMismatchError() > scope.compilationUnitScope().recordTypeConversion(variableType, initializationType); > if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, variableType) >- || initializationType.isCompatibleWith(variableType)) { >+ || initializationType.isCompatibleWith(variableType, isDiamond)) { > this.initialization.computeConversion(scope, variableType, initializationType); > if (initializationType.needsUncheckedConversion(variableType)) { > scope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, variableType); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java,v >retrieving revision 1.63.2.2 >diff -u -r1.63.2.2 ParameterizedQualifiedTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 25 Mar 2011 13:12:28 -0000 1.63.2.2 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 25 Mar 2011 22:55:20 -0000 >@@ -27,6 +27,7 @@ > public class ParameterizedQualifiedTypeReference extends ArrayQualifiedTypeReference { > > public TypeReference[][] typeArguments; >+ public TypeBinding[] inferredTypeArgs; > > /** > * @param tokens >@@ -37,6 +38,7 @@ > > super(tokens, dim, positions); > this.typeArguments = typeArguments; >+ this.inferredTypeArgs = null; > } > public void checkBounds(Scope scope) { > if (this.resolvedType == null) return; >@@ -68,6 +70,8 @@ > * @return char[][] > */ > public char [][] getParameterizedTypeName(){ >+ if ((this.bits & ASTNode.IsDiamond) != 0) >+ return this.getTypeName(); > int length = this.tokens.length; > char[][] qParamName = new char[length][]; > for (int i = 0; i < length; i++) { >@@ -223,6 +227,9 @@ > argTypes[j] = argType; > } > } >+ if (argLength == 0 && (this.bits & ASTNode.IsDiamond) != 0 && this.inferredTypeArgs != null) { >+ argTypes = this.inferredTypeArgs; >+ } > if (argHasError) { > return null; > } >@@ -344,7 +351,11 @@ > } > return output; > } >- >+ >+ public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding[] inferredArgs) { >+ this.inferredTypeArgs = inferredArgs; >+ return internalResolveType(scope, checkBounds); >+ } > public TypeBinding resolveType(BlockScope scope, boolean checkBounds) { > return internalResolveType(scope, checkBounds); > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java,v >retrieving revision 1.54.2.2 >diff -u -r1.54.2.2 ParameterizedSingleTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 25 Mar 2011 13:12:28 -0000 1.54.2.2 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 25 Mar 2011 22:55:21 -0000 >@@ -27,11 +27,13 @@ > public class ParameterizedSingleTypeReference extends ArrayTypeReference { > > public TypeReference[] typeArguments; >+ public TypeBinding[] inferredTypeArgs; > > public ParameterizedSingleTypeReference(char[] name, TypeReference[] typeArguments, int dim, long pos){ > super(name, dim, pos); > this.originalSourceEnd = this.sourceEnd; > this.typeArguments = typeArguments; >+ this.inferredTypeArgs = null; > } > public void checkBounds(Scope scope) { > if (this.resolvedType == null) return; >@@ -57,6 +59,8 @@ > * @return char[][] > */ > public char [][] getParameterizedTypeName(){ >+ if ((this.bits & ASTNode.IsDiamond) != 0) >+ return this.getTypeName(); > StringBuffer buffer = new StringBuffer(5); > buffer.append(this.token).append('<'); > for (int i = 0, length = this.typeArguments.length; i < length; i++) { >@@ -188,6 +192,9 @@ > argTypes[i] = argType; > } > } >+ if (argLength == 0 && (this.bits & ASTNode.IsDiamond) != 0 && this.inferredTypeArgs != null) { >+ argTypes = this.inferredTypeArgs; >+ } > if (argHasError) { > return null; > } >@@ -281,6 +288,11 @@ > return output; > } > >+ public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding[] inferredArgs) { >+ this.inferredTypeArgs = inferredArgs; >+ return internalResolveType(scope, null, checkBounds); >+ } >+ > public TypeBinding resolveType(BlockScope scope, boolean checkBounds) { > return internalResolveType(scope, null, checkBounds); > } >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.1 >diff -u -r1.101.2.1 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 5 Mar 2011 18:12:56 -0000 1.101.2.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 25 Mar 2011 22:55:21 -0000 >@@ -498,4 +498,13 @@ > } > visitor.endVisit(this, scope); > } >+ >+ /** >+ * @see org.eclipse.jdt.internal.compiler.ast.Expression#setExpectedType(org.eclipse.jdt.internal.compiler.lookup.TypeBinding) >+ */ >+ public void setExpectedType(TypeBinding expectedType) { >+ this.expectedType = expectedType; >+ if (this.expectedType != null && this.enclosingInstance != null) >+ this.enclosingInstance.setExpectedType(this.expectedType.enclosingType()); >+ } > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java,v >retrieving revision 1.44.4.1 >diff -u -r1.44.4.1 TypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java 25 Jan 2011 20:33:00 -0000 1.44.4.1 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TypeReference.java 25 Mar 2011 22:55:23 -0000 >@@ -208,6 +208,10 @@ > return internalResolveType(scope); > } > >+public TypeBinding resolveType(BlockScope scope, boolean checkBounds, TypeBinding[] inferredArgs) { >+ return internalResolveType(scope); >+} >+ > public TypeBinding resolveType(ClassScope scope) { > return internalResolveType(scope); > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java,v >retrieving revision 1.120 >diff -u -r1.120 ParameterizedTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 23 Dec 2010 13:57:49 -0000 1.120 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 25 Mar 2011 22:55:26 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2010 IBM Corporation and others. >+ * Copyright (c) 2005, 2011 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 >@@ -31,6 +31,7 @@ > public ReferenceBinding[] memberTypes; > public MethodBinding[] methods; > private ReferenceBinding enclosingType; >+ private TypeBinding[] expectedArgumentTypes; > > public ParameterizedTypeBinding(ReferenceBinding type, TypeBinding[] arguments, ReferenceBinding enclosingType, LookupEnvironment environment){ > this.environment = environment; >@@ -451,7 +452,7 @@ > public MethodBinding getExactConstructor(TypeBinding[] argumentTypes) { > int argCount = argumentTypes.length; > MethodBinding match = null; >- >+ this.expectedArgumentTypes = argumentTypes; > if ((this.tagBits & TagBits.AreMethodsComplete) != 0) { // have resolved all arg types & return type of the methods > long range; > if ((range = ReferenceBinding.binarySearch(TypeConstants.INIT, this.methods)) >= 0) { >@@ -955,6 +956,13 @@ > // lazy init, since cannot do so during binding creation if during supertype connection > if (currentType.arguments == null) > currentType.initializeArguments(); // only for raw types >+ else if (currentType.arguments.length == 0) { // diamond case >+ // this.expectedArgumentTypes should have the argument list >+ if (currentType.expectedArgumentTypes != null && currentType.expectedArgumentTypes.length != 0) { >+ return currentType.expectedArgumentTypes[originalVariable.rank]; >+ } >+ return originalVariable; >+ } > if (currentType.arguments != null) > return currentType.arguments[originalVariable.rank]; > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java,v >retrieving revision 1.140.2.4 >diff -u -r1.140.2.4 ReferenceBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 14 Feb 2011 06:33:10 -0000 1.140.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ReferenceBinding.java 25 Mar 2011 22:55:30 -0000 >@@ -1005,6 +1005,18 @@ > * In addition to improving performance, caching also ensures there is no infinite regression > * since per nature, the compatibility check is recursive through parameterized type arguments (122775) > */ >+public boolean isCompatibleWith(TypeBinding otherType, boolean isDiamondCase) { >+ if (isDiamondCase) { >+ if (this.erasure() == otherType.erasure()) >+ return true; >+ } >+ return isCompatibleWith(otherType); >+} >+/** >+ * Answer true if the receiver type can be assigned to the argument type (right) >+ * In addition to improving performance, caching also ensures there is no infinite regression >+ * since per nature, the compatibility check is recursive through parameterized type arguments (122775) >+ */ > public boolean isCompatibleWith(TypeBinding otherType) { > if (otherType == this) > return true; >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java,v >retrieving revision 1.113 >diff -u -r1.113 TypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 24 Nov 2010 04:51:11 -0000 1.113 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java 25 Mar 2011 22:55:31 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 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 >@@ -1183,4 +1183,8 @@ > public TypeVariableBinding[] typeVariables() { > return Binding.NO_TYPE_VARIABLES; > } >+ >+public boolean isCompatibleWith(TypeBinding variableType, boolean isDiamond){ >+ return isCompatibleWith(variableType); >+} > }
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 339478
:
190845
|
191332
|
191458
|
191707
|
191785
|
191891
|
191902
|
191946
|
191947
|
191984
|
192058
|
193887
|
193901
|
193918
|
193951
|
193962
|
193963