1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jan 03 17:18:10 2012 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Wed Jan 11 18:23:24 2012 +0000 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -3600,39 +3600,44 @@ 1.11 1.12 @Override 1.13 public Type visitCapturedType(CapturedType t, Void s) { 1.14 - Type bound = visitWildcardType(t.wildcard, null); 1.15 - return (bound.contains(t)) ? 1.16 - erasure(bound) : 1.17 - bound; 1.18 + Type w_bound = t.wildcard.type; 1.19 + Type bound = w_bound.contains(t) ? 1.20 + erasure(w_bound) : 1.21 + visit(w_bound); 1.22 + return rewriteAsWildcardType(visit(bound), t.wildcard.bound, t.wildcard.kind); 1.23 } 1.24 1.25 @Override 1.26 public Type visitTypeVar(TypeVar t, Void s) { 1.27 if (rewriteTypeVars) { 1.28 - Type bound = high ? 1.29 - (t.bound.contains(t) ? 1.30 + Type bound = t.bound.contains(t) ? 1.31 erasure(t.bound) : 1.32 - visit(t.bound)) : 1.33 - syms.botType; 1.34 - return rewriteAsWildcardType(bound, t); 1.35 + visit(t.bound); 1.36 + return rewriteAsWildcardType(bound, t, EXTENDS); 1.37 + } else { 1.38 + return t; 1.39 } 1.40 - else 1.41 - return t; 1.42 } 1.43 1.44 @Override 1.45 public Type visitWildcardType(WildcardType t, Void s) { 1.46 - Type bound = high ? t.getExtendsBound() : 1.47 - t.getSuperBound(); 1.48 - if (bound == null) 1.49 - bound = high ? syms.objectType : syms.botType; 1.50 - return rewriteAsWildcardType(visit(bound), t.bound); 1.51 + Type bound2 = visit(t.type); 1.52 + return t.type == bound2 ? t : rewriteAsWildcardType(bound2, t.bound, t.kind); 1.53 } 1.54 1.55 - private Type rewriteAsWildcardType(Type bound, TypeVar formal) { 1.56 - return high ? 1.57 - makeExtendsWildcard(B(bound), formal) : 1.58 - makeSuperWildcard(B(bound), formal); 1.59 + private Type rewriteAsWildcardType(Type bound, TypeVar formal, BoundKind bk) { 1.60 + switch (bk) { 1.61 + case EXTENDS: return high ? 1.62 + makeExtendsWildcard(B(bound), formal) : 1.63 + makeExtendsWildcard(syms.objectType, formal); 1.64 + case SUPER: return high ? 1.65 + makeSuperWildcard(syms.botType, formal) : 1.66 + makeSuperWildcard(B(bound), formal); 1.67 + case UNBOUND: return makeExtendsWildcard(syms.objectType, formal); 1.68 + default: 1.69 + Assert.error("Invalid bound kind " + bk); 1.70 + return null; 1.71 + } 1.72 } 1.73 1.74 Type B(Type t) {