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 193963 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]
Revised Implementation with tests v1.0
patchwithtests.txt (text/plain), 37.16 KB, created by
Srikanth Sankaran
on 2011-04-24 03:57:46 EDT
(
hide
)
Description:
Revised Implementation with tests v1.0
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2011-04-24 03:57:46 EDT
Size:
37.16 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/core/compiler/IProblem.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java,v >retrieving revision 1.225.2.13 >diff -u -r1.225.2.13 IProblem.java >--- compiler/org/eclipse/jdt/core/compiler/IProblem.java 21 Apr 2011 06:09:53 -0000 1.225.2.13 >+++ compiler/org/eclipse/jdt/core/compiler/IProblem.java 24 Apr 2011 07:54:04 -0000 >@@ -1379,6 +1379,8 @@ > int PolymorphicMethodNotBelow17 = MethodRelated + 876; > /** @since 3.7 */ > int IncorrectSwitchType17 = TypeRelated + 877; >+ /** @since 3.7 */ >+ int CannotInferElidedTypes = TypeRelated + 878; > > /** > * External problems -- These are problems defined by other plugins >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.6 >diff -u -r1.84.2.6 AllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 23 Apr 2011 07:21:32 -0000 1.84.2.6 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 24 Apr 2011 07:54:05 -0000 >@@ -17,6 +17,7 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >+import org.eclipse.jdt.core.compiler.CharOperation; > import org.eclipse.jdt.internal.compiler.ASTVisitor; > import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; > import org.eclipse.jdt.internal.compiler.codegen.*; >@@ -33,6 +34,7 @@ > public TypeReference[] typeArguments; > public TypeBinding[] genericTypeArguments; > public FieldDeclaration enumConstant; // for enum constant initializations >+ protected TypeBinding typeExpected; // for <> inference > > public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { > // check captured variables are initialized in current context (26134) >@@ -359,6 +361,10 @@ > scope.problemReporter().cannotInstantiate(this.type, this.resolvedType); > return this.resolvedType; > } >+ if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) { >+ 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()); >+ } > ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType; > if (!(this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { > if (this.binding.declaringClass == null) { >@@ -384,6 +390,25 @@ > return allocationType; > } > >+public TypeBinding[] inferElidedTypes(ReferenceBinding allocationType, TypeBinding[] argumentTypes, final BlockScope scope) { >+ /* Given the allocation type and the arguments to the constructor, see if we can synthesize a generic static factory >+ method that would, given the argument types and the invocation site, manufacture a parameterized object of type allocationType. >+ If we are successful then by design and construction, the parameterization of the return type of the factory method is identical >+ to the types elided in the <>. >+ */ >+ MethodBinding factory = scope.getStaticFactory(allocationType, argumentTypes, this); >+ if (factory instanceof ParameterizedGenericMethodBinding && factory.isValidBinding()) { >+ return ((ParameterizedTypeBinding)factory.returnType).arguments; >+ } >+ scope.problemReporter().cannotInferElidedTypes(this); >+ int arity = allocationType.typeVariables().length; >+ TypeBinding [] inferredTypes = new TypeBinding[arity]; >+ for (int i = 0; i < arity; i++) { >+ inferredTypes[i] = new ProblemReferenceBinding(CharOperation.NO_CHAR_CHAR, null, ProblemReasons.InferenceFailed); >+ } >+ return inferredTypes; >+} >+ > public void setActualReceiverType(ReferenceBinding receiverType) { > // ignored > } >@@ -413,4 +438,17 @@ > } > 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.typeExpected = expectedType; >+} >+/** >+ * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#expectedType() >+ */ >+public TypeBinding expectedType() { >+ return this.typeExpected; >+} >+ > } >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.6 >diff -u -r1.63.2.6 ParameterizedQualifiedTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 19 Apr 2011 21:36:37 -0000 1.63.2.6 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 24 Apr 2011 07:54:05 -0000 >@@ -253,7 +253,6 @@ > scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes, i); > return null; > } >- checkBounds = false; // successful <> inference needs no bounds check, we will scream foul if needed during inference. > } > // check parameterizing non-static member type of raw type > if (typeIsConsistent && !currentType.isStatic()) { >@@ -265,11 +264,13 @@ > } > } > ParameterizedTypeBinding parameterizedType = scope.environment().createParameterizedType(currentOriginal, argTypes, qualifyingType); >- // check argument type compatibility >- if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution >- parameterizedType.boundCheck(scope, args); >- else >- scope.deferBoundCheck(this); >+ // check argument type compatibility for non <> cases - <> case needs no bounds check, we will scream foul if needed during inference. >+ if (!isDiamond) { >+ if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution >+ parameterizedType.boundCheck(scope, args); >+ else >+ scope.deferBoundCheck(this); >+ } > qualifyingType = parameterizedType; > } else { > ReferenceBinding currentOriginal = (ReferenceBinding)currentType.original(); >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.6 >diff -u -r1.54.2.6 ParameterizedSingleTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 19 Apr 2011 21:36:37 -0000 1.54.2.6 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 24 Apr 2011 07:54:05 -0000 >@@ -209,6 +209,7 @@ > return null; > } > >+ final boolean isDiamond = (this.bits & ASTNode.IsDiamond) != 0; > TypeVariableBinding[] typeVariables = currentOriginal.typeVariables(); > if (typeVariables == Binding.NO_TYPE_VARIABLES) { // non generic invoked with arguments > boolean isCompliant15 = scope.compilerOptions().originalSourceLevel >= ClassFileConstants.JDK1_5; >@@ -227,11 +228,10 @@ > } > // if missing generic type, and compliance >= 1.5, then will rebuild a parameterized binding > } else if (argLength != typeVariables.length) { >- if ((this.bits & ASTNode.IsDiamond) == 0) { // check arity, IsDiamond never set for 1.6- >+ if (!isDiamond) { // check arity, IsDiamond never set for 1.6- > scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes); > return null; > } >- checkBounds = false; // successful <> inference needs no bounds check, we will scream foul if needed during inference. > } else if (!currentType.isStatic()) { > ReferenceBinding actualEnclosing = currentType.enclosingType(); > if (actualEnclosing != null && actualEnclosing.isRawType()){ >@@ -242,11 +242,13 @@ > } > > ParameterizedTypeBinding parameterizedType = scope.environment().createParameterizedType(currentOriginal, argTypes, enclosingType); >- // check argument type compatibility >- if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution >- parameterizedType.boundCheck(scope, this.typeArguments); >- else >- scope.deferBoundCheck(this); >+ // check argument type compatibility for non <> cases - <> case needs no bounds check, we will scream foul if needed during inference. >+ if (!isDiamond) { >+ if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution >+ parameterizedType.boundCheck(scope, this.typeArguments); >+ else >+ scope.deferBoundCheck(this); >+ } > if (isTypeUseDeprecated(parameterizedType, scope)) > reportDeprecatedType(parameterizedType, 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.5 >diff -u -r1.101.2.5 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 23 Apr 2011 07:21:32 -0000 1.101.2.5 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 24 Apr 2011 07:54:05 -0000 >@@ -27,6 +27,7 @@ > import org.eclipse.jdt.internal.compiler.lookup.ExtraCompilerModifiers; > import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; >+import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; > import org.eclipse.jdt.internal.compiler.lookup.ProblemMethodBinding; > import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; > import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; >@@ -385,6 +386,10 @@ > 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()); >+ } > ReferenceBinding allocationType = (ReferenceBinding) receiverType; > if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { > if (isMethodUseDeprecated(this.binding, scope, true)) { >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java,v >retrieving revision 1.14.28.1 >diff -u -r1.14.28.1 ProblemReasons.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java 2 Mar 2011 11:56:58 -0000 1.14.28.1 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ProblemReasons.java 24 Apr 2011 07:54:07 -0000 >@@ -31,4 +31,5 @@ > final int TypeArgumentsForRawGenericMethod = 13; // for generic method > final int InvalidTypeForStaticImport = 14; > final int InvalidTypeForAutoManagedResource = 15; >+ final int InferenceFailed = 16; > } >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.3 >diff -u -r1.380.2.3 Scope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 15 Feb 2011 05:43:47 -0000 1.380.2.3 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 24 Apr 2011 07:54:12 -0000 >@@ -25,6 +25,7 @@ > import org.eclipse.jdt.internal.compiler.problem.ProblemReporter; > import org.eclipse.jdt.internal.compiler.util.HashtableOfObject; > import org.eclipse.jdt.internal.compiler.util.ObjectVector; >+import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; > import org.eclipse.jdt.internal.compiler.util.SimpleSet; > > public abstract class Scope { >@@ -4023,4 +4024,137 @@ > int startIndex() { > return 0; > } >+ /* Given an allocation type and arguments at the allocation site, answer a synthetic generic static factory method >+ that could instead be invoked with identical results. Return null if no compatible, visible, most specific method >+ could be found. This method is modeled after Scope.getConstructor and Scope.getMethod. >+ */ >+ public MethodBinding getStaticFactory (ReferenceBinding allocationType, TypeBinding[] argumentTypes, final InvocationSite allocationSite) { >+ TypeVariableBinding[] classTypeVariables = allocationType.typeVariables(); >+ int classTypeVariablesArity = classTypeVariables.length; >+ MethodBinding[] methods = allocationType.getMethods(TypeConstants.INIT, argumentTypes.length); >+ MethodBinding [] staticFactories = new MethodBinding[methods.length]; >+ int sfi = 0; >+ for (int i = 0, length = methods.length; i < length; i++) { >+ MethodBinding method = methods[i]; >+ >+ TypeVariableBinding[] methodTypeVariables = method.typeVariables(); >+ int methodTypeVariablesArity = methodTypeVariables.length; >+ >+ final TypeBinding[] genericTypeArguments = allocationSite.genericTypeArguments(); >+ if (genericTypeArguments != null && genericTypeArguments.length < methodTypeVariablesArity) >+ continue; // wrong tree, don't bark. >+ MethodBinding staticFactory = new MethodBinding(method.modifiers | ClassFileConstants.AccStatic, TypeConstants.SYNTHETIC_STATIC_FACTORY, >+ null, null, null, method.declaringClass); >+ staticFactory.typeVariables = new TypeVariableBinding[classTypeVariablesArity + (genericTypeArguments == null ? methodTypeVariablesArity : 0)]; >+ final SimpleLookupTable map = new SimpleLookupTable(classTypeVariablesArity + methodTypeVariablesArity); >+ // Rename each type variable T of the type to T' >+ final LookupEnvironment environment = environment(); >+ for (int j = 0; j < classTypeVariablesArity; j++) { >+ map.put(classTypeVariables[j], staticFactory.typeVariables[j] = new TypeVariableBinding(CharOperation.concat(classTypeVariables[j].sourceName, "'".toCharArray()), //$NON-NLS-1$ >+ staticFactory, j, environment)); >+ } >+ // Rename each type variable U of method U to U'' if not explicitly parameterized. Otherwise use the parameterizing type. >+ for (int j = classTypeVariablesArity, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) { >+ map.put(methodTypeVariables[j - classTypeVariablesArity], >+ genericTypeArguments != null ? genericTypeArguments[j - classTypeVariablesArity] : >+ (staticFactory.typeVariables[j] = new TypeVariableBinding(CharOperation.concat(methodTypeVariables[j - classTypeVariablesArity].sourceName, "''".toCharArray()), //$NON-NLS-1$ >+ staticFactory, j, environment))); >+ } >+ final Scope scope = this; >+ Substitution substitution = new Substitution() { >+ public LookupEnvironment environment() { >+ return scope.environment(); >+ } >+ public boolean isRawSubstitution() { >+ return false; >+ } >+ public TypeBinding substitute(TypeVariableBinding typeVariable) { >+ return (TypeBinding) map.get(typeVariable); >+ } >+ }; >+ >+ // initialize new variable bounds >+ for (int j = 0, max = classTypeVariablesArity + methodTypeVariablesArity; j < max; j++) { >+ TypeVariableBinding originalVariable = j < classTypeVariablesArity ? classTypeVariables[j] : methodTypeVariables[j - classTypeVariablesArity]; >+ TypeBinding substitutedType = (TypeBinding) map.get(originalVariable); >+ if (substitutedType instanceof TypeVariableBinding) { >+ TypeVariableBinding substitutedVariable = (TypeVariableBinding) substitutedType; >+ TypeBinding substitutedSuperclass = Scope.substitute(substitution, originalVariable.superclass); >+ ReferenceBinding[] substitutedInterfaces = Scope.substitute(substitution, originalVariable.superInterfaces); >+ if (originalVariable.firstBound != null) { >+ substitutedVariable.firstBound = originalVariable.firstBound == originalVariable.superclass >+ ? substitutedSuperclass // could be array type or interface >+ : substitutedInterfaces[0]; >+ } >+ switch (substitutedSuperclass.kind()) { >+ case Binding.ARRAY_TYPE : >+ substitutedVariable.superclass = environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null); >+ substitutedVariable.superInterfaces = substitutedInterfaces; >+ break; >+ default: >+ if (substitutedSuperclass.isInterface()) { >+ substitutedVariable.superclass = environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null); >+ int interfaceCount = substitutedInterfaces.length; >+ System.arraycopy(substitutedInterfaces, 0, substitutedInterfaces = new ReferenceBinding[interfaceCount+1], 1, interfaceCount); >+ substitutedInterfaces[0] = (ReferenceBinding) substitutedSuperclass; >+ substitutedVariable.superInterfaces = substitutedInterfaces; >+ } else { >+ substitutedVariable.superclass = (ReferenceBinding) substitutedSuperclass; // typeVar was extending other typeVar which got substituted with interface >+ substitutedVariable.superInterfaces = substitutedInterfaces; >+ } >+ } >+ } >+ } >+ TypeVariableBinding[] returnTypeParameters = new TypeVariableBinding[classTypeVariablesArity]; >+ for (int j = 0; j < classTypeVariablesArity; j++) { >+ returnTypeParameters[j] = (TypeVariableBinding) map.get(classTypeVariables[j]); >+ } >+ staticFactory.returnType = environment.createParameterizedType(allocationType, returnTypeParameters, allocationType.enclosingType()); >+ staticFactory.parameters = Scope.substitute(substitution, method.parameters); >+ staticFactory.thrownExceptions = Scope.substitute(substitution, method.thrownExceptions); >+ if (staticFactory.thrownExceptions == null) { >+ staticFactory.thrownExceptions = Binding.NO_EXCEPTIONS; >+ } >+ staticFactories[sfi++] = new ParameterizedMethodBinding((ParameterizedTypeBinding) environment.convertToParameterizedType(staticFactory.declaringClass), >+ staticFactory); >+ } >+ if (sfi != methods.length) { >+ System.arraycopy(staticFactories, 0, staticFactories = new MethodBinding[sfi], 0, sfi); >+ } >+ InvocationSite site = new InvocationSite() { // Alternate site to not expose the generic type arguments as they have already been substituted. >+ public int sourceStart() { return allocationSite.sourceStart(); } >+ public int sourceEnd() { return allocationSite.sourceEnd(); } >+ public void setFieldIndex(int depth) { allocationSite.setFieldIndex(depth); } >+ public void setDepth(int depth) { allocationSite.setDepth(depth);} >+ public void setActualReceiverType(ReferenceBinding receiverType) { allocationSite.setActualReceiverType(receiverType);} >+ public boolean isTypeAccess() { return allocationSite.isTypeAccess(); } >+ public boolean isSuperAccess() { return allocationSite.isSuperAccess(); } >+ public TypeBinding[] genericTypeArguments() { return null; } >+ public TypeBinding expectedType() { return allocationSite.expectedType(); } >+ }; >+ MethodBinding[] compatible = new MethodBinding[sfi]; >+ int compatibleIndex = 0; >+ for (int i = 0; i < sfi; i++) { >+ MethodBinding compatibleMethod = computeCompatibleMethod(staticFactories[i], argumentTypes, site); >+ if (compatibleMethod != null) { >+ if (compatibleMethod.isValidBinding()) >+ compatible[compatibleIndex++] = compatibleMethod; >+ } >+ } >+ >+ if (compatibleIndex == 0) { >+ return null; >+ } >+ MethodBinding[] visible = new MethodBinding[compatibleIndex]; >+ int visibleIndex = 0; >+ for (int i = 0; i < compatibleIndex; i++) { >+ MethodBinding method = compatible[i]; >+ if (method.canBeSeenBy(allocationSite, this)) >+ visible[visibleIndex++] = method; >+ } >+ if (visibleIndex == 0) { >+ return null; >+ } >+ return visibleIndex == 1 ? visible[0] : mostSpecificMethodBinding(visible, visibleIndex, argumentTypes, allocationSite, allocationType); >+ } > } >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java,v >retrieving revision 1.51.2.4 >diff -u -r1.51.2.4 TypeConstants.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 19 Apr 2011 13:09:09 -0000 1.51.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java 24 Apr 2011 07:54:13 -0000 >@@ -170,6 +170,7 @@ > char[] SYNTHETIC_ENCLOSING_INSTANCE_PREFIX = "this$".toCharArray(); //$NON-NLS-1$ > char[] SYNTHETIC_ACCESS_METHOD_PREFIX = "access$".toCharArray(); //$NON-NLS-1$ > char[] SYNTHETIC_ENUM_CONSTANT_INITIALIZATION_METHOD_PREFIX = " enum constant initialization$".toCharArray(); //$NON-NLS-1$ >+ char[] SYNTHETIC_STATIC_FACTORY = "<factory>".toCharArray(); //$NON-NLS-1$ > > // synthetic package-info name > public static final char[] PACKAGE_INFO_NAME = "package-info".toCharArray(); //$NON-NLS-1$ >Index: compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java,v >retrieving revision 1.430.2.19 >diff -u -r1.430.2.19 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 21 Apr 2011 06:09:56 -0000 1.430.2.19 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 24 Apr 2011 07:54:20 -0000 >@@ -7748,4 +7748,12 @@ > resources[0].declarationSourceStart, > resources[resources.length - 1].declarationSourceEnd); > } >+public void cannotInferElidedTypes(AllocationExpression allocationExpression) { >+ this.handle( >+ IProblem.CannotInferElidedTypes, >+ NoArgument, >+ NoArgument, >+ allocationExpression.sourceStart, >+ allocationExpression.sourceEnd); >+} > } >\ No newline at end of file >Index: compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties,v >retrieving revision 1.262.2.15 >diff -u -r1.262.2.15 messages.properties >--- compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 21 Apr 2011 06:09:56 -0000 1.262.2.15 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties 24 Apr 2011 07:54:21 -0000 >@@ -639,6 +639,7 @@ > 875 = Multi-catch parameters are not allowed for source level below 1.7 > 876 = Invocation of polymorphic methods not allowed for source level below 1.7 > 877 = Cannot switch on a value of type {0}. Only convertible int values, strings or enum constants are permitted >+878 = Cannot infer elided type(s) > > ### ELABORATIONS > ## Access restrictions >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java,v >retrieving revision 1.40.2.9 >diff -u -r1.40.2.9 CompilerInvocationTests.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 21 Apr 2011 06:09:47 -0000 1.40.2.9 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java 24 Apr 2011 07:54:30 -0000 >@@ -382,6 +382,7 @@ > expectedProblemAttributes.put("CannotExtendEnum", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("CannotHideAnInstanceMethodWithAStaticMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("CannotImportPackage", new ProblemAttributes(CategorizedProblem.CAT_IMPORT)); >+ expectedProblemAttributes.put("CannotInferElidedTypes", new ProblemAttributes(CategorizedProblem.CAT_TYPE)); > expectedProblemAttributes.put("CannotInvokeSuperConstructorInEnum", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("CannotOverrideAStaticMethodWithAnInstanceMethod", new ProblemAttributes(CategorizedProblem.CAT_MEMBER)); > expectedProblemAttributes.put("CannotReadSource", new ProblemAttributes(CategorizedProblem.CAT_INTERNAL)); >@@ -1041,6 +1042,7 @@ > expectedProblemAttributes.put("CannotExtendEnum", SKIP); > expectedProblemAttributes.put("CannotHideAnInstanceMethodWithAStaticMethod", SKIP); > expectedProblemAttributes.put("CannotImportPackage", SKIP); >+ expectedProblemAttributes.put("CannotInferElidedTypes", SKIP); > expectedProblemAttributes.put("CannotInvokeSuperConstructorInEnum", SKIP); > expectedProblemAttributes.put("CannotOverrideAStaticMethodWithAnInstanceMethod", SKIP); > expectedProblemAttributes.put("CannotReadSource", SKIP); >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/Attic/GenericsRegressionTest_1_7.java,v >retrieving revision 1.1.2.6 >diff -u -r1.1.2.6 GenericsRegressionTest_1_7.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java 19 Apr 2011 12:10:01 -0000 1.1.2.6 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericsRegressionTest_1_7.java 24 Apr 2011 07:54:30 -0000 >@@ -28,7 +28,7 @@ > public static Test suite() { > return buildMinimalComplianceTestSuite(testClass(), F_1_7); > } >-public void _test001() { >+public void test001() { > this.runConformTest( > new String[] { > "X.java", >@@ -44,7 +44,7 @@ > }, > "SUCCESS"); > } >-public void _test001a() { >+public void test001a() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -65,7 +65,7 @@ > "The method testFunction(String) in the type X<String> is not applicable for the arguments (int)\n" + > "----------\n"); > } >-public void _test001b() { >+public void test001b() { > this.runConformTest( > new String[] { > "X.java", >@@ -80,7 +80,7 @@ > "SUCCESS"); > } > // fields >-public void _test001b_1() { >+public void test001b_1() { > this.runConformTest( > new String[] { > "X.java", >@@ -94,7 +94,7 @@ > }, > "SUCCESS"); > } >-public void _test001c() { >+public void test001c() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -114,7 +114,7 @@ > "----------\n"); > } > // fields >-public void _test001c_1() { >+public void test001c_1() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -133,7 +133,7 @@ > "The method add(int, String) in the type ArrayList<String> is not applicable for the arguments (int)\n" + > "----------\n"); > } >-public void _test001d() { >+public void test001d() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -155,7 +155,7 @@ > "The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Object>)\n" + > "----------\n"); > } >-public void _test001e() { >+public void test001e() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -177,8 +177,8 @@ > "The method ab(ArrayList<String>) in the type X<String> is not applicable for the arguments (ArrayList<Object>)\n" + > "----------\n"); > } >-public void _test001f() { >- this.runConformTest( >+public void test001f() { >+ this.runNegativeTest( > new String[] { > "X.java", > "public class X<T> {\n" + >@@ -193,7 +193,17 @@ > " }\n" + > "}", > }, >- "SUCCESS"); >+ "----------\n" + >+ "1. WARNING in X.java (at line 2)\n" + >+ " class X2<T>{\n" + >+ " ^\n" + >+ "The type parameter T is hiding the type T\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " X<String>.X2<String> x = new X<>().new X2<>();\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from X<Object>.X2<String> to X<String>.X2<String>\n" + >+ "----------\n"); > } > // fields > public void test001f_1() { >@@ -216,8 +226,8 @@ > }, > "SUCCESS"); > } >-public void _test001g() { >- this.runConformTest( >+public void test001g() { >+ this.runNegativeTest( > new String[] { > "X.java", > "public class X<T> {\n" + >@@ -233,7 +243,12 @@ > " }\n" + > "}", > }, >- "SUCCESS\n1"); >+ "----------\n" + >+ "1. ERROR in X.java (at line 9)\n" + >+ " X<String>.X2<Integer> x = new X<>().new X2<>();\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from X<Object>.X2<Integer> to X<String>.X2<Integer>\n" + >+ "----------\n"); > } > public void test001g_1() { > this.runConformTest( >@@ -256,7 +271,7 @@ > }, > "SUCCESS\n1"); > } >-public void _test001h() { >+public void test001h() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -278,13 +293,18 @@ > " ^\n" + > "The type parameter T is hiding the type T\n" + > "----------\n" + >- "2. ERROR in X.java (at line 9)\n" + >+ "2. ERROR in X.java (at line 8)\n" + >+ " X<String>.X2<String> x = new X<>().new X2<>();\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from X<Object>.X2<String> to X<String>.X2<String>\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 9)\n" + > " x.methodx(1);\n" + > " ^^^^^^^\n" + > "The method methodx(String) in the type X<String>.X2<String> is not applicable for the arguments (int)\n" + > "----------\n"); > } >-public void _test001h_1() { >+public void test001h_1() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -329,11 +349,31 @@ > "Type safety: The method methodx(Object) belongs to the raw type X.X2. References to generic type X<T>.X2<T> should be parameterized\n" + > "----------\n"); > } >-public void _test001i() { >+public void test001h_2() { > this.runConformTest( > new String[] { > "X.java", > "public class X<T> {\n" + >+ " class X2<T>{\n" + >+ " void methodx(T param){\n" + >+ " System.out.println(param);\n" + >+ " }\n" + >+ " }\n" + >+ " X<String>.X2<String> x;\n" + >+ " public static void main(String[] args) {\n" + >+ " X test = new X();\n" + >+ " test.x = new X<>().new X2<>();\n" + >+ " test.x.methodx(1);\n" + >+ " }\n" + >+ "}", >+ }, >+ "1"); >+} >+public void test001i() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X<T> {\n" + > " class X2<K>{\n" + > " class X22<I>{\n" + > " void methodx(T param, K param2, I param3){\n" + >@@ -348,7 +388,12 @@ > " }\n" + > "}", > }, >- "SUCCESS"); >+ "----------\n" + >+ "1. ERROR in X.java (at line 10)\n" + >+ " X<String> test = new X<>(); X<String>.X2<Integer>.X22<X<String>> x = new X<>().new X2<>().new X22<>();\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from X<Object>.X2<Object>.X22<X<String>> to X<String>.X2<Integer>.X22<X<String>>\n" + >+ "----------\n"); > } > public void test002() { > this.runNegativeTest( >@@ -376,7 +421,7 @@ > "Type safety: The method testFunction(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + > "----------\n"); > } >-public void _test003() { >+public void test003() { > this.runConformTest( > new String[] { > "X.java", >@@ -392,7 +437,7 @@ > "SUCCESS"); > } > >-public void _test004b() { >+public void test004b() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -437,7 +482,7 @@ > "1"); > } > >-public void _test006() { >+public void test006() { > this.runConformTest( > new String[] { > "X.java", >@@ -460,7 +505,7 @@ > "SUCCESS"); > } > // shows the difference between using <> and the raw type - different semantics >-public void _test007() { >+public void test007() { > this.runConformTest( > new String[] { > "X.java", >@@ -487,7 +532,7 @@ > "1\n" + > "2"); > } >-public void _test007a() { >+public void test007a() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -529,12 +574,12 @@ > "----------\n"); > } > //shows the difference between using <> and the raw type - different semantics >-public void _test008() { >- this.runConformTest( >+public void test008() { >+ this.runNegativeTest( > new String[] { > "X.java", > "public class X<T> {\n" + >- " T field1;" + >+ " T field1;\n" + > " public X(T param){\n" + > " field1 = param;\n" + > " }\n" + >@@ -547,10 +592,30 @@ > " }\n" + > "}", > }, >- ""); >+ "----------\n" + >+ "1. WARNING in X.java (at line 7)\n" + >+ " X<?> x1 = new X(1).get(\"\");\n" + >+ " ^^^^^^^^\n" + >+ "Type safety: The constructor X(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " X<?> x1 = new X(1).get(\"\");\n" + >+ " ^^^^^^^^^^^^^^^^\n" + >+ "Type safety: The method get(Object) belongs to the raw type X. References to generic type X<T> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 7)\n" + >+ " X<?> x1 = new X(1).get(\"\");\n" + >+ " ^\n" + >+ "X is a raw type. References to generic type X<T> should be parameterized\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 8)\n" + >+ " X<?> x2 = new X<>(1).get(\"\");\n" + >+ " ^^^\n" + >+ "The method get(Integer) in the type X<Integer> is not applicable for the arguments (String)\n" + >+ "----------\n"); > } > >-public void _test0014() { >+public void test0014() { > this.runConformTest( > new String[] { > "X.java", >@@ -568,7 +633,7 @@ > "SUCCESS\n" + > "123"); > } >-public void _test0014a() { >+public void test0014a() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -590,7 +655,7 @@ > "The method testFunction(String, Integer) in the type X<String,Integer> is not applicable for the arguments (int, String)\n" + > "----------\n"); > } >-public void _test0015() { >+public void test0015() { > this.runConformTest( > new String[] { > "X.java", >@@ -611,8 +676,8 @@ > } > // To verify that a parameterized invocation of a generic constructor works even if <> is used > // to elide class type parameters. >-public void _test0016() { >- this.runConformTest( >+public void test0016() { >+ this.runConformTest( // javac fails to compile this, looks buggy > new String[] { > "X.java", > "public class X<T> {\n" + >@@ -632,8 +697,8 @@ > } > // To verify that a parameterized invocation of a generic constructor works even if <> is used > // to elide class type parameters. This test handles fields >-public void _test0016b() { >- this.runConformTest( >+public void test0016b() { >+ this.runConformTest( // javac fails to compile this, looks buggy > new String[] { > "X.java", > "public class X<T> {\n" + >@@ -657,8 +722,8 @@ > // To verify that a parameterized invocation of a non-generic constructor works even if <> is used > // to elide class type parameters. > // This was not allowed in java 1.6 and 1.5 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=168230) >-public void _test0017() { >- this.runConformTest( >+public void test0017() { >+ this.runConformTest( // javac fails to compile this, looks buggy > new String[] { > "X.java", > "public class X<T> {\n" + >@@ -679,7 +744,7 @@ > "const.1\nconst.1\nconst.2"); > } > // To verify that the correct constructor is found by parameter substitution in the diamond case >-public void _test0018() { >+public void test0018() { > this.runConformTest( > new String[] { > "X.java", >@@ -700,7 +765,7 @@ > } > // To verify that the correct constructor is found by parameter substitution > // in the diamond case -- fields >-public void _test0018b() { >+public void test0018b() { > this.runConformTest( > new String[] { > "X.java", >@@ -738,7 +803,7 @@ > "----------\n"); > } > // check inference at method argument position. >-public void _test0020() { >+public void test0020() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -757,7 +822,7 @@ > "----------\n"); > } > //check inference at method argument position. >-public void _test0021() { >+public void test0021() { > this.runNegativeTest( > new String[] { > "X.java",
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