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 64742 Details for
Bug 183216
[1.5][compiler] Cannot refer to a generic member type using a non static subclass of the enclosing type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Better patch
183216.txt (text/plain), 30.46 KB, created by
Philipe Mulet
on 2007-04-24 10:39:47 EDT
(
hide
)
Description:
Better patch
Filename:
MIME Type:
Creator:
Philipe Mulet
Created:
2007-04-24 10:39:47 EDT
Size:
30.46 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.81 >diff -u -r1.81 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 6 Mar 2007 02:38:48 -0000 1.81 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 24 Apr 2007 11:53:04 -0000 >@@ -12,10 +12,20 @@ > > 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.codegen.CodeStream; >+import org.eclipse.jdt.internal.compiler.flow.FlowContext; >+import org.eclipse.jdt.internal.compiler.flow.FlowInfo; > import org.eclipse.jdt.internal.compiler.impl.Constant; >-import org.eclipse.jdt.internal.compiler.lookup.*; >+import org.eclipse.jdt.internal.compiler.lookup.Binding; >+import org.eclipse.jdt.internal.compiler.lookup.BlockScope; >+import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding; >+import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; >+import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; >+import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; >+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; >+import org.eclipse.jdt.internal.compiler.lookup.TagBits; >+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; >+import org.eclipse.jdt.internal.compiler.lookup.TypeIds; > > /** > * Variation on allocation, where can optionally be specified any of: >@@ -45,8 +55,8 @@ > FlowInfo flowInfo) { > > // analyse the enclosing instance >- if (enclosingInstance != null) { >- flowInfo = enclosingInstance.analyseCode(currentScope, flowContext, flowInfo); >+ if (this.enclosingInstance != null) { >+ flowInfo = this.enclosingInstance.analyseCode(currentScope, flowContext, flowInfo); > } > > // check captured variables are initialized in current context (26134) >@@ -57,20 +67,20 @@ > flowInfo); > > // process arguments >- if (arguments != null) { >- for (int i = 0, count = arguments.length; i < count; i++) { >- flowInfo = arguments[i].analyseCode(currentScope, flowContext, flowInfo); >+ if (this.arguments != null) { >+ for (int i = 0, count = this.arguments.length; i < count; i++) { >+ flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo); > } > } > > // analyse the anonymous nested type >- if (anonymousType != null) { >- flowInfo = anonymousType.analyseCode(currentScope, flowContext, flowInfo); >+ if (this.anonymousType != null) { >+ flowInfo = this.anonymousType.analyseCode(currentScope, flowContext, flowInfo); > } > > // record some dependency information for exception types > ReferenceBinding[] thrownExceptions; >- if (((thrownExceptions = binding.thrownExceptions).length) != 0) { >+ if (((thrownExceptions = this.binding.thrownExceptions).length) != 0) { > // check exception handling > flowContext.checkExceptionHandlers( > thrownExceptions, >@@ -85,7 +95,7 @@ > > public Expression enclosingInstance() { > >- return enclosingInstance; >+ return this.enclosingInstance; > } > > public void generateCode( >@@ -104,8 +114,8 @@ > codeStream.recordPositionsFrom(pc, this.type.sourceStart); > } else { > // push enum constant name and ordinal >- codeStream.ldc(String.valueOf(enumConstant.name)); >- codeStream.generateInlinedValue(enumConstant.binding.id); >+ codeStream.ldc(String.valueOf(this.enumConstant.name)); >+ codeStream.generateInlinedValue(this.enumConstant.binding.id); > } > // handling innerclass instance allocation - enclosing instance arguments > if (allocatedType.isNestedType()) { >@@ -116,7 +126,7 @@ > this); > } > // generate the arguments for constructor >- generateArguments(binding, arguments, currentScope, codeStream); >+ generateArguments(this.binding, this.arguments, currentScope, codeStream); > // handling innerclass instance allocation - outer local arguments > if (allocatedType.isNestedType()) { > codeStream.generateSyntheticOuterArgumentValues( >@@ -126,30 +136,30 @@ > } > > // invoke constructor >- if (syntheticAccessor == null) { >+ if (this.syntheticAccessor == null) { > codeStream.invokespecial(this.codegenBinding); > } else { > // synthetic accessor got some extra arguments appended to its signature, which need values > for (int i = 0, >- max = syntheticAccessor.parameters.length - this.codegenBinding.parameters.length; >+ max = this.syntheticAccessor.parameters.length - this.codegenBinding.parameters.length; > i < max; > i++) { > codeStream.aconst_null(); > } >- codeStream.invokespecial(syntheticAccessor); >+ codeStream.invokespecial(this.syntheticAccessor); > } > codeStream.generateImplicitConversion(this.implicitConversion); > codeStream.recordPositionsFrom(pc, this.sourceStart); > >- if (anonymousType != null) { >- anonymousType.generateCode(currentScope, codeStream); >+ if (this.anonymousType != null) { >+ this.anonymousType.generateCode(currentScope, codeStream); > } > } > > public boolean isSuperAccess() { > > // necessary to lookup super constructor of anonymous type >- return anonymousType != null; >+ return this.anonymousType != null; > } > > /* Inner emulation consists in either recording a dependency >@@ -162,17 +172,17 @@ > public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { > > if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { >- ReferenceBinding allocatedTypeErasure = (ReferenceBinding) binding.declaringClass.erasure(); >+ ReferenceBinding allocatedTypeErasure = (ReferenceBinding) this.binding.declaringClass.erasure(); > > // perform some extra emulation work in case there is some and we are inside a local type only > if (allocatedTypeErasure.isNestedType() > && currentScope.enclosingSourceType().isLocalType()) { > > if (allocatedTypeErasure.isLocalType()) { >- ((LocalTypeBinding) allocatedTypeErasure).addInnerEmulationDependent(currentScope, enclosingInstance != null); >+ ((LocalTypeBinding) allocatedTypeErasure).addInnerEmulationDependent(currentScope, this.enclosingInstance != null); > } else { > // locally propagate, since we already now the desired shape for sure >- currentScope.propagateInnerEmulation(allocatedTypeErasure, enclosingInstance != null); >+ currentScope.propagateInnerEmulation(allocatedTypeErasure, this.enclosingInstance != null); > } > } > } >@@ -180,11 +190,11 @@ > > public StringBuffer printExpression(int indent, StringBuffer output) { > >- if (enclosingInstance != null) >- enclosingInstance.printExpression(0, output).append('.'); >+ if (this.enclosingInstance != null) >+ this.enclosingInstance.printExpression(0, output).append('.'); > super.printExpression(0, output); >- if (anonymousType != null) { >- anonymousType.print(indent, output); >+ if (this.anonymousType != null) { >+ this.anonymousType.print(indent, output); > } > return output; > } >@@ -200,32 +210,32 @@ > // ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt > // ClassInstanceCreationExpression ::= Name '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt > >- constant = Constant.NotAConstant; >+ this.constant = Constant.NotAConstant; > TypeBinding enclosingInstanceType = null; > TypeBinding receiverType = null; > boolean hasError = false; > boolean enclosingInstanceContainsCast = false; > boolean argsContainCast = false; > >- if (enclosingInstance != null) { >- if (enclosingInstance instanceof CastExpression) { >- enclosingInstance.bits |= DisableUnnecessaryCastCheck; // will check later on >+ if (this.enclosingInstance != null) { >+ if (this.enclosingInstance instanceof CastExpression) { >+ this.enclosingInstance.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on > enclosingInstanceContainsCast = true; > } >- if ((enclosingInstanceType = enclosingInstance.resolveType(scope)) == null){ >+ if ((enclosingInstanceType = this.enclosingInstance.resolveType(scope)) == null){ > hasError = true; > } else if (enclosingInstanceType.isBaseType() || enclosingInstanceType.isArrayType()) { > scope.problemReporter().illegalPrimitiveOrArrayTypeForEnclosingInstance( > enclosingInstanceType, >- enclosingInstance); >+ this.enclosingInstance); > hasError = true; >- } else if (type instanceof QualifiedTypeReference) { >- scope.problemReporter().illegalUsageOfQualifiedTypeReference((QualifiedTypeReference)type); >+ } else if (this.type instanceof QualifiedTypeReference) { >+ scope.problemReporter().illegalUsageOfQualifiedTypeReference((QualifiedTypeReference)this.type); > hasError = true; > } else { >- receiverType = ((SingleTypeReference) type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType); >+ receiverType = ((SingleTypeReference) this.type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType); > if (receiverType != null && enclosingInstanceContainsCast) { >- CastExpression.checkNeedForEnclosingInstanceCast(scope, enclosingInstance, enclosingInstanceType, receiverType); >+ CastExpression.checkNeedForEnclosingInstanceCast(scope, this.enclosingInstance, enclosingInstanceType, receiverType); > } > } > } else { >@@ -259,11 +269,11 @@ > } else if (((ReferenceBinding) receiverType).isFinal()) { > if (this.anonymousType != null) { > if (!receiverType.isEnum()) { >- scope.problemReporter().anonymousClassCannotExtendFinalClass(type, receiverType); >+ scope.problemReporter().anonymousClassCannotExtendFinalClass(this.type, receiverType); > hasError = true; > } > } else if (!receiverType.canBeInstantiated()) { >- scope.problemReporter().cannotInstantiate(type, receiverType); >+ scope.problemReporter().cannotInstantiate(this.type, receiverType); > return this.resolvedType = receiverType; > } > } >@@ -286,13 +296,13 @@ > > // will check for null after args are resolved > TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; >- if (arguments != null) { >- int length = arguments.length; >+ if (this.arguments != null) { >+ int length = this.arguments.length; > argumentTypes = new TypeBinding[length]; > for (int i = 0; i < length; i++) { > Expression argument = this.arguments[i]; > if (argument instanceof CastExpression) { >- argument.bits |= DisableUnnecessaryCastCheck; // will check later on >+ argument.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on > argsContainCast = true; > } > if ((argumentTypes[i] = argument.resolveType(scope)) == null){ >@@ -305,15 +315,15 @@ > if (this.anonymousType == null) { > // qualified allocation with no anonymous type > if (!receiverType.canBeInstantiated()) { >- scope.problemReporter().cannotInstantiate(type, receiverType); >+ scope.problemReporter().cannotInstantiate(this.type, receiverType); > return this.resolvedType = receiverType; > } > ReferenceBinding allocationType = (ReferenceBinding) receiverType; > if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { >- if (isMethodUseDeprecated(binding, scope, true)) { >+ if (isMethodUseDeprecated(this.binding, scope, true)) { > scope.problemReporter().deprecatedMethod(this.binding, this); > } >- checkInvocationArguments(scope, null, allocationType, binding, this.arguments, argumentTypes, argsContainCast, this); >+ checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this); > } else { > if (this.binding.declaringClass == null) { > this.binding.declaringClass = allocationType; >@@ -327,7 +337,7 @@ > if (expectedType != enclosingInstanceType) // must call before computeConversion() and typeMismatchError() > scope.compilationUnitScope().recordTypeConversion(expectedType, enclosingInstanceType); > if (enclosingInstanceType.isCompatibleWith(expectedType) || scope.isBoxingCompatibleWith(enclosingInstanceType, expectedType)) { >- enclosingInstance.computeConversion(scope, expectedType, enclosingInstanceType); >+ this.enclosingInstance.computeConversion(scope, expectedType, enclosingInstanceType); > return this.resolvedType = receiverType; > } > scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance); >@@ -338,8 +348,8 @@ > receiverType = new ProblemReferenceBinding(receiverType.sourceName(), (ReferenceBinding)receiverType, ProblemReasons.IllegalSuperTypeVariable); > scope.problemReporter().invalidType(this, receiverType); > return null; >- } else if (type != null && receiverType.isEnum()) { // tolerate enum constant body >- scope.problemReporter().cannotInstantiate(type, receiverType); >+ } else if (this.type != null && receiverType.isEnum()) { // tolerate enum constant body >+ scope.problemReporter().cannotInstantiate(this.type, receiverType); > return this.resolvedType = receiverType; > } > // anonymous type scenario >@@ -348,12 +358,12 @@ > // insert anonymous type in scope > scope.addAnonymousType(this.anonymousType, (ReferenceBinding) receiverType); > this.anonymousType.resolve(scope); >- if (this.superTypeBinding.erasure().id == T_JavaLangEnum) { >+ if (this.superTypeBinding.erasure().id == TypeIds.T_JavaLangEnum) { > scope.problemReporter().cannotExtendEnum(this.anonymousType.binding, this.type, this.superTypeBinding); > } > > if ((receiverType.tagBits & TagBits.HasDirectWildcard) != 0) { >- scope.problemReporter().superTypeCannotUseWildcard(anonymousType.binding, this.type, receiverType); >+ scope.problemReporter().superTypeCannotUseWildcard(this.anonymousType.binding, this.type, receiverType); > } > // find anonymous super constructor > MethodBinding inheritedBinding = scope.getConstructor(this.superTypeBinding, argumentTypes, this); >@@ -362,32 +372,32 @@ > inheritedBinding.declaringClass = this.superTypeBinding; > } > scope.problemReporter().invalidConstructor(this, inheritedBinding); >- return this.resolvedType = anonymousType.binding; >+ return this.resolvedType = this.anonymousType.binding; > } >- if (enclosingInstance != null) { >+ if (this.enclosingInstance != null) { > ReferenceBinding targetEnclosing = inheritedBinding.declaringClass.enclosingType(); > if (targetEnclosing == null) { >- scope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, (ReferenceBinding)receiverType); >- return this.resolvedType = anonymousType.binding; >+ scope.problemReporter().unnecessaryEnclosingInstanceSpecification(this.enclosingInstance, (ReferenceBinding)receiverType); >+ return this.resolvedType = this.anonymousType.binding; > } else if (!enclosingInstanceType.isCompatibleWith(targetEnclosing) && !scope.isBoxingCompatibleWith(enclosingInstanceType, targetEnclosing)) { >- scope.problemReporter().typeMismatchError(enclosingInstanceType, targetEnclosing, enclosingInstance); >- return this.resolvedType = anonymousType.binding; >+ scope.problemReporter().typeMismatchError(enclosingInstanceType, targetEnclosing, this.enclosingInstance); >+ return this.resolvedType = this.anonymousType.binding; > } >- enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); >+ this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); > } > if (this.arguments != null) > checkInvocationArguments(scope, null, this.superTypeBinding, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this); > > // Update the anonymous inner class : superclass, interface >- binding = anonymousType.createDefaultConstructorWithBinding(inheritedBinding); >- return this.resolvedType = anonymousType.binding; // 1.2 change >+ this.binding = this.anonymousType.createDefaultConstructorWithBinding(inheritedBinding); >+ return this.resolvedType = this.anonymousType.binding; // 1.2 change > } > > public void traverse(ASTVisitor visitor, BlockScope scope) { > > if (visitor.visit(this, scope)) { >- if (enclosingInstance != null) >- enclosingInstance.traverse(visitor, scope); >+ if (this.enclosingInstance != null) >+ this.enclosingInstance.traverse(visitor, scope); > if (this.typeArguments != null) { > for (int i = 0, typeArgumentsLength = this.typeArguments.length; i < typeArgumentsLength; i++) { > this.typeArguments[i].traverse(visitor, scope); >@@ -395,13 +405,13 @@ > } > if (this.type != null) // case of enum constant > this.type.traverse(visitor, scope); >- if (arguments != null) { >- int argumentsLength = arguments.length; >+ if (this.arguments != null) { >+ int argumentsLength = this.arguments.length; > for (int i = 0; i < argumentsLength; i++) >- arguments[i].traverse(visitor, scope); >+ this.arguments[i].traverse(visitor, scope); > } >- if (anonymousType != null) >- anonymousType.traverse(visitor, scope); >+ if (this.anonymousType != null) >+ this.anonymousType.traverse(visitor, scope); > } > visitor.endVisit(this, scope); > } >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.37 >diff -u -r1.37 ParameterizedSingleTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 10 Apr 2007 19:03:10 -0000 1.37 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedSingleTypeReference.java 24 Apr 2007 11:53:04 -0000 >@@ -120,7 +120,7 @@ > : scope.environment().convertToParameterizedType(enclosingType); > } > } else { // resolving member type (relatively to enclosingType) >- this.resolvedType = scope.getMemberType(token, (ReferenceBinding)enclosingType.erasure()); >+ this.resolvedType = scope.getMemberType(token, enclosingType); > if (!this.resolvedType.isValidBinding()) { > scope.problemReporter().invalidEnclosingType(this, this.resolvedType, enclosingType); > return null; >@@ -165,10 +165,13 @@ > } else if (argLength != typeVariables.length) { // check arity > scope.problemReporter().incorrectArityForParameterizedType(this, currentType, argTypes); > return null; >- } else if (!currentType.isStatic() && enclosingType != null && enclosingType.isRawType()){ >- scope.problemReporter().rawMemberTypeCannotBeParameterized( >- this, scope.environment().createRawType((ReferenceBinding)currentType.erasure(), enclosingType), argTypes); >- return null; >+ } else if (!currentType.isStatic()) { >+ ReferenceBinding actualEnclosing = currentType.enclosingType(); >+ if (actualEnclosing != null && actualEnclosing.isRawType()){ >+ scope.problemReporter().rawMemberTypeCannotBeParameterized( >+ this, scope.environment().createRawType((ReferenceBinding)currentType.erasure(), actualEnclosing), argTypes); >+ return null; >+ } > } > > ParameterizedTypeBinding parameterizedType = scope.environment().createParameterizedType((ReferenceBinding)currentType.erasure(), argTypes, enclosingType); >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.42 >diff -u -r1.42 ParameterizedQualifiedTypeReference.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 10 Apr 2007 19:03:10 -0000 1.42 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ParameterizedQualifiedTypeReference.java 24 Apr 2007 11:53:04 -0000 >@@ -218,11 +218,14 @@ > return null; > } > // check parameterizing non-static member type of raw type >- if (typeIsConsistent && !currentType.isStatic() && qualifiedType != null && qualifiedType.isRawType()) { >- scope.problemReporter().rawMemberTypeCannotBeParameterized( >- this, scope.environment().createRawType((ReferenceBinding)currentType.erasure(), qualifiedType), argTypes); >- typeIsConsistent = false; >- } >+ if (typeIsConsistent && !currentType.isStatic()) { >+ ReferenceBinding actualEnclosing = currentType.enclosingType(); >+ if (actualEnclosing != null && actualEnclosing.isRawType()) { >+ scope.problemReporter().rawMemberTypeCannotBeParameterized( >+ this, scope.environment().createRawType((ReferenceBinding)currentType.erasure(), actualEnclosing), argTypes); >+ typeIsConsistent = false; >+ } >+ } > ParameterizedTypeBinding parameterizedType = scope.environment().createParameterizedType((ReferenceBinding)currentType.erasure(), argTypes, qualifiedType); > // check argument type compatibility > if (checkBounds) // otherwise will do it in Scope.connectTypeVariables() or generic method resolution >@@ -247,8 +250,9 @@ > } > if (isTypeUseDeprecated(qualifiedType, scope)) > reportDeprecatedType(qualifiedType, scope); >+ this.resolvedType = qualifiedType; > } >- this.resolvedType = qualifiedType; >+// this.resolvedType = qualifiedType; > // array type ? > if (this.dimensions > 0) { > if (dimensions > 255) >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v >retrieving revision 1.613 >diff -u -r1.613 GenericTypeTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 23 Apr 2007 06:51:49 -0000 1.613 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 24 Apr 2007 11:53:15 -0000 >@@ -37384,4 +37384,228 @@ > "Type mismatch: cannot convert from element type Object to Map.Entry<String,String>\n" + > "----------\n"); > } >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=183216 >+public void test1125() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class A {\n" + >+ " class B<T> {\n" + >+ " T t;\n" + >+ " T getValue() {\n" + >+ " return t;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "class C<T> extends A {\n" + >+ " Zork z;\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " static C.B<Double> c = new C().new B<Double>();\n" + >+ "\n" + >+ " public static void main(String[] args) {\n" + >+ " C.B<String> temp = new C().new B<String>();\n" + >+ " String s = temp.getValue();\n" + >+ " System.out.println(s);\n" + >+ " foo(bar());\n" + >+ " }\n" + >+ "\n" + >+ " static C.B<? extends Number> bar() {\n" + >+ " return new C().new B<Integer>();\n" + >+ " }\n" + >+ "\n" + >+ " static void foo(C.B<?> arg) {\n" + >+ " Object o = arg.getValue();\n" + >+ " Double d = c.getValue();\n" + >+ " System.out.println(o);\n" + >+ " System.out.println(d);\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 11)\n" + >+ " Zork z;\n" + >+ " ^^^^\n" + >+ "Zork cannot be resolved to a type\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 15)\n" + >+ " static C.B<Double> c = new C().new B<Double>();\n" + >+ " ^\n" + >+ "C is a raw type. References to generic type C<T> should be parameterized\n" + >+ "----------\n" + >+ "3. WARNING in X.java (at line 18)\n" + >+ " C.B<String> temp = new C().new B<String>();\n" + >+ " ^\n" + >+ "C is a raw type. References to generic type C<T> should be parameterized\n" + >+ "----------\n" + >+ "4. WARNING in X.java (at line 25)\n" + >+ " return new C().new B<Integer>();\n" + >+ " ^\n" + >+ "C is a raw type. References to generic type C<T> should be parameterized\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=183216 - variation >+public void test1126() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "class A {\n" + >+ " class B<T> {\n" + >+ " T t;\n" + >+ " T getValue() {\n" + >+ " return t;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " static A.B<Double> c = new A().new B<Double>();\n" + >+ "\n" + >+ " public static void main(String[] args) {\n" + >+ " A.B<String> temp = new A().new B<String>();\n" + >+ " String s = temp.getValue();\n" + >+ " System.out.print(s);\n" + >+ " foo(bar());\n" + >+ " }\n" + >+ "\n" + >+ " static A.B<? extends Number> bar() {\n" + >+ " return new A().new B<Integer>();\n" + >+ " }\n" + >+ "\n" + >+ " static void foo(A.B<?> arg) {\n" + >+ " Object o = arg.getValue();\n" + >+ " Double d = c.getValue();\n" + >+ " System.out.print(o);\n" + >+ " System.out.print(d);\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "nullnullnull"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=183216 - variation >+public void test1127() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class A<E> {\n" + >+ " class B<T> {\n" + >+ " T t;\n" + >+ " T getValue() {\n" + >+ " return t;\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" + >+ "\n" + >+ "class C<T> extends A<T> {\n" + >+ "}\n" + >+ "\n" + >+ "public class X {\n" + >+ " static C.B<Double> c = new C().new B<Double>();\n" + >+ "\n" + >+ " public static void main(String[] args) {\n" + >+ " C.B<String> temp = new C().new B<String>();\n" + >+ " String s = temp.getValue();\n" + >+ " System.out.println(s);\n" + >+ " foo(bar());\n" + >+ " }\n" + >+ "\n" + >+ " static C.B<? extends Number> bar() {\n" + >+ " return new C().new B<Integer>();\n" + >+ " }\n" + >+ "\n" + >+ " static void foo(C.B<?> arg) {\n" + >+ " Object o = arg.getValue();\n" + >+ " Double d = c.getValue();\n" + >+ " System.out.println(o);\n" + >+ " System.out.println(d);\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 14)\n" + >+ " static C.B<Double> c = new C().new B<Double>();\n" + >+ " ^^^\n" + >+ "The member type A.B<Double> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 14)\n" + >+ " static C.B<Double> c = new C().new B<Double>();\n" + >+ " ^\n" + >+ "C is a raw type. References to generic type C<T> should be parameterized\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 14)\n" + >+ " static C.B<Double> c = new C().new B<Double>();\n" + >+ " ^\n" + >+ "The member type A.B<Double> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n" + >+ "4. ERROR in X.java (at line 17)\n" + >+ " C.B<String> temp = new C().new B<String>();\n" + >+ " ^^^\n" + >+ "The member type A.B<String> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n" + >+ "5. WARNING in X.java (at line 17)\n" + >+ " C.B<String> temp = new C().new B<String>();\n" + >+ " ^\n" + >+ "C is a raw type. References to generic type C<T> should be parameterized\n" + >+ "----------\n" + >+ "6. ERROR in X.java (at line 17)\n" + >+ " C.B<String> temp = new C().new B<String>();\n" + >+ " ^\n" + >+ "The member type A.B<String> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n" + >+ "7. ERROR in X.java (at line 23)\n" + >+ " static C.B<? extends Number> bar() {\n" + >+ " ^^^\n" + >+ "The member type A.B<? extends Number> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n" + >+ "8. WARNING in X.java (at line 24)\n" + >+ " return new C().new B<Integer>();\n" + >+ " ^\n" + >+ "C is a raw type. References to generic type C<T> should be parameterized\n" + >+ "----------\n" + >+ "9. ERROR in X.java (at line 24)\n" + >+ " return new C().new B<Integer>();\n" + >+ " ^\n" + >+ "The member type A.B<Integer> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n" + >+ "10. ERROR in X.java (at line 27)\n" + >+ " static void foo(C.B<?> arg) {\n" + >+ " ^^^\n" + >+ "The member type A.B<?> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n"); >+} >+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=183216 - variation >+public void test1128() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "class A<T> {\n" + >+ " class Member<U> {}\n" + >+ "}\n" + >+ "\n" + >+ "public class X extends A {\n" + >+ " void foo() {\n" + >+ " new Member<String>();\n" + >+ " new X().new Member<String>();\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 5)\n" + >+ " public class X extends A {\n" + >+ " ^\n" + >+ "A is a raw type. References to generic type A<T> should be parameterized\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 7)\n" + >+ " new Member<String>();\n" + >+ " ^^^^^^\n" + >+ "The member type A.Member<String> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 8)\n" + >+ " new X().new Member<String>();\n" + >+ " ^^^^^^\n" + >+ "The member type A.Member<String> must be qualified with a parameterized type, since it is not static\n" + >+ "----------\n"); >+} > }
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 183216
:
64713
| 64742 |
64743