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 83344 Details for
Bug 210422
[compiler] Need to have local bindings created in error cases
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Changes made by Philippe on my machine
210422.txt (text/plain), 18.62 KB, created by
Jerome Lanneluc
on 2007-11-20 12:39:58 EST
(
hide
)
Description:
Changes made by Philippe on my machine
Filename:
MIME Type:
Creator:
Jerome Lanneluc
Created:
2007-11-20 12:39:58 EST
Size:
18.62 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >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.362 >diff -u -r1.362 ProblemReporter.java >--- compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 16 Nov 2007 13:53:37 -0000 1.362 >+++ compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java 20 Nov 2007 17:39:23 -0000 >@@ -680,13 +680,13 @@ > value.sourceEnd); > } > } >-public void anonymousClassCannotExtendFinalClass(Expression expression, TypeBinding type) { >+public void anonymousClassCannotExtendFinalClass(TypeReference reference, TypeBinding type) { > this.handle( > IProblem.AnonymousClassCannotExtendFinalClass, > new String[] {new String(type.readableName())}, > new String[] {new String(type.shortReadableName())}, >- expression.sourceStart, >- expression.sourceEnd); >+ reference.sourceStart, >+ reference.sourceEnd); > } > public void argumentTypeCannotBeVoid(SourceTypeBinding type, AbstractMethodDeclaration methodDecl, Argument arg) { > String[] arguments = new String[] {new String(methodDecl.selector), new String(arg.name)}; >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.85 >diff -u -r1.85 QualifiedAllocationExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 2 Nov 2007 11:23:38 -0000 1.85 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java 20 Nov 2007 17:39:19 -0000 >@@ -42,7 +42,7 @@ > //qualification may be on both side > public Expression enclosingInstance; > public TypeDeclaration anonymousType; >- public ReferenceBinding superTypeBinding; >+ public ReferenceBinding superclassBinding; > > public QualifiedAllocationExpression() { > // for subtypes >@@ -64,7 +64,7 @@ > } > > // check captured variables are initialized in current context (26134) >- ReferenceBinding allocatedType = this.superTypeBinding == null ? this.binding.declaringClass : this.superTypeBinding; >+ ReferenceBinding allocatedType = this.superclassBinding == null ? this.binding.declaringClass : this.superclassBinding; // TODO shouldn't it be #resolvedType ? > checkCapturedLocalInitializationIfNecessary( > (ReferenceBinding) allocatedType.erasure(), > currentScope, >@@ -284,16 +284,6 @@ > } > if (receiverType == null) { > hasError = true; >- } else if (((ReferenceBinding) receiverType).isFinal()) { >- if (this.anonymousType != null) { >- if (!receiverType.isEnum()) { >- scope.problemReporter().anonymousClassCannotExtendFinalClass(this.type, receiverType); >- hasError = true; >- } >- } else if (!receiverType.canBeInstantiated()) { >- scope.problemReporter().cannotInstantiate(this.type, receiverType); >- return this.resolvedType = receiverType; >- } > } > // resolve type arguments (for generic constructor call) > if (this.typeArguments != null) { >@@ -331,13 +321,14 @@ > // limit of fault-tolerance > if (hasError) { > if (receiverType instanceof ReferenceBinding) { >+ ReferenceBinding referenceReceiver = (ReferenceBinding) receiverType; > // record a best guess, for clients who need hint about possible contructor match > int length = this.arguments == null ? 0 : this.arguments.length; > TypeBinding[] pseudoArgs = new TypeBinding[length]; > for (int i = length; --i >= 0;) { > pseudoArgs[i] = argumentTypes[i] == null ? TypeBinding.NULL : argumentTypes[i]; // replace args with errors with null type > } >- this.binding = scope.findMethod((ReferenceBinding) receiverType, TypeConstants.INIT, pseudoArgs, this); >+ this.binding = scope.findMethod(referenceReceiver, TypeConstants.INIT, pseudoArgs, this); > if (this.binding != null && !this.binding.isValidBinding()) { > MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch; > // record the closest match, for clients who may still need hint about possible method match >@@ -354,7 +345,12 @@ > } > } > } >- >+ if (this.anonymousType != null) { >+ // insert anonymous type in scope (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=210070) >+ scope.addAnonymousType(this.anonymousType, referenceReceiver); >+ this.anonymousType.resolve(scope); >+ return this.resolvedType = this.anonymousType.binding; >+ } > } > return this.resolvedType = receiverType; > } >@@ -392,57 +388,55 @@ > scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance); > return this.resolvedType = receiverType; > } >- >- if (receiverType.isTypeVariable()) { >- receiverType = new ProblemReferenceBinding(receiverType.sourceName(), (ReferenceBinding)receiverType, ProblemReasons.IllegalSuperTypeVariable); >- scope.problemReporter().invalidType(this, receiverType); >+ ReferenceBinding superType = (ReferenceBinding) receiverType; >+ if (superType.isTypeVariable()) { >+ superType = new ProblemReferenceBinding(superType.sourceName(), superType, ProblemReasons.IllegalSuperTypeVariable); >+ scope.problemReporter().invalidType(this, superType); > return null; >- } else if (this.type != null && receiverType.isEnum()) { // tolerate enum constant body >- scope.problemReporter().cannotInstantiate(this.type, receiverType); >- return this.resolvedType = receiverType; >+ } else if (this.type != null && superType.isEnum()) { // tolerate enum constant body >+ scope.problemReporter().cannotInstantiate(this.type, superType); >+ return this.resolvedType = superType; > } > // anonymous type scenario > // an anonymous class inherits from java.lang.Object when declared "after" an interface >- this.superTypeBinding = receiverType.isInterface() ? scope.getJavaLangObject() : (ReferenceBinding) receiverType; >+ this.superclassBinding = superType.isInterface() ? scope.getJavaLangObject() : superType; > // insert anonymous type in scope >- scope.addAnonymousType(this.anonymousType, (ReferenceBinding) receiverType); >- this.anonymousType.resolve(scope); >- 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(this.anonymousType.binding, this.type, receiverType); >- } >+ scope.addAnonymousType(this.anonymousType, superType); >+ this.anonymousType.resolve(scope); >+ > // find anonymous super constructor >- MethodBinding inheritedBinding = scope.getConstructor(this.superTypeBinding, argumentTypes, this); >- if (!inheritedBinding.isValidBinding()) { >- if (inheritedBinding.declaringClass == null) { >- inheritedBinding.declaringClass = this.superTypeBinding; >+ this.resolvedType = this.anonymousType.binding; // 1.2 change >+ if ((this.resolvedType.tagBits & TagBits.HierarchyHasProblems) == 0) { >+ MethodBinding inheritedBinding = scope.getConstructor(this.superclassBinding, argumentTypes, this); >+ if (!inheritedBinding.isValidBinding()) { >+ if (inheritedBinding.declaringClass == null) { >+ inheritedBinding.declaringClass = this.superclassBinding; >+ } >+ scope.problemReporter().invalidConstructor(this, inheritedBinding); >+ return this.resolvedType; >+ } >+ if (this.enclosingInstance != null) { >+ ReferenceBinding targetEnclosing = inheritedBinding.declaringClass.enclosingType(); >+ if (targetEnclosing == null) { >+ scope.problemReporter().unnecessaryEnclosingInstanceSpecification(this.enclosingInstance, superType); >+ return this.resolvedType; >+ } else if (!enclosingInstanceType.isCompatibleWith(targetEnclosing) && !scope.isBoxingCompatibleWith(enclosingInstanceType, targetEnclosing)) { >+ scope.problemReporter().typeMismatchError(enclosingInstanceType, targetEnclosing, this.enclosingInstance); >+ return this.resolvedType; >+ } >+ this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); >+ } >+ if (this.arguments != null) { >+ // TODO shouldn't this.superclassBinding be replaced with superType ? >+ checkInvocationArguments(scope, null, this.superclassBinding, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this); > } >- scope.problemReporter().invalidConstructor(this, inheritedBinding); >- return this.resolvedType = this.anonymousType.binding; >+ if (this.typeArguments != null && inheritedBinding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { >+ scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(inheritedBinding, this.genericTypeArguments, this.typeArguments); >+ } >+ // Update the anonymous inner class : superclass, interface >+ this.binding = this.anonymousType.createDefaultConstructorWithBinding(inheritedBinding); > } >- if (this.enclosingInstance != null) { >- ReferenceBinding targetEnclosing = inheritedBinding.declaringClass.enclosingType(); >- if (targetEnclosing == null) { >- 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, this.enclosingInstance); >- return this.resolvedType = this.anonymousType.binding; >- } >- this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); >- } >- if (this.arguments != null) >- checkInvocationArguments(scope, null, this.superTypeBinding, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this); >- >- if (this.typeArguments != null && inheritedBinding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { >- scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(inheritedBinding, this.genericTypeArguments, this.typeArguments); >- } >- // Update the anonymous inner class : superclass, interface >- this.binding = this.anonymousType.createDefaultConstructorWithBinding(inheritedBinding); >- return this.resolvedType = this.anonymousType.binding; // 1.2 change >+ return this.resolvedType; > } > > public void traverse(ASTVisitor visitor, BlockScope scope) { >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v >retrieving revision 1.154 >diff -u -r1.154 ClassScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 25 Oct 2007 14:02:13 -0000 1.154 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 20 Nov 2007 17:39:20 -0000 >@@ -38,13 +38,27 @@ > } > > void buildAnonymousTypeBinding(SourceTypeBinding enclosingType, ReferenceBinding supertype) { >- LocalTypeBinding anonymousType = buildLocalType(enclosingType, enclosingType.fPackage); >+ LocalTypeBinding anonymousType = buildLocalType(enclosingType, supertype, enclosingType.fPackage); > SourceTypeBinding sourceType = referenceContext.binding; > if (supertype.isInterface()) { > sourceType.superclass = getJavaLangObject(); > sourceType.superInterfaces = new ReferenceBinding[] { supertype }; > } else { >- sourceType.superclass = supertype; >+ if (supertype.erasure().id == TypeIds.T_JavaLangEnum) { >+ problemReporter().cannotExtendEnum(anonymousType, referenceContext.allocation.type, supertype); >+ sourceType.tagBits |= TagBits.HierarchyHasProblems; >+ sourceType.superclass = getJavaLangObject(); >+ } else if (supertype.isFinal()) { >+ problemReporter().anonymousClassCannotExtendFinalClass(referenceContext.allocation.type, supertype); >+ sourceType.tagBits |= TagBits.HierarchyHasProblems; >+ sourceType.superclass = getJavaLangObject(); >+ } else if ((supertype.tagBits & TagBits.HasDirectWildcard) != 0) { >+ problemReporter().superTypeCannotUseWildcard(anonymousType, referenceContext.allocation.type, supertype); >+ sourceType.tagBits |= TagBits.HierarchyHasProblems; >+ sourceType.superclass = getJavaLangObject(); >+ } else { >+ sourceType.superclass = supertype; >+ } > sourceType.superInterfaces = Binding.NO_SUPERINTERFACES; > } > connectMemberTypes(); >@@ -144,14 +158,14 @@ > ((SourceTypeBinding) memberTypes[i]).scope.buildFieldsAndMethods(); > } > >- private LocalTypeBinding buildLocalType(SourceTypeBinding enclosingType, PackageBinding packageBinding) { >+ private LocalTypeBinding buildLocalType(SourceTypeBinding enclosingType, ReferenceBinding anonymousOriginalSuperType, PackageBinding packageBinding) { > > referenceContext.scope = this; > referenceContext.staticInitializerScope = new MethodScope(this, referenceContext, true); > referenceContext.initializerScope = new MethodScope(this, referenceContext, false); > > // build the binding or the local type >- LocalTypeBinding localType = new LocalTypeBinding(this, enclosingType, this.innermostSwitchCase()); >+ LocalTypeBinding localType = new LocalTypeBinding(this, enclosingType, this.innermostSwitchCase(), anonymousOriginalSuperType); > referenceContext.binding = localType; > checkAndSetModifiers(); > buildTypeVariables(); >@@ -187,7 +201,7 @@ > } > } > ClassScope memberScope = new ClassScope(this, referenceContext.memberTypes[i]); >- LocalTypeBinding memberBinding = memberScope.buildLocalType(localType, packageBinding); >+ LocalTypeBinding memberBinding = memberScope.buildLocalType(localType, null /* anonymous super type*/, packageBinding); > memberBinding.setAsMemberType(); > memberTypeBindings[count++] = memberBinding; > } >@@ -200,7 +214,7 @@ > > void buildLocalTypeBinding(SourceTypeBinding enclosingType) { > >- LocalTypeBinding localType = buildLocalType(enclosingType, enclosingType.fPackage); >+ LocalTypeBinding localType = buildLocalType(enclosingType, null /* anonymous super type*/, enclosingType.fPackage); > connectTypeHierarchy(); > buildFieldsAndMethods(); > localType.faultInTypesForFieldsAndMethods(); >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java,v >retrieving revision 1.44 >diff -u -r1.44 LocalTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java 27 Apr 2007 15:51:38 -0000 1.44 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/LocalTypeBinding.java 20 Nov 2007 17:39:20 -0000 >@@ -22,23 +22,26 @@ > public CaseStatement enclosingCase; // from 1.4 on, local types should not be accessed across switch case blocks (52221) > public int sourceStart; // used by computeUniqueKey to uniquely identify this binding > public MethodBinding enclosingMethod; >+ public ReferenceBinding anonymousOriginalSuperType; > >-public LocalTypeBinding(ClassScope scope, SourceTypeBinding enclosingType, CaseStatement switchCase) { >+public LocalTypeBinding(ClassScope scope, SourceTypeBinding enclosingType, CaseStatement switchCase, ReferenceBinding anonymousOriginalSuperType) { > super( > new char[][] {CharOperation.concat(LocalTypePrefix, scope.referenceContext.name)}, > scope, > enclosingType); > >- if (this.sourceName == CharOperation.NO_CHAR) >+ if (anonymousOriginalSuperType != null) { > this.tagBits |= TagBits.AnonymousTypeMask; >- else >+ this.anonymousOriginalSuperType = anonymousOriginalSuperType; >+ } else { > this.tagBits |= TagBits.LocalTypeMask; >+ } > this.enclosingCase = switchCase; > this.sourceStart = scope.referenceContext.sourceStart; > MethodScope methodScope = scope.enclosingMethodScope(); >- AbstractMethodDeclaration declaration = methodScope.referenceMethod(); >- if (declaration != null) { >- this.enclosingMethod = declaration.binding; >+ AbstractMethodDeclaration methodDeclaration = methodScope.referenceMethod(); >+ if (methodDeclaration != null) { >+ this.enclosingMethod = methodDeclaration.binding; > } > } > /* Record a dependency onto a source target type which may be altered >@@ -126,10 +129,7 @@ > public char[] readableName() /*java.lang.Object, p.X<T> */ { > char[] readableName; > if (isAnonymousType()) { >- if (superInterfaces == Binding.NO_SUPERINTERFACES) >- readableName = CharOperation.concat(TypeConstants.ANONYM_PREFIX, superclass.readableName(), TypeConstants.ANONYM_SUFFIX); >- else >- readableName = CharOperation.concat(TypeConstants.ANONYM_PREFIX, superInterfaces[0].readableName(), TypeConstants.ANONYM_SUFFIX); >+ readableName = CharOperation.concat(TypeConstants.ANONYM_PREFIX, anonymousOriginalSuperType.readableName(), TypeConstants.ANONYM_SUFFIX); > } else if (isMemberType()) { > readableName = CharOperation.concat(enclosingType().readableName(), this.sourceName, '.'); > } else { >@@ -154,10 +154,7 @@ > public char[] shortReadableName() /*Object*/ { > char[] shortReadableName; > if (isAnonymousType()) { >- if (superInterfaces == Binding.NO_SUPERINTERFACES) >- shortReadableName = CharOperation.concat(TypeConstants.ANONYM_PREFIX, superclass.shortReadableName(), TypeConstants.ANONYM_SUFFIX); >- else >- shortReadableName = CharOperation.concat(TypeConstants.ANONYM_PREFIX, superInterfaces[0].shortReadableName(), TypeConstants.ANONYM_SUFFIX); >+ shortReadableName = CharOperation.concat(TypeConstants.ANONYM_PREFIX, anonymousOriginalSuperType.shortReadableName(), TypeConstants.ANONYM_SUFFIX); > } else if (isMemberType()) { > shortReadableName = CharOperation.concat(enclosingType().shortReadableName(), sourceName, '.'); > } else { >@@ -203,11 +200,7 @@ > } > public char[] sourceName() { > if (isAnonymousType()) { >- if (superInterfaces == Binding.NO_SUPERINTERFACES) >- return CharOperation.concat(TypeConstants.ANONYM_PREFIX, superclass.sourceName(), TypeConstants.ANONYM_SUFFIX); >- else >- return CharOperation.concat(TypeConstants.ANONYM_PREFIX, superInterfaces[0].sourceName(), TypeConstants.ANONYM_SUFFIX); >- >+ return CharOperation.concat(TypeConstants.ANONYM_PREFIX, anonymousOriginalSuperType.sourceName(), TypeConstants.ANONYM_SUFFIX); > } else > return sourceName; > }
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 210422
:
83344
|
83429