From: aclement Date: Fri, 12 Aug 2005 10:57:38 +0000 (+0000) Subject: genericitds: on first construction of the ITD, it builds some 'placeholder' type... X-Git-Tag: V1_5_0M3~145 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=329a179ced983545db124b4eb92984e0c8d79a07;p=aspectj.git genericitds: on first construction of the ITD, it builds some 'placeholder' type parameters to keep the eclipse compiler happy, these will be replaced later by the InterTypeMemberFinder when the compiler asks for the field (if anyone uses it...) --- 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 464f8f177..c17e57837 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 @@ -18,6 +18,7 @@ import java.lang.reflect.Modifier; import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; import org.aspectj.ajdt.internal.compiler.lookup.EclipseTypeMunger; import org.aspectj.weaver.*; +import org.aspectj.org.eclipse.jdt.core.compiler.CharOperation; import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile; import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult; import org.aspectj.org.eclipse.jdt.internal.compiler.ast.*; @@ -41,6 +42,23 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { public InterTypeFieldDeclaration(CompilationResult result, TypeReference onType) { super(result, onType); + if (onType!=null && onType instanceof ParameterizedSingleTypeReference) { + // Here we fill in the type parameters with *something* so that the compiler doesn't + // think there is a missing type. For example, if the declaration is 'List Base.i' + // then we need to put in a type parameter called 'Z' so that the compiler understands + // we don't mean a type called 'Z'. + ParameterizedSingleTypeReference paramRef = (ParameterizedSingleTypeReference) onType; + // The type arguments are SingleTypeReferences - they were transformed when the ITD + // was built from type parameters to get them through the parser. Here we know + // what they are. + TypeReference[] rb = paramRef.typeArguments; + typeParameters = new TypeParameter[rb.length]; + for (int i = 0; i < rb.length; i++) { + TypeReference reference = rb[i]; + typeParameters[i] = new TypeParameter(); + typeParameters[i].name = CharOperation.toString(rb[i].getTypeName()).toCharArray(); + } + } } @@ -60,8 +78,13 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { "static inter-type field on interface not supported"); ignoreFurtherInvestigation = true; } - } + if (Modifier.isStatic(declaredModifiers) && typeParameters!=null && typeParameters.length>0 && onTypeBinding.isGenericType()) { + scope.problemReporter().signalError(sourceStart,sourceEnd, + "static intertype field declarations cannot refer to type variables from the target generic type"); + } + + } public void resolve(ClassScope upperScope) { if (munger == null) ignoreFurtherInvestigation = true; @@ -178,7 +201,7 @@ public class InterTypeFieldDeclaration extends InterTypeDeclaration { declaredModifiers, world.fromBinding(binding.returnType), new String(declaredSelector), UnresolvedType.NONE); - NewFieldTypeMunger myMunger = new NewFieldTypeMunger(sig, null); + NewFieldTypeMunger myMunger = new NewFieldTypeMunger(sig, null, phantomTypeVariableToRealIndex); setMunger(myMunger); ResolvedType aspectType = world.fromEclipse(classScope.referenceContext.binding); ResolvedMember me =