From: aclement Date: Thu, 3 Feb 2011 02:37:15 +0000 (+0000) Subject: 336136 X-Git-Tag: V1_6_11RC1~16 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c584cedda7f4b25f3d6661f39f4b88f432cf63b4;p=aspectj.git 336136 --- 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 bf1a084a9..f4e6e4df0 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 @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.ajdt.internal.compiler.lookup; import java.util.HashMap; @@ -31,7 +30,8 @@ import org.aspectj.weaver.BCException; public class InterTypeScope extends ClassScope { ReferenceBinding onType; List aliases; - Map /* real type variable > alias letter */ usedAliases; // Used later when reconstructing the resolved member + Map /* real type variable > alias letter */usedAliases; // Used later when reconstructing the + // resolved member public InterTypeScope(Scope parent, ReferenceBinding onType) { super(parent, null); @@ -41,47 +41,53 @@ public class InterTypeScope extends ClassScope { } public InterTypeScope(Scope parent, ReferenceBinding rb, List list) { - this(parent,rb); + this(parent, rb); this.aliases = list; } - + public String getAnyAliasForTypeVariableBinding(TypeVariableBinding tvb) { - if (usedAliases==null) return null; - return (String)usedAliases.get(tvb); + if (usedAliases == null) + return null; + return (String) usedAliases.get(tvb); } // this method depends on the fact that BinaryTypeBinding extends SourceTypeBinding private SourceTypeBinding makeSourceTypeBinding(ReferenceBinding onType) { - if (onType instanceof SourceTypeBinding) return (SourceTypeBinding)onType; + if (onType instanceof SourceTypeBinding) + return (SourceTypeBinding) onType; else if (onType instanceof ParameterizedTypeBinding) { - 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) { + 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; } else if (onType instanceof TypeVariableBinding) { // Problem will have already been reported, cant ITD on a type variable. return null; } - + throw new BCException("can't handle: " + onType); } public SourceTypeBinding invocationType() { return parent.enclosingSourceType(); } - + public int addDepth() { return 0; } - public TypeVariableBinding findTypeVariable(char[] name, SourceTypeBinding sourceType) { + if (sourceType == null) { + return null; + } String variableName = new String(name); - int aliased = (aliases==null?-1:aliases.indexOf(variableName)); - if (aliased!=-1) { - if (aliased>sourceType.typeVariables.length || sourceType.typeVariables.length==0) { - TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(),null,0); + int aliased = (aliases == null ? -1 : aliases.indexOf(variableName)); + if (aliased != -1) { + if (aliased > sourceType.typeVariables.length || sourceType.typeVariables.length == 0) { + TypeVariableBinding tvb = new TypeVariableBinding("fake".toCharArray(), null, 0); tvb.superclass = getJavaLangObject(); tvb.fPackage = new PackageBinding(environment()); return tvb; @@ -89,22 +95,22 @@ public class InterTypeScope extends ClassScope { } TypeVariableBinding tvb = sourceType.typeVariables()[aliased]; tvb.fPackage = sourceType.fPackage; - if (usedAliases==null) usedAliases = new HashMap(); - usedAliases.put(tvb,variableName); + if (usedAliases == null) + usedAliases = new HashMap(); + usedAliases.put(tvb, variableName); return tvb; } else { - TypeVariableBinding variableBinding = sourceType.getTypeVariable(name); - if (variableBinding == null) { // GENERICITDFIX - // Inside generic aspect, might want the type var attached to us - variableBinding = parent.findTypeVariable(name,((ClassScope) parent).referenceContext.binding); - } - return variableBinding; + TypeVariableBinding variableBinding = sourceType.getTypeVariable(name); + if (variableBinding == null) { // GENERICITDFIX + // Inside generic aspect, might want the type var attached to us + variableBinding = parent.findTypeVariable(name, ((ClassScope) parent).referenceContext.binding); + } + return variableBinding; } } public Map getRecoveryAliases() { return usedAliases; } - }