diff options
author | aclement <aclement> | 2005-12-04 13:54:20 +0000 |
---|---|---|
committer | aclement <aclement> | 2005-12-04 13:54:20 +0000 |
commit | 278718a6d3bd0c15ebdb9fcf149811575fc99454 (patch) | |
tree | 5d553f288df206e78f6121c3f3a31fb169fa0a8c /org.aspectj.ajdt.core | |
parent | b17970f20c9040c3455a02b353a8e7fbc1914024 (diff) | |
download | aspectj-278718a6d3bd0c15ebdb9fcf149811575fc99454.tar.gz aspectj-278718a6d3bd0c15ebdb9fcf149811575fc99454.zip |
fixes for 119019
Diffstat (limited to 'org.aspectj.ajdt.core')
3 files changed, 106 insertions, 3 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java index 5ed1217ee..1eda57c45 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java @@ -29,9 +29,11 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.ast.Statement; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeReference; import org.aspectj.org.eclipse.jdt.internal.compiler.codegen.CodeStream; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ArrayBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.BaseTypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.MethodScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.parser.Parser; import org.aspectj.weaver.AjAttribute; @@ -57,6 +59,7 @@ import org.aspectj.weaver.UnresolvedType; */ public class InterTypeFieldDeclaration extends InterTypeDeclaration { public Expression initialization; + private TypeBinding realFieldType; //public InterTypeFieldBinding interBinding; public InterTypeFieldDeclaration(CompilationResult result, TypeReference onType) { @@ -80,7 +83,6 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { "static inter-type field on interface not supported"); ignoreFurtherInvestigation = true; } - if (Modifier.isStatic(declaredModifiers) && typeVariableAliases!=null && typeVariableAliases.size()>0 && onTypeBinding.isGenericType()) { scope.problemReporter().signalError(sourceStart,sourceEnd, "static intertype field declarations cannot refer to type variables from the target generic type"); @@ -119,7 +121,58 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { aae.sourceEnd = initialization.sourceEnd; aae.dimensions = new Expression[arrayType.dimensions]; initialization = aae; + } /*else if (initialization!=null) { + MethodScope initializationScope = this.scope; + TypeBinding fieldType = realFieldType; + TypeBinding initializationType; + this.initialization.setExpectedType(fieldType); // needed in case of generic method invocation + if (this.initialization instanceof ArrayInitializer) { + + if ((initializationType = this.initialization.resolveTypeExpecting(initializationScope, fieldType)) != null) { + ((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationType; + this.initialization.computeConversion(initializationScope, fieldType, initializationType); + } + } +// System.err.println("i=>"+initialization); +// System.err.println("sasuages=>"+initialization.resolvedType); +// //initializationType = initialization.resolveType(initializationScope); +// System.err.println("scope=>"+initializationScope); + + else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) { + + if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError() + initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType); + if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType) + || (fieldType.isBaseType() && BaseTypeBinding.isWidening(fieldType.id, initializationType.id)) + || initializationType.isCompatibleWith(fieldType)) { + initialization.computeConversion(initializationScope, fieldType, initializationType); + if (initializationType.needsUncheckedConversion(fieldType)) { + initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType); + } + } else if (initializationScope.isBoxingCompatibleWith(initializationType, fieldType) + || (initializationType.isBaseType() // narrowing then boxing ? + && initializationScope.compilerOptions().sourceLevel >= JDK1_5 // autoboxing + && !fieldType.isBaseType() + && initialization.isConstantValueOfTypeAssignableToType(initializationType, initializationScope.environment().computeBoxingType(fieldType)))) { + this.initialization.computeConversion(initializationScope, fieldType, initializationType); + } else { + initializationScope.problemReporter().typeMismatchError(initializationType, fieldType, this); + } + // if (this.binding.isFinal()){ // cast from constant actual type to variable type + // this.binding.setConstant(this.initialization.constant.castTo((this.binding.returnType.id << 4) + this.initialization.constant.typeID())); + // } + // } else { + // this.binding.setConstant(NotAConstant); + } + // } + + */ + + + + + ////////////////////// if (initialization == null) { @@ -172,6 +225,55 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { } + /* + public void resolveStatements() { + super.resolveStatements(); + +// if (initialization!=null) { +// MethodScope initializationScope = this.scope; +// TypeBinding fieldType = realFieldType; +// TypeBinding initializationType; +// this.initialization.setExpectedType(fieldType); // needed in case of generic method invocation +// if (this.initialization instanceof ArrayInitializer) { +// +// if ((initializationType = this.initialization.resolveTypeExpecting(initializationScope, fieldType)) != null) { +// ((ArrayInitializer) this.initialization).binding = (ArrayBinding) initializationType; +// this.initialization.computeConversion(initializationScope, fieldType, initializationType); +// } +// } +//// System.err.println("i=>"+initialization); +//// System.err.println("sasuages=>"+initialization.resolvedType); +//// //initializationType = initialization.resolveType(initializationScope); +//// System.err.println("scope=>"+initializationScope); +// +// else if ((initializationType = this.initialization.resolveType(initializationScope)) != null) { +// +// if (fieldType != initializationType) // must call before computeConversion() and typeMismatchError() +// initializationScope.compilationUnitScope().recordTypeConversion(fieldType, initializationType); +// if (this.initialization.isConstantValueOfTypeAssignableToType(initializationType, fieldType) +// || (fieldType.isBaseType() && BaseTypeBinding.isWidening(fieldType.id, initializationType.id)) +// || initializationType.isCompatibleWith(fieldType)) { +// initialization.computeConversion(initializationScope, fieldType, initializationType); +// if (initializationType.needsUncheckedConversion(fieldType)) { +// initializationScope.problemReporter().unsafeTypeConversion(this.initialization, initializationType, fieldType); +// } +// } else if (initializationScope.isBoxingCompatibleWith(initializationType, fieldType) +// || (initializationType.isBaseType() // narrowing then boxing ? +// && initializationScope.compilerOptions().sourceLevel >= JDK1_5 // autoboxing +// && !fieldType.isBaseType() +// && initialization.isConstantValueOfTypeAssignableToType(initializationType, initializationScope.environment().computeBoxingType(fieldType)))) { +// this.initialization.computeConversion(initializationScope, fieldType, initializationType); +// } else { +// initializationScope.problemReporter().typeMismatchError(initializationType, fieldType, this); +// } +// // if (this.binding.isFinal()){ // cast from constant actual type to variable type +// // this.binding.setConstant(this.initialization.constant.castTo((this.binding.returnType.id << 4) + this.initialization.constant.typeID())); +// // } +// // } else { +// // this.binding.setConstant(NotAConstant); +// }} + + }*/ public EclipseTypeMunger build(ClassScope classScope) { EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope); resolveOnType(classScope); @@ -214,6 +316,7 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { ResolvedMember me = myMunger.getInitMethod(aspectType); this.selector = binding.selector = me.getName().toCharArray(); + this.realFieldType = this.binding.returnType; this.binding.returnType = TypeBinding.VoidBinding; //??? all other pieces should already match diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java index fd902bcff..d9309f6d3 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/Ajc.java @@ -80,7 +80,7 @@ public class Ajc { private int incrementalStage = 10; private boolean shouldEmptySandbox = true; private AjcCommandController controller; - private static boolean verbose = System.getProperty("org.aspectj.tools.ajc.Ajc.verbose","false").equals("true"); + private static boolean verbose = true;//System.getProperty("org.aspectj.tools.ajc.Ajc.verbose","false").equals("true"); /** * Constructs a new Ajc instance, with a new AspectJ compiler diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java index d498254bd..2be687d62 100644 --- a/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java +++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/tools/ajc/AjcTestCase.java @@ -92,7 +92,7 @@ public class AjcTestCase extends TestCase { public final static PrintStream out = System.out; private final static DelegatingOutputStream delegatingErr; private final static DelegatingOutputStream delegatingOut; - public final static boolean DEFAULT_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose",false); + public final static boolean DEFAULT_VERBOSE = true;//getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose",false); public final static boolean DEFAULT_ERR_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose.err",DEFAULT_VERBOSE); public final static boolean DEFAULT_OUT_VERBOSE = getBoolean("org.aspectj.tools.ajc.AjcTestCase.verbose.out",DEFAULT_VERBOSE); |