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 193901 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 v0.95
patch.txt (text/plain), 33.00 KB, created by
Srikanth Sankaran
on 2011-04-22 00:42:42 EDT
(
hide
)
Description:
Revised Implementation v0.95
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2011-04-22 00:42:42 EDT
Size:
33.00 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.5 >diff -u -r1.84.2.5 AllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 20 Apr 2011 16:36:05 -0000 1.84.2.5 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java 22 Apr 2011 04:38:02 -0000 >@@ -17,12 +17,14 @@ > *******************************************************************************/ > 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.*; > import org.eclipse.jdt.internal.compiler.flow.*; > import org.eclipse.jdt.internal.compiler.impl.Constant; > import org.eclipse.jdt.internal.compiler.lookup.*; >+import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable; > > public class AllocationExpression extends Expression implements InvocationSite { > >@@ -260,11 +262,7 @@ > // initialization of an enum constant > this.resolvedType = scope.enclosingReceiverType(); > } else { >- if ((this.type.bits & ASTNode.IsDiamond) != 0) { >- this.resolvedType = null; // can be done only after type arguments and method arguments resolution. >- } else { >- this.resolvedType = this.type.resolveType(scope, true /* check bounds*/); >- } >+ this.resolvedType = this.type.resolveType(scope, true /* check bounds*/); > // check for parameterized allocation deferred to below. > } > // will check for null after args are resolved >@@ -338,9 +336,19 @@ > return this.resolvedType; > } > } >- if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) { >- // Perform diamond inference here. (Not done yet.) >- this.resolvedType = this.type.resolveType(scope, true /* check bounds*/); // for now just do what we do for 1.6- >+ if (this.resolvedType == null || !this.resolvedType.isValidBinding()) { >+ return null; >+ } >+ >+ // null type denotes fake allocation for enum constant inits >+ if (this.type != null && !this.resolvedType.canBeInstantiated()) { >+ scope.problemReporter().cannotInstantiate(this.type, this.resolvedType); >+ return this.resolvedType; >+ } >+ if (this.type != null && this.resolvedType != 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()); >+ // inject inferred args ?? > } > checkParameterizedAllocation: { > if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>() >@@ -360,15 +368,7 @@ > } > } > } >- if (this.resolvedType == null || !this.resolvedType.isValidBinding()) { >- return null; >- } > >- // null type denotes fake allocation for enum constant inits >- if (this.type != null && !this.resolvedType.canBeInstantiated()) { >- scope.problemReporter().cannotInstantiate(this.type, this.resolvedType); >- return this.resolvedType; >- } > ReferenceBinding allocationType = (ReferenceBinding) this.resolvedType; > if (!(this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { > if (this.binding.declaringClass == null) { >@@ -394,6 +394,149 @@ > return allocationType; > } > >+public TypeBinding[] inferElidedTypes(ReferenceBinding allocationType, TypeBinding[] argumentTypes, final BlockScope scope) { >+ MethodBinding factory = getStaticFactory(allocationType, argumentTypes, scope); >+ if (factory instanceof ParameterizedGenericMethodBinding) { >+ return ((ParameterizedGenericMethodBinding) factory).typeArguments; >+ } >+ // Either inference failed or no inference was needed (exact match) ... >+ 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; >+} >+ >+private MethodBinding getStaticFactory (ReferenceBinding allocationType, TypeBinding[] argumentTypes, final BlockScope scope) { >+ 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]; >+ >+// if (method.parameters.length == argumentTypes.length) { >+// TypeBinding[] toMatch = method.parameters; >+// for (int iarg = 0, argCount = argumentTypes.length; iarg < argCount; iarg++) { >+// if (toMatch[iarg] != argumentTypes[iarg]) >+// break; >+// } >+// // we have an exact match, no inference is called for ... >+// return method; >+// } >+ >+ TypeVariableBinding[] methodTypeVariables = method.typeVariables(); >+ int methodTypeVariablesArity = methodTypeVariables.length; >+ >+ if (this.genericTypeArguments != null && this.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 + (this.genericTypeArguments == null ? methodTypeVariablesArity : 0)]; >+ final SimpleLookupTable map = new SimpleLookupTable(classTypeVariablesArity + methodTypeVariablesArity); >+ // Rename each type variable T of the type to T' >+ 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, scope.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], >+ this.genericTypeArguments != null ? this.genericTypeArguments[j - classTypeVariablesArity] : >+ (staticFactory.typeVariables[j] = new TypeVariableBinding(CharOperation.concat(methodTypeVariables[j - classTypeVariablesArity].sourceName, "''".toCharArray()), //$NON-NLS-1$ >+ staticFactory, j, scope.environment()))); >+ } >+ >+ 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); >+ } >+ }; >+ >+ staticFactory.parameters = Scope.substitute(substitution, method.parameters); >+ >+ // 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 = scope.environment().getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null); >+ substitutedVariable.superInterfaces = substitutedInterfaces; >+ break; >+ default: >+ if (substitutedSuperclass.isInterface()) { >+ substitutedVariable.superclass = scope.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 = scope.environment().createParameterizedType(allocationType, returnTypeParameters, allocationType.enclosingType()); >+ staticFactory.thrownExceptions = Scope.substitute(substitution, method.thrownExceptions); >+ if (staticFactory.thrownExceptions == null) { >+ staticFactory.thrownExceptions = Binding.NO_EXCEPTIONS; >+ } >+ ParameterizedMethodBinding aFactory = new ParameterizedMethodBinding((ParameterizedTypeBinding) scope.environment().convertToParameterizedType(staticFactory.declaringClass), >+ staticFactory); >+ staticFactories[sfi++] = aFactory; >+ } >+ if (sfi != methods.length) { >+ System.arraycopy(staticFactories, 0, staticFactories = new MethodBinding[sfi], 0, sfi); >+ } >+ MethodBinding[] compatible = new MethodBinding[sfi]; >+ int compatibleIndex = 0; >+ for (int i = 0; i < sfi; i++) { >+ MethodBinding compatibleMethod = scope.computeCompatibleMethod(staticFactories[i], argumentTypes, this); >+ 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(this, scope)) >+ visible[visibleIndex++] = method; >+ } >+ if (visibleIndex == 0) { >+ return null; >+ } >+ return visibleIndex == 1 ? visible[0] : scope.mostSpecificMethodBinding(visible, visibleIndex, argumentTypes, this, allocationType); >+} >+ > public void setActualReceiverType(ReferenceBinding receiverType) { > // ignored > } >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 22 Apr 2011 04:38:03 -0000 >@@ -268,7 +268,7 @@ > // check argument type compatibility > if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution > parameterizedType.boundCheck(scope, args); >- else >+ else if (!isDiamond) > scope.deferBoundCheck(this); > qualifyingType = parameterizedType; > } else { >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 22 Apr 2011 04:38:03 -0000 >@@ -245,7 +245,7 @@ > // check argument type compatibility > if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution > parameterizedType.boundCheck(scope, this.typeArguments); >- else >+ else if ((this.bits & ASTNode.IsDiamond) == 0) > 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.4 >diff -u -r1.101.2.4 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 20 Apr 2011 16:36:05 -0000 1.101.2.4 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 22 Apr 2011 04:38:03 -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; >@@ -275,14 +276,30 @@ > // initialization of an enum constant > receiverType = scope.enclosingSourceType(); > } else { >- if ((this.type.bits & ASTNode.IsDiamond) == 0) { >- receiverType = this.type.resolveType(scope, true /* check bounds*/); >- } else { >- // can be done only after type arguments and method arguments resolution >+ receiverType = this.type.resolveType(scope, true /* check bounds*/); >+ checkParameterizedAllocation: { >+ if (receiverType == null || !receiverType.isValidBinding()) break checkParameterizedAllocation; >+ if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>() >+ ReferenceBinding currentType = (ReferenceBinding)receiverType; >+ do { >+ // isStatic() is answering true for toplevel types >+ if ((currentType.modifiers & ClassFileConstants.AccStatic) != 0) break checkParameterizedAllocation; >+ if (currentType.isRawType()) break checkParameterizedAllocation; >+ } while ((currentType = currentType.enclosingType())!= null); >+ ParameterizedQualifiedTypeReference qRef = (ParameterizedQualifiedTypeReference) this.type; >+ for (int i = qRef.typeArguments.length - 2; i >= 0; i--) { >+ if (qRef.typeArguments[i] != null) { >+ scope.problemReporter().illegalQualifiedParameterizedTypeAllocation(this.type, receiverType); >+ break; >+ } >+ } >+ } > } >- // check for parameterized allocation deferred to below. > } > } >+ if (receiverType == null || !receiverType.isValidBinding()) { >+ hasError = true; >+ } > > // resolve type arguments (for generic constructor call) > if (this.typeArguments != null) { >@@ -324,31 +341,6 @@ > } > } > } >- if (this.type != null && (this.type.bits & ASTNode.IsDiamond) != 0) { >- // Perform diamond inference here. (Not done yet.) >- receiverType = this.type.resolveType(scope, true /* check bounds*/); // for now just do what we do for 1.6- >- } >- checkParameterizedAllocation: { >- if (receiverType == null || !receiverType.isValidBinding()) break checkParameterizedAllocation; >- if (this.type instanceof ParameterizedQualifiedTypeReference) { // disallow new X<String>.Y<Integer>() >- ReferenceBinding currentType = (ReferenceBinding)receiverType; >- do { >- // isStatic() is answering true for toplevel types >- if ((currentType.modifiers & ClassFileConstants.AccStatic) != 0) break checkParameterizedAllocation; >- if (currentType.isRawType()) break checkParameterizedAllocation; >- } while ((currentType = currentType.enclosingType())!= null); >- ParameterizedQualifiedTypeReference qRef = (ParameterizedQualifiedTypeReference) this.type; >- for (int i = qRef.typeArguments.length - 2; i >= 0; i--) { >- if (qRef.typeArguments[i] != null) { >- scope.problemReporter().illegalQualifiedParameterizedTypeAllocation(this.type, receiverType); >- break; >- } >- } >- } >- } >- if (receiverType == null || !receiverType.isValidBinding()) { >- hasError = true; >- } > > // limit of fault-tolerance > if (hasError) { >@@ -394,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 22 Apr 2011 04:38:03 -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 22 Apr 2011 04:38:07 -0000 >@@ -511,7 +511,7 @@ > * Will answer a substituted method in case the method was generic and type inference got triggered; > * in case the method was originally compatible, then simply answer it back. > */ >- protected final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) { >+ public final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) { > TypeBinding[] genericTypeArguments = invocationSite.genericTypeArguments(); > TypeBinding[] parameters = method.parameters; > TypeVariableBinding[] typeVariables = method.typeVariables; >@@ -3686,7 +3686,7 @@ > } > > // caveat: this is not a direct implementation of JLS >- protected final MethodBinding mostSpecificMethodBinding(MethodBinding[] visible, int visibleSize, TypeBinding[] argumentTypes, final InvocationSite invocationSite, ReferenceBinding receiverType) { >+ public final MethodBinding mostSpecificMethodBinding(MethodBinding[] visible, int visibleSize, TypeBinding[] argumentTypes, final InvocationSite invocationSite, ReferenceBinding receiverType) { > int[] compatibilityLevels = new int[visibleSize]; > for (int i = 0; i < visibleSize; i++) > compatibilityLevels[i] = parameterCompatibilityLevel(visible[i], argumentTypes); >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 22 Apr 2011 04:38:07 -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$ >#P org.eclipse.jdt.core.tests.compiler >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 22 Apr 2011 04:38:11 -0000 >@@ -18,7 +18,7 @@ > public class GenericsRegressionTest_1_7 extends AbstractRegressionTest { > > static { >-// TESTS_NAMES = new String[] { "test0014" }; >+// TESTS_NAMES = new String[] { "test001f" }; > // TESTS_NUMBERS = new int[] { 40, 41, 43, 45, 63, 64 }; > // TESTS_RANGE = new int[] { 11, -1 }; > } >@@ -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,8 +349,8 @@ > "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() { >- this.runConformTest( >+public void test001i() { >+ this.runNegativeTest( > new String[] { > "X.java", > "public class X<T> {\n" + >@@ -348,7 +368,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 +401,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 +417,7 @@ > "SUCCESS"); > } > >-public void _test004b() { >+public void test004b() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -437,7 +462,7 @@ > "1"); > } > >-public void _test006() { >+public void test006() { > this.runConformTest( > new String[] { > "X.java", >@@ -460,7 +485,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 +512,7 @@ > "1\n" + > "2"); > } >-public void _test007a() { >+public void test007a() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -529,12 +554,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 +572,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 +613,7 @@ > "SUCCESS\n" + > "123"); > } >-public void _test0014a() { >+public void test0014a() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -590,7 +635,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,7 +656,7 @@ > } > // To verify that a parameterized invocation of a generic constructor works even if <> is used > // to elide class type parameters. >-public void _test0016() { >+public void test0016() { > this.runConformTest( > new String[] { > "X.java", >@@ -632,7 +677,7 @@ > } > // 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() { >+public void test0016b() { > this.runConformTest( > new String[] { > "X.java", >@@ -657,7 +702,7 @@ > // 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() { >+public void test0017() { > this.runConformTest( > new String[] { > "X.java", >@@ -679,7 +724,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 +745,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 +783,7 @@ > "----------\n"); > } > // check inference at method argument position. >-public void _test0020() { >+public void test0020() { > this.runNegativeTest( > new String[] { > "X.java", >@@ -757,7 +802,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