- Location:
- /trunk/gj/src/gjc/v6
- Files:
-
- 11 added
- 6 edited
-
code/CJByteCodes.java (added)
-
code/CJClassReader.java (added)
-
code/CJClassWriter.java (added)
-
code/CompleteClassReader.java (modified) (1 diff)
-
code/Scope.java (modified) (1 diff)
-
code/Symbol.java (modified) (6 diffs)
-
code/Type.java (modified) (23 diffs)
-
comp/Attr.java (modified) (16 diffs)
-
comp/AttrContext.java (added)
-
comp/Check.java (modified) (9 diffs)
-
comp/ConstFold.java (added)
-
comp/Enter.java (added)
-
comp/Env.java (added)
-
comp/Flow.java (added)
-
comp/Gen.java (added)
-
comp/Infer.java (added)
-
comp/Items.java (added)
Legend:
- Unmodified
- Added
- Removed
-
/trunk/gj/src/gjc/v6/code/CompleteClassReader.java
r20 r30 25 25 26 26 public CompleteClassReader(Hashtable<String,String> options) { 27 super(options, 28 // JavaParty: 29 false 30 ); 27 super(options); 31 28 } 32 29 -
/trunk/gj/src/gjc/v6/code/Scope.java
r20 r30 60 60 * given table. table's length must be an exponent of 2. 61 61 */ 62 privateScope(Scope next, Symbol owner, Entry[] table) {62 Scope(Scope next, Symbol owner, Entry[] table) { 63 63 this.next = next; 64 64 this.owner = owner; -
/trunk/gj/src/gjc/v6/code/Symbol.java
r20 r30 121 121 public Type externalType() { 122 122 Type t = erasure(); 123 if (name == Names.init && owner. isNested()) {123 if (name == Names.init && owner.hasOuterInstance()) { 124 124 Type this0type = owner.type.outer().erasure(); 125 125 return new MethodType( … … 176 176 */ 177 177 public boolean isNested() { 178 return type.outer().tag == CLASS && (flags() & INTERFACE) == 0; 178 return (flags_field & INTERFACE) == 0 && type.outer().tag == CLASS; 179 } 180 181 /** An inner class has an outer instance it is nested and NOTHIS0 is not set 182 */ 183 public boolean hasOuterInstance() { 184 return isNested() && (flags() & NOTHIS0) == 0; 179 185 } 180 186 … … 216 222 } 217 223 224 public Scope members() { 225 return null; 226 } 227 218 228 /** A class for type symbols. Type variables are represented by instances 219 229 * of this class, classes and packages by instances of subclasses. … … 227 237 public String toString() { 228 238 return "type variable " + name; 229 }230 231 public Scope members() {232 return null;233 239 } 234 240 … … 418 424 return true; 419 425 } else if ((base.flags() & INTERFACE) != 0) { 420 for ( List<Type> is = type.interfaces();421 is.nonEmpty();422 is = is.tail)423 if (is.head.tsym.subclass(base)) return true;424 return false;426 for (Type t = type; t.tag == CLASS; t = t.supertype()) 427 for (List<Type> is = t.interfaces(); 428 is.nonEmpty(); 429 is = is.tail) 430 if (is.head.tsym.subclass(base)) return true; 425 431 } else { 426 Type t = type.supertype(); 427 while (t.tag == CLASS && t.tsym != base) t = t.supertype(); 428 return t.tag == CLASS; 432 for (Type t = type; t.tag == CLASS; t = t.supertype()) 433 if (t.tsym == base) return true; 429 434 } 435 return false; 430 436 } 431 437 … … 587 593 e.scope != null; 588 594 e = e.next()) { 589 if (overrides(e.sym, origin)) 590 // && e.sym.flags() & SYNTHETIC) == 0) 591 return (MethodSymbol)e.sym; 595 if (e.sym.kind == MTH) { 596 MethodSymbol m = (MethodSymbol) e.sym; 597 if (m.overrides(this, origin) && 598 (m.flags() & SYNTHETIC) == 0) return m; 599 } 592 600 } 593 601 } -
/trunk/gj/src/gjc/v6/code/Type.java
r20 r30 54 54 return t; 55 55 } 56 57 /** If this is a constant type, return its underlying type. 58 * Otherwise, return the type itself. 59 */ 60 public Type baseType() { 61 if (constValue == null) return this; 62 else return tsym.type; 63 } 56 64 65 /** Return the base types of a list of types. 66 */ 67 public static List<Type> baseTypes(List<Type> types) { 68 if (types.nonEmpty()) { 69 Type t = types.head.baseType(); 70 List<Type> ts = baseTypes(types.tail); 71 if (t != types.head || ts != types.tail) 72 return new List<Type>(t, ts); 73 } 74 return types; 75 } 76 57 77 /** convert to string 58 78 */ … … 320 340 return this.bound().castableTo(that); 321 341 case ALL: 322 return t rue;342 return this.subType(that); 323 343 default: 324 344 throw new InternalError(); 325 345 } 346 } 347 348 /** Return the member class of this type with given name, 349 * or null if none exists. 350 */ 351 public TypeSymbol memberClass(Name name) { 352 return null; 326 353 } 327 354 … … 395 422 public static final Type errType = new ErrorType(null); 396 423 397 static void initType(Type type, String name) { 398 ClassSymbol c = new ClassSymbol( 399 PUBLIC, Name.fromString(name), type, Symbol.emptyPackage); 424 static void initType(Type type, ClassSymbol c) { 400 425 type.tsym = c; 401 426 typeOfTag[type.tag] = type; 427 } 428 429 static void initType(Type type, String name) { 430 initType( 431 type, 432 new ClassSymbol( 433 PUBLIC, Name.fromString(name), type, Symbol.emptyPackage)); 402 434 } 403 435 … … 417 449 initType(booleanType, "boolean", "Boolean"); 418 450 initType(voidType, "void", "Void"); 419 initType(allType, " <null>");420 errType.tsym = Symbol.errSymbol;451 initType(allType, "*"); 452 initType(errType, Symbol.errSymbol); 421 453 } 422 454 … … 435 467 public List<Type> typarams_field; 436 468 469 /** A cache variable for the type parameters of this type, 470 * appended to all parameters of its enclosing class. 471 */ 472 public List<Type> allparams_field; 473 437 474 /** The supertype of this class (to be set once class is loaded) 438 475 */ … … 447 484 this.outer_field = outer; 448 485 this.typarams_field = typarams; 486 this.allparams_field = null; 449 487 this.supertype_field = null; 450 488 this.interfaces_field = null; … … 457 495 } 458 496 497 public Type baseType() { 498 if (constValue == null) return this; 499 else return tsym.type; 500 } 501 459 502 public String toString() { 460 503 StringBuffer buf = new StringBuffer(); 461 if (outer().tag == CLASS) {504 if (outer().tag != NONE) { 462 505 buf.append(outer().toString()); 463 506 buf.append("."); … … 513 556 } else if (this == tsym.type) { 514 557 supertype_field = st; 515 } else if (typarams_field.isEmpty()) {516 // in this case, `this' is an erasure of a parameterized type517 supertype_field = st.erasure();518 558 } else { 519 supertype_field = 520 st.subst(tsym.type.typarams(), typarams_field); 559 List<Type> ownparams = allParams(); 560 List<Type> symparams = tsym.type.allParams(); 561 if (ownparams.isEmpty()) supertype_field = st.erasure(); 562 else supertype_field = st.subst(symparams, ownparams); 521 563 } 522 564 } … … 532 574 } else if (this == tsym.type) { 533 575 interfaces_field = is; 534 } else if (typarams_field.isEmpty()) {535 // in this case, `this' is an erasure of a parameterized type536 interfaces_field = erasure(is);537 576 } else { 538 interfaces_field = 539 subst(is, tsym.type.typarams(), typarams_field); 577 List<Type> ownparams = allParams(); 578 List<Type> symparams = tsym.type.allParams(); 579 if (ownparams.isEmpty()) interfaces_field = erasure(is); 580 else interfaces_field = subst(is, symparams, ownparams); 540 581 } 541 582 } … … 544 585 545 586 public List<Type> allParams() { 546 return typarams().prepend(outer().typarams()); 587 if (allparams_field == null) { 588 allparams_field = typarams().prepend(outer().allParams()); 589 } 590 return allparams_field; 547 591 } 548 592 … … 567 611 568 612 public Type asOuterSuper(Symbol sym) { 569 Type s = this.asSuper(sym);570 Type t = this.outer();571 while (s == null && t.tag == CLASS) {572 s = t.asSuper(sym);613 Type t = this; 614 do { 615 Type s = t.asSuper(sym); 616 if (s != null) return s; 573 617 t = t.outer(); 574 } 575 return s;618 } while (t.tag == CLASS); 619 return null; 576 620 } 577 621 … … 592 636 593 637 public Type memberType(Symbol sym) { 638 // System.out.print(this + ".memberType " + sym + " = ");//DEBUG 594 639 Symbol owner = sym.owner; 595 if ((sym.flags() & STATIC) == 0 && owner.type.isParameterized()) { 596 Type base = this.asSuper(owner); 640 int flags = sym.flags(); 641 if (((flags & STATIC) == 0 || (flags & INTERFACE) != 0) && 642 owner.type.isParameterized()) { 643 Type base = this.asOuterSuper(owner); 597 644 if (base != null) { 645 // System.out.print("[base = " + base + "]");//DEBUG 598 646 List<Type> ownerParams = owner.type.allParams(); 599 647 List<Type> baseParams = base.allParams(); … … 601 649 if (baseParams.isEmpty()) { 602 650 // then base is a raw type 651 // System.out.println(sym.type.erasure());//DEBUG 603 652 return sym.type.erasure(); 604 653 } else { 654 // System.out.println(sym.type.subst(ownerParams, baseParams));//DEBUG 655 while (ownerParams.length() > baseParams.length()) 656 ownerParams = ownerParams.tail; 605 657 return sym.type.subst(ownerParams, baseParams); 606 658 } … … 608 660 } 609 661 } 662 // System.out.println(sym.type);//DEBUG 610 663 return sym.type; 611 664 } … … 616 669 List<Type> typarams1 = subst(typarams, from, to); 617 670 Type outer1 = outer.subst(from, to); 618 if (typarams1 == typarams && outer1 == outer) return this; 619 else return new ClassType(outer1, typarams1, tsym); 671 if (typarams1 == typarams && outer1 == outer) { 672 return this; 673 } else { 674 TypeSymbol tsym1 = tsym; 675 if (outer.tsym != outer1.tsym && tsym.isNested()) { 676 TypeSymbol tsym2 = outer1.memberClass(tsym.name); 677 if (tsym2 != null) { 678 tsym1 = tsym2; 679 if (outer1.tag == CLASS) { 680 outer1 = outer1.asSuper(tsym1.type.outer().tsym); 681 } 682 } 683 } 684 return new ClassType(outer1, typarams1, tsym1); 685 } 620 686 } 621 687 622 688 public boolean isErroneous() { 623 689 return outer().isErroneous() || isErroneous(typarams()); 690 } 691 692 public boolean isParameterized() { 693 return allParams().tail != null; 694 // optimization, was: allParams().nonEmpty(); 624 695 } 625 696 … … 630 701 public boolean isRaw() { 631 702 return 632 tsym.type.isParameterized() && 633 (typarams().isEmpty() && 634 tsym.type.typarams().nonEmpty() 635 || 636 outer().isRaw()); 637 } 638 639 public boolean isParameterized() { 640 if (tsym.completer != null) tsym.complete(); 641 return 642 typarams_field.tail != null 643 /*inlined: typarams_field.nonEmpty()*/ || 644 outer_field.tag == CLASS && outer_field.isParameterized(); 703 this != tsym.type && // fast special case 704 tsym.type.allParams().nonEmpty() && 705 allParams().isEmpty() && // fast special case 706 (tsym.type.typarams().nonEmpty() && typarams().isEmpty() || 707 outer().isRaw()); // precise condition, slow to check; 645 708 } 646 709 … … 675 738 return true; 676 739 } else if (this.tsym == that.tsym) { 677 return !that.isParameterized() || this.genType(that); 740 return 741 (!that.isParameterized() || 742 genTypes(this.typarams(), that.typarams())) && 743 this.outer().subType(that.outer()); 678 744 } else { 679 745 Type st = supertype(); … … 688 754 } 689 755 756 public TypeSymbol memberClass(Name name) { 757 Type t = this; 758 while (t.tag == CLASS) { 759 Scope.Entry e = t.tsym.members().lookup(name); 760 while (e.scope != null && e.sym.kind != TYP) 761 e = e.next(); 762 if (e.scope != null) return (TypeSymbol) e.sym; 763 t = t.supertype(); 764 } 765 return null; 766 } 767 690 768 public boolean castableTo(Type that) { 691 769 List<Type> thatParams = that.allParams(); … … 697 775 || 698 776 (that.subType(this) && 699 thatParams.subset(this.allParams())) 777 (that.tag == ARRAY || 778 that.tsym.type == that /*fast special case*/ || 779 that.sameType(this.asSub(that.tsym)))) 700 780 || 701 781 that.tag == CLASS && thatParams.isEmpty() && … … 740 820 } 741 821 822 public boolean isParameterized() { 823 return elemtype.isParameterized(); 824 } 825 742 826 public boolean isRaw() { 743 827 return elemtype.isRaw(); 744 }745 746 public boolean isParameterized() {747 return elemtype.isParameterized();748 828 } 749 829 … … 945 1025 } 946 1026 947 public boolean isErroneous() {948 return bound != null && bound.isErroneous();949 }950 951 1027 public Type erasure() { 952 1028 return bound.erasure(); 1029 } 1030 1031 public TypeSymbol memberClass(Name name) { 1032 return bound().memberClass(name); 953 1033 } 954 1034 } … … 986 1066 987 1067 public boolean isErroneous() { 988 return isErroneous(tvars) ||qtype.isErroneous();1068 return qtype.isErroneous(); 989 1069 } 990 1070 … … 1000 1080 return 1001 1081 that.tag == FORALL && 1082 sameTypes( 1083 bounds(), 1084 subst(((ForAll)that).bounds(), ((ForAll)that).tvars, tvars)) && 1002 1085 qtype.sameArgs( 1003 1086 ((ForAll)that).qtype.subst(((ForAll)that).tvars, tvars)); 1087 } 1088 1089 private List<Type> bounds() { 1090 ListBuffer<Type> b = new ListBuffer<Type>(); 1091 for (List<Type> l = tvars; l.nonEmpty(); l = l.tail) 1092 b.append(l.head.bound()); 1093 return b.toList(); 1004 1094 } 1005 1095 -
/trunk/gj/src/gjc/v6/comp/Attr.java
r20 r30 107 107 */ 108 108 void warnDeprecated(int pos, Symbol sym) { 109 if (! enter.compiled.contains(sym.enclClass().fullname))109 if (!chk.compiled.contains(sym.enclClass().fullname)) 110 110 log.warning(pos, sym + sym.location() + " has been deprecated"); 111 111 } … … 115 115 Symbol thisSym(Env<AttrContext> env) { 116 116 return rs.resolveSelf( 117 Position.NOPOS, env, env.enclClass.sym, Names._this );117 Position.NOPOS, env, env.enclClass.sym, Names._this, true); 118 118 } 119 119 … … 185 185 * for a method `m' defined in an interface 186 186 */ 187 privatevoid addAbstractMethod(ClassDef cd,187 void addAbstractMethod(ClassDef cd, 188 188 MethodSymbol m, 189 189 Env<AttrContext> env) { … … 433 433 else if (thentype.tag < INT && elsetype.tag == INT && 434 434 elsetype.assignable(thentype)) 435 return thentype ;435 return thentype.baseType(); 436 436 else if (elsetype.tag < INT && thentype.tag == INT && 437 437 thentype.assignable(elsetype)) 438 return elsetype ;438 return elsetype.baseType(); 439 439 else if (thentype.tag <= DOUBLE && elsetype.tag <= DOUBLE) { 440 440 for (int i = BYTE; i <= DOUBLE; i++) { … … 448 448 return syms.stringType; 449 449 } else if (thentype.subType(elsetype)) { 450 return elsetype ;450 return elsetype.baseType(); 451 451 } else { 452 452 chk.checkType(pos, elsetype, thentype); 453 return thentype; 454 } 455 } 453 return thentype.baseType(); 454 } 455 } 456 456 457 457 458 public Type _case(Exec tree, Env<AttrContext> env) { … … 653 654 TreeInfo.setSymbol(clazzid, TreeInfo.symbol(clazzid1)); 654 655 clazzid.type = ((Ident)clazzid).sym.type; 656 } else if ((clazztype.tsym.flags() & INTERFACE) == 0 && 657 clazztype.outer().tag == CLASS) { 658 rs.resolveSelf( 659 tree.pos, env, clazztype.outer().tsym, Names._this, false); 655 660 } 656 661 … … 659 664 660 665 if (clazztype.tag == CLASS) { 661 // Type site = clazztype.tsym.type;662 // List<Type> typarams = clazztype.typarams();663 //664 // if (site.typarams().nonEmpty() && typarams.isEmpty())665 // site = site.erasure();666 667 666 // resolve constructor, if not abstract 668 667 if (cdef == null && … … 705 704 attribStat(cdef, env.dup(tree)); 706 705 // new Pretty().printStat(cdef);//DEBUG 706 707 // don't pass a this0 to anonymous classes in super calls 708 if (tree.encl == null && env.info.isSelfCall) 709 cdef.sym.flags_field |= NOTHIS0; 707 710 708 711 // if enclosing class is given, … … 931 934 } 932 935 936 if ((sym.flags() & DEPRECATED) != 0) 937 warnDeprecated(tree.pos, sym); 933 938 return checkId(tree, env.enclClass.sym.type, sym, pkind, pt); 934 939 } … … 983 988 env.info.selectSuper = selectSuperPrev; 984 989 } 990 991 if ((sym.flags() & DEPRECATED) != 0) 992 warnDeprecated(tree.pos, sym); 985 993 return checkId(tree, site, sym, pkind, pt); 986 994 } … … 994 1002 * @param pkind the expected kind(s) of the Select expression 995 1003 */ 996 privateSymbol selectSym(Select tree, Type site,997 Env<AttrContext> env, Type pt, int pkind) {1004 Symbol selectSym(Select tree, Type site, 1005 Env<AttrContext> env, Type pt, int pkind) { 998 1006 int pos = tree.pos; 999 1007 Name name = tree.name; … … 1009 1017 pos, env, site, name, Type.emptyList, pt.argtypes()); 1010 1018 } else if (name == Names._this) { 1011 return rs.resolveSelf(pos, env, site.tsym, name );1019 return rs.resolveSelf(pos, env, site.tsym, name, true); 1012 1020 } else if (name == Names._class) { 1013 1021 return new VarSymbol( … … 1060 1068 */ 1061 1069 Type checkId(Tree tree, Type site, Symbol sym, int pkind, Type pt) { 1062 if ((sym.flags() & DEPRECATED) != 0) warnDeprecated(tree.pos, sym);1063 1070 Type owntype; 1064 1071 switch (sym.kind) { … … 1070 1077 site != owntype.outer()) 1071 1078 { 1072 owntype = new ClassType( 1073 site, Type.emptyList, owntype.tsym); 1074 } else if (owntype.typarams().nonEmpty()) { 1079 Type normSite = site; 1080 if (normSite.tag == CLASS) 1081 normSite = site.asOuterSuper(owntype.outer().tsym); 1082 if (normSite != owntype.outer()) 1083 owntype = new ClassType( 1084 normSite, Type.emptyList, owntype.tsym); 1085 } 1086 if (owntype.typarams().nonEmpty()) { 1075 1087 owntype = new ClassType( 1076 1088 owntype.outer(), Type.emptyList, owntype.tsym); … … 1106 1118 (sym.flags() & STATIC) == 0 && 1107 1119 site.tag == CLASS) { 1108 Type s = site.asOuterSuper(sym.owner);1120 Type s = site.asOuterSuper(sym.owner); 1109 1121 if (s != null && 1110 1122 s.isRaw() && … … 1246 1258 if (actuals.length() == formals.length()) { 1247 1259 owntype = new ClassType( 1248 clazztype. tsym.type.outer(), actuals, clazztype.tsym);1260 clazztype.outer(), actuals, clazztype.tsym); 1249 1261 } else { 1250 1262 log.error( -
/trunk/gj/src/gjc/v6/comp/Check.java
r20 r30 32 32 } 33 33 34 /** switch: unchecked option set? 34 /** the set of all compiled classes in this run; maintained from outside 35 */ 36 public Set<Name> compiled = new Set<Name>(); 37 38 /** switch: -unchecked option set? 35 39 */ 36 40 boolean unchecked; … … 109 113 return t.tag == TYPEVAR || t.tag == ARRAY && isTypeVar(t.elemtype()); 110 114 } 115 116 /** Check that type `a' deeply extends type `b'. 117 * That is, check that `a' is a subtype of `b', 118 * and that all inner classes of `a' deeply extend 119 * corresponding inner classes in `b'. 120 */ 121 public boolean checkDeeplyExtends(int pos, boolean reportErrors, 122 Type a, Type b) { 123 if (!a.subType(b)) { 124 log.error(pos, 125 "type parameter " + a + " is not within its bound " + b); 126 return false; 127 } else { 128 return checkDeeplyExtends(pos, reportErrors, a, b, a, b); 129 } 130 } 131 132 /** Inner class extension rule: given a bounding declaration 133 * 134 * d extends T 135 * 136 * and an instance S bound to d, it must hold that 137 * 138 * S deeply extends T[S/d] . 139 * 140 * 141 * DEFINITION: A type S *deeply extends* a type T, if 142 * 143 * S extends T 144 * 145 * and, for all (non-static) class members A of T, 146 * 147 * S.A deeply extends T.A, 148 * S.A has at least the same access priviliges as T.A, and 149 * S.A is not static. 150 * 151 * The class members of a type variable are taken to be the class members 152 * of its bound. 153 * 154 * Note that given declarations 155 * 156 * class G<g extends T> 157 * class F<f extends S> extends G<f> 158 * 159 * we must check that f deeply extends T 160 * (by checking that S deeply extends T). 161 * 162 */ 163 public boolean checkDeeplyExtends(int pos, boolean reportErrors, 164 Type aroot, Type broot, 165 Type a, Type b) { 166 if (a == b) { // fast special case 167 return true; 168 } else if (!a.subType(b)) { 169 if (reportErrors) 170 log.error(pos, 171 "type parameter " + aroot + 172 " is not within its bound " + broot + 173 " since " + a + " is not a subtype of " + b); 174 return false; 175 } else { 176 Scope s = b.tsym.members(); 177 if (s != null) { 178 for (Scope.Entry e = s.elems; e != null; e = e.sibling) { 179 if (e.sym.kind == TYP && 180 (e.sym.flags_field & (STATIC | PRIVATE)) == 0) 181 { 182 Type b1 = b.memberType(e.sym); 183 Type a1 = a.memberType(a.memberClass(e.sym.name)); 184 if ((a1.tsym.flags_field & STATIC) != 0) { 185 if (reportErrors) 186 log.error(pos, 187 "type parameter " + aroot + 188 " is not within its bound " + broot + 189 " since " + a + " is static"); 190 return false; 191 } 192 if (protection(a.tsym.flags_field) > 193 protection(b.tsym.flags_field)) { 194 if (reportErrors) 195 log.error(pos, 196 "type parameter " + aroot + 197 " is not within its bound " + broot + 198 " since " + a + 199 " has weaker access priviliges than " + b); 200 return false; 201 } 202 if (!checkDeeplyExtends( 203 pos, reportErrors, aroot, broot, a1, b1)) 204 { 205 return false; 206 } 207 } 208 } 209 } 210 return true; 211 } 212 } 111 213 112 214 /** check that type t is different from 'void'. … … 193 295 if (sym.owner.owner.kind == PCK || 194 296 (sym.owner.flags_field & STATIC) != 0) mask |= STATIC; 297 if ((flags & INTERFACE) != 0) implicit = STATIC; 195 298 } else { 196 299 mask = ClassFlags; … … 212 315 //should it be deleted here? 213 316 && 317 318 // JavaParty [ 214 319 checkDisjoint(pos, flags, 215 ABSTRACT | INTERFACE,320 ABSTRACT, 216 321 FINAL | NATIVE | SYNCHRONIZED) 322 && 323 checkDisjoint(pos, flags, 324 INTERFACE, 325 FINAL | NATIVE | SYNCHRONIZED | REMOTE) 326 // ] JavaParty 327 217 328 && 218 329 checkDisjoint(pos, flags, … … 284 395 Type bound = forms.head.bound().subst(formals, actuals); 285 396 validate(a); 286 if (!a.type.subType(bound)) 287 log.error(a.pos, 288 "type parameter " + a.type + 289 " is not within bound " + bound); 397 checkDeeplyExtends(tree.pos, true, a.type, bound); 290 398 args = args.tail; 291 399 forms = forms.tail; … … 303 411 public Void _case(Select tree, Void arg) { 304 412 if (tree.type.tag == CLASS) { 305 if (tree.type.outer().tag == CLASS) validate(tree.selected); 413 if (tree.type.outer().tag == CLASS) 414 validate(tree.selected); 415 else if (tree.selected.type.isParameterized()) 416 log.error( 417 tree.pos, 418 "cannot select a static class from a parameterized type"); 419 306 420 if (tree.type.isRaw() && tree.type.allParams().nonEmpty()) 307 421 log.error( … … 495 609 List<Type> mtvars = mt.typarams(); 496 610 List<Type> otvars = ot.typarams(); 497 if (!(mt.restype().subType(ot.restype().subst(otvars, mtvars)))) { 498 typeError(pos, 499 cannotOverride(m, other) + " with incompatible return type", 500 mt.restype(), ot.restype().subst(otvars, mtvars)); 611 Type otres = ot.restype().subst(otvars, mtvars); 612 if (!(mt.restype().subType(otres))) { 613 if ((m.flags() & IPROXY) != 0 && otres.subType(mt.restype())) { 614 ((MethodType)mt).restype = otres; 615 } else { 616 typeError(pos, 617 cannotOverride(m, other) + " with incompatible return type", 618 mt.restype(), ot.restype().subst(otvars, mtvars)); 619 } 501 620 } else if ((origin.flags() & INTERFACE) == 0) { 502 621 List<ClassSymbol> unhandled = unHandled(mt.thrown(), ot.thrown()); … … 513 632 } 514 633 } 515 634 516 635 /** check that this method conforms with any class member method 517 636 * it overrides. … … 549 668 * null if there is none. 550 669 */ 551 privateMethodSymbol firstUndef(ClassSymbol impl, ClassSymbol c) {670 MethodSymbol firstUndef(ClassSymbol impl, ClassSymbol c) { 552 671 MethodSymbol undef = null; 553 672 if (c == impl || (c.flags() & (ABSTRACT | INTERFACE)) != 0) {
Note: See TracChangeset
for help on using the changeset viewer.
