From b03b2426fc26455aa7af2077a6b12146175fdd88 Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 22 Aug 2005 16:55:51 +0000 Subject: [PATCH] genericitds: scope can now lookup type variables when referenced via the alias used in the ITD --- .../compiler/lookup/InterTypeScope.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java index 82a4d7595..6ebf5dd36 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/InterTypeScope.java @@ -13,16 +13,21 @@ package org.aspectj.ajdt.internal.compiler.lookup; +import java.util.List; + import org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ClassScope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.Scope; import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding; +import org.aspectj.org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding; import org.aspectj.weaver.BCException; public class InterTypeScope extends ClassScope { ReferenceBinding onType; + List aliases; public InterTypeScope(Scope parent, ReferenceBinding onType) { super(parent, null); @@ -31,6 +36,11 @@ public class InterTypeScope extends ClassScope { this.onType = onType; } + public InterTypeScope(Scope parent, ReferenceBinding rb, List list) { + this(parent,rb); + this.aliases = list; + } + // this method depends on the fact that BinaryTypeBinding extends SourceTypeBinding private SourceTypeBinding makeSourceTypeBinding(ReferenceBinding onType) { if (onType instanceof SourceTypeBinding) return (SourceTypeBinding)onType; @@ -38,7 +48,10 @@ public class InterTypeScope extends ClassScope { ReferenceBinding rb = ((ParameterizedTypeBinding)onType).type; if (rb instanceof SourceTypeBinding) return (SourceTypeBinding)rb; else throw new BCException("In parameterized type "+onType+", can't handle reference binding "+rb); + } else if (onType instanceof ProblemReferenceBinding) { + return null; } + throw new BCException("can't handle: " + onType); } @@ -49,7 +62,21 @@ public class InterTypeScope extends ClassScope { public int addDepth() { return 0; } + + public TypeVariableBinding findTypeVariable(char[] name, SourceTypeBinding sourceType) { + int aliased = (aliases==null?-1:aliases.indexOf(new String(name))); + if (aliased!=-1) { + if (aliased>sourceType.typeVariables.length || sourceType.typeVariables.length==0) { + TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(),null,0); + return tvb; + // error is going to be reported by someone else! + } + return sourceType.typeVariables()[aliased]; + } else { + return sourceType.getTypeVariable(name); + } + } } -- 2.39.5