/*******************************************************************************
- * 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;
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 {
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())
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;
}
// 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);
/*
problemReporter().illegalModifierForLocalInterface(sourceType);
*/
} else {
- int unexpectedModifiers = ~(AccPublic | AccAbstract | AccInterface | AccStrictfp);
+ int unexpectedModifiers = ~(AccPublic | AccAbstract | AccInterface);// | AccStrictfp);
if ((realModifiers & unexpectedModifiers) != 0)
problemReporter().illegalModifierForInterface(sourceType);
}
// 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);
}
// 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);
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;
}
*/
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
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
}
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;
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;
}
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();
}
/* 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;
else
return "--- Class Scope ---\n\n Binding not initialized" ; //$NON-NLS-1$
}
-}
\ No newline at end of file
+}