X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/ClassScope.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/ClassScope.java index 9b6777f..4fd2e45 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/ClassScope.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/lookup/ClassScope.java @@ -1,15 +1,16 @@ /******************************************************************************* - * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others. + * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 + * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html + * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation - ******************************************************************************/ + *******************************************************************************/ package net.sourceforge.phpdt.internal.compiler.lookup; +import net.sourceforge.phpdt.core.compiler.CharOperation; import net.sourceforge.phpdt.internal.compiler.ast.AbstractMethodDeclaration; import net.sourceforge.phpdt.internal.compiler.ast.Clinit; import net.sourceforge.phpdt.internal.compiler.ast.FieldDeclaration; @@ -17,7 +18,6 @@ import net.sourceforge.phpdt.internal.compiler.ast.TypeDeclaration; import net.sourceforge.phpdt.internal.compiler.ast.TypeReference; import net.sourceforge.phpdt.internal.compiler.impl.ReferenceContext; import net.sourceforge.phpdt.internal.compiler.problem.ProblemReporter; -import net.sourceforge.phpdt.internal.compiler.util.CharOperation; import net.sourceforge.phpdt.internal.compiler.util.HashtableOfObject; public class ClassScope extends Scope { @@ -301,8 +301,8 @@ public class ClassScope extends Scope { if (isMemberType) { // checks for member types before local types to catch local members - if (enclosingType.isStrictfp()) - modifiers |= AccStrictfp; +// if (enclosingType.isStrictfp()) +// modifiers |= AccStrictfp; if (enclosingType.isDeprecated()) modifiers |= AccDeprecatedImplicitly; if (enclosingType.isInterface()) @@ -313,15 +313,15 @@ public class ClassScope extends Scope { ReferenceContext refContext = methodScope().referenceContext; if (refContext instanceof TypeDeclaration) { ReferenceBinding type = ((TypeDeclaration) refContext).binding; - if (type.isStrictfp()) - modifiers |= AccStrictfp; +// if (type.isStrictfp()) +// modifiers |= AccStrictfp; if (type.isDeprecated()) modifiers |= AccDeprecatedImplicitly; } else { MethodBinding method = ((AbstractMethodDeclaration) refContext).binding; if (method != null){ - if (method.isStrictfp()) - modifiers |= AccStrictfp; +// if (method.isStrictfp()) +// modifiers |= AccStrictfp; if (method.isDeprecated()) modifiers |= AccDeprecatedImplicitly; } @@ -334,7 +334,7 @@ public class ClassScope extends Scope { // detect abnormal cases for interfaces if (isMemberType) { int unexpectedModifiers = - ~(AccPublic | AccPrivate | AccProtected | AccStatic | AccAbstract | AccInterface | AccStrictfp); + ~(AccPublic | AccPrivate | AccProtected | AccStatic | AccAbstract | AccInterface );//| AccStrictfp); if ((realModifiers & unexpectedModifiers) != 0) problemReporter().illegalModifierForMemberInterface(sourceType); /* @@ -344,7 +344,7 @@ public class ClassScope extends Scope { problemReporter().illegalModifierForLocalInterface(sourceType); */ } else { - int unexpectedModifiers = ~(AccPublic | AccAbstract | AccInterface | AccStrictfp); + int unexpectedModifiers = ~(AccPublic | AccAbstract | AccInterface);// | AccStrictfp); if ((realModifiers & unexpectedModifiers) != 0) problemReporter().illegalModifierForInterface(sourceType); } @@ -353,15 +353,15 @@ public class ClassScope extends Scope { // detect abnormal cases for types if (isMemberType) { // includes member types defined inside local types int unexpectedModifiers = - ~(AccPublic | AccPrivate | AccProtected | AccStatic | AccAbstract | AccFinal | AccStrictfp); + ~(AccPublic | AccPrivate | AccProtected | AccStatic | AccAbstract | AccFinal);// | AccStrictfp); if ((realModifiers & unexpectedModifiers) != 0) problemReporter().illegalModifierForMemberClass(sourceType); } else if (sourceType.isLocalType()) { - int unexpectedModifiers = ~(AccAbstract | AccFinal | AccStrictfp); + int unexpectedModifiers = ~(AccAbstract | AccFinal);// | AccStrictfp); if ((realModifiers & unexpectedModifiers) != 0) problemReporter().illegalModifierForLocalClass(sourceType); } else { - int unexpectedModifiers = ~(AccPublic | AccAbstract | AccFinal | AccStrictfp); + int unexpectedModifiers = ~(AccPublic | AccAbstract | AccFinal);// | AccStrictfp); if ((realModifiers & unexpectedModifiers) != 0) problemReporter().illegalModifierForClass(sourceType); } @@ -442,7 +442,7 @@ public class ClassScope extends Scope { // after this point, tests on the 16 bits reserved. int realModifiers = modifiers & AccJustFlag; int unexpectedModifiers = - ~(AccPublic | AccPrivate | AccProtected | AccFinal | AccStatic | AccTransient | AccVolatile); + ~(AccPublic | AccPrivate | AccProtected | AccFinal | AccStatic);// | AccTransient | AccVolatile); if ((realModifiers & unexpectedModifiers) != 0) problemReporter().illegalModifierForField(fieldBinding.declaringClass, fieldDecl); @@ -464,11 +464,14 @@ public class ClassScope extends Scope { modifiers ^= AccPrivate; } - if ((realModifiers & (AccFinal | AccVolatile)) == (AccFinal | AccVolatile)) - problemReporter().illegalModifierCombinationFinalVolatileForField( - fieldBinding.declaringClass, - fieldDecl); +// if ((realModifiers & (AccFinal | AccVolatile)) == (AccFinal | AccVolatile)) +// problemReporter().illegalModifierCombinationFinalVolatileForField( +// fieldBinding.declaringClass, +// fieldDecl); + if (fieldDecl.initialization == null && (modifiers & AccFinal) != 0) { + modifiers |= AccBlankFinal; + } fieldBinding.modifiers = modifiers; } @@ -565,12 +568,16 @@ public class ClassScope extends Scope { */ private boolean connectSuperclass() { SourceTypeBinding sourceType = referenceContext.binding; + if (isJavaLangObject(sourceType)) { // handle the case of redefining java.lang.Object up front + sourceType.superclass = null; + sourceType.superInterfaces = NoSuperInterfaces; + if (referenceContext.superclass != null || referenceContext.superInterfaces != null) + problemReporter().objectCannotHaveSuperTypes(sourceType); + return true; // do not propagate Object's hierarchy problems down to every subtype + } if (referenceContext.superclass == null) { - if (isJavaLangObject(sourceType)) - return true; sourceType.superclass = getJavaLangObject(); return !detectCycle(sourceType, sourceType.superclass, null); - // ensure Object is initialized if it comes from a source file } ReferenceBinding superclass = findSupertype(referenceContext.superclass); if (superclass != null) { // is null if a cycle was detected cycle @@ -580,25 +587,17 @@ public class ClassScope extends Scope { problemReporter().superclassMustBeAClass(sourceType, referenceContext.superclass, superclass); } else if (superclass.isFinal()) { problemReporter().classExtendFinalClass(sourceType, referenceContext.superclass, superclass); - } else if (isJavaLangObject(sourceType)) { - // can only happen if Object extends another type... will never happen unless we're testing for it. - sourceType.tagBits |= HierarchyHasProblems; - sourceType.superclass = null; - return true; } else { // only want to reach here when no errors are reported - referenceContext.superclass.binding = superclass; + referenceContext.superclass.resolvedType = superclass; sourceType.superclass = superclass; return true; } } sourceType.tagBits |= HierarchyHasProblems; - if (!isJavaLangObject(sourceType)) { - sourceType.superclass = getJavaLangObject(); - if ((sourceType.superclass.tagBits & BeginHierarchyCheck) == 0) - detectCycle(sourceType, sourceType.superclass, null); - // ensure Object is initialized if it comes from a source file - } + sourceType.superclass = getJavaLangObject(); + if ((sourceType.superclass.tagBits & BeginHierarchyCheck) == 0) + detectCycle(sourceType, sourceType.superclass, null); return false; // reported some error against the source type } @@ -617,6 +616,8 @@ public class ClassScope extends Scope { sourceType.superInterfaces = NoSuperInterfaces; if (referenceContext.superInterfaces == null) return true; + if (isJavaLangObject(sourceType)) // already handled the case of redefining java.lang.Object + return true; boolean noProblems = true; int length = referenceContext.superInterfaces.length; @@ -651,7 +652,8 @@ public class ClassScope extends Scope { noProblems = false; continue nextInterface; } - referenceContext.superInterfaces[i].binding = superInterface; + + referenceContext.superInterfaces[i].resolvedType = superInterface; // only want to reach here when no errors are reported interfaceBindings[count++] = superInterface; } @@ -683,8 +685,8 @@ public class ClassScope extends Scope { private void connectTypeHierarchyWithoutMembers() { // must ensure the imports are resolved if (parent instanceof CompilationUnitScope) { - if (((CompilationUnitScope) parent).imports == null) - ((CompilationUnitScope) parent).checkAndSetImports(); +// if (((CompilationUnitScope) parent).imports == null) +// ((CompilationUnitScope) parent).checkAndSetImports(); } else if (parent instanceof ClassScope) { // ensure that the enclosing type has already been checked ((ClassScope) parent).connectTypeHierarchyWithoutMembers(); @@ -857,8 +859,7 @@ public class ClassScope extends Scope { } /* Answer the reference type of this scope. - * - * i.e. the nearest enclosing type of this scope. + * It is the nearest enclosing type of this scope. */ public TypeDeclaration referenceType() { return referenceContext; @@ -871,4 +872,4 @@ public class ClassScope extends Scope { else return "--- Class Scope ---\n\n Binding not initialized" ; //$NON-NLS-1$ } -} \ No newline at end of file +}