84 methodNotFound = new |
84 methodNotFound = new |
85 ResolveError(ABSENT_MTH, syms.errSymbol, "method not found"); |
85 ResolveError(ABSENT_MTH, syms.errSymbol, "method not found"); |
86 typeNotFound = new |
86 typeNotFound = new |
87 ResolveError(ABSENT_TYP, syms.errSymbol, "type not found"); |
87 ResolveError(ABSENT_TYP, syms.errSymbol, "type not found"); |
88 |
88 |
89 names = Name.Table.instance(context); |
89 names = Names.instance(context); |
90 log = Log.instance(context); |
90 log = Log.instance(context); |
91 chk = Check.instance(context); |
91 chk = Check.instance(context); |
92 infer = Infer.instance(context); |
92 infer = Infer.instance(context); |
93 reader = ClassReader.instance(context); |
93 reader = ClassReader.instance(context); |
94 treeinfo = TreeInfo.instance(context); |
94 treeinfo = TreeInfo.instance(context); |
1536 List<Type> argtypes, List<Type> typeargtypes) { |
1536 List<Type> argtypes, List<Type> typeargtypes) { |
1537 if (argtypes == null) |
1537 if (argtypes == null) |
1538 argtypes = List.nil(); |
1538 argtypes = List.nil(); |
1539 if (typeargtypes == null) |
1539 if (typeargtypes == null) |
1540 typeargtypes = List.nil(); |
1540 typeargtypes = List.nil(); |
1541 if (name != name.table.error) { |
1541 if (name != names.error) { |
1542 KindName kindname = absentKind(kind); |
1542 KindName kindname = absentKind(kind); |
1543 Name idname = name; |
1543 Name idname = name; |
1544 if (kind >= WRONG_MTHS && kind <= ABSENT_MTH) { |
1544 if (kind >= WRONG_MTHS && kind <= ABSENT_MTH) { |
1545 if (isOperator(name)) { |
1545 if (isOperator(name)) { |
1546 log.error(pos, "operator.cant.be.applied", |
1546 log.error(pos, "operator.cant.be.applied", |
1547 name, argtypes); |
1547 name, argtypes); |
1548 return; |
1548 return; |
1549 } |
1549 } |
1550 if (name == name.table.init) { |
1550 if (name == names.init) { |
1551 kindname = KindName.CONSTRUCTOR; |
1551 kindname = KindName.CONSTRUCTOR; |
1552 idname = site.tsym.name; |
1552 idname = site.tsym.name; |
1553 } |
1553 } |
1554 } |
1554 } |
1555 if (kind == WRONG_MTH) { |
1555 if (kind == WRONG_MTH) { |
1561 ws.type.getParameterTypes(), |
1561 ws.type.getParameterTypes(), |
1562 argtypes, |
1562 argtypes, |
1563 kindName(ws.owner), |
1563 kindName(ws.owner), |
1564 ws.owner.type, |
1564 ws.owner.type, |
1565 explanation); |
1565 explanation); |
1566 } else if (site.tsym.name.len != 0) { |
1566 } else if (!site.tsym.name.isEmpty()) { |
1567 if (site.tsym.kind == PCK && !site.tsym.exists()) |
1567 if (site.tsym.kind == PCK && !site.tsym.exists()) |
1568 log.error(pos, "doesnt.exist", site.tsym); |
1568 log.error(pos, "doesnt.exist", site.tsym); |
1569 else { |
1569 else { |
1570 String errKey = getErrorKey("cant.resolve.location", |
1570 String errKey = getErrorKey("cant.resolve.location", |
1571 argtypes, typeargtypes, |
1571 argtypes, typeargtypes, |
1599 /** A name designates an operator if it consists |
1599 /** A name designates an operator if it consists |
1600 * of a non-empty sequence of operator symbols +-~!/*%&|^<>= |
1600 * of a non-empty sequence of operator symbols +-~!/*%&|^<>= |
1601 */ |
1601 */ |
1602 boolean isOperator(Name name) { |
1602 boolean isOperator(Name name) { |
1603 int i = 0; |
1603 int i = 0; |
1604 while (i < name.len && |
1604 while (i < name.getByteLength() && |
1605 "+-~!*/%&|^<>=".indexOf(name.byteAt(i)) >= 0) i++; |
1605 "+-~!*/%&|^<>=".indexOf(name.getByteAt(i)) >= 0) i++; |
1606 return i > 0 && i == name.len; |
1606 return i > 0 && i == name.getByteLength(); |
1607 } |
1607 } |
1608 } |
1608 } |
1609 |
1609 |
1610 /** Resolve error class indicating that a symbol is not accessible. |
1610 /** Resolve error class indicating that a symbol is not accessible. |
1611 */ |
1611 */ |
1637 * if we looked for a method. |
1637 * if we looked for a method. |
1638 */ |
1638 */ |
1639 void report(Log log, DiagnosticPosition pos, Type site, Name name, |
1639 void report(Log log, DiagnosticPosition pos, Type site, Name name, |
1640 List<Type> argtypes, List<Type> typeargtypes) { |
1640 List<Type> argtypes, List<Type> typeargtypes) { |
1641 if (sym.owner.type.tag != ERROR) { |
1641 if (sym.owner.type.tag != ERROR) { |
1642 if (sym.name == sym.name.table.init && sym.owner != site.tsym) |
1642 if (sym.name == names.init && sym.owner != site.tsym) |
1643 new ResolveError(ABSENT_MTH, sym.owner, "absent method " + sym).report( |
1643 new ResolveError(ABSENT_MTH, sym.owner, "absent method " + sym).report( |
1644 log, pos, site, name, argtypes, typeargtypes); |
1644 log, pos, site, name, argtypes, typeargtypes); |
1645 if ((sym.flags() & PUBLIC) != 0 |
1645 if ((sym.flags() & PUBLIC) != 0 |
1646 || (env != null && this.site != null |
1646 || (env != null && this.site != null |
1647 && !isAccessible(env, this.site))) |
1647 && !isAccessible(env, this.site))) |
1721 else if (pair.sym2.kind == AMBIGUOUS) |
1721 else if (pair.sym2.kind == AMBIGUOUS) |
1722 pair = (AmbiguityError)pair.sym2; |
1722 pair = (AmbiguityError)pair.sym2; |
1723 else break; |
1723 else break; |
1724 } |
1724 } |
1725 Name sname = pair.sym1.name; |
1725 Name sname = pair.sym1.name; |
1726 if (sname == sname.table.init) sname = pair.sym1.owner.name; |
1726 if (sname == names.init) sname = pair.sym1.owner.name; |
1727 log.error(pos, "ref.ambiguous", sname, |
1727 log.error(pos, "ref.ambiguous", sname, |
1728 kindName(pair.sym1), |
1728 kindName(pair.sym1), |
1729 pair.sym1, |
1729 pair.sym1, |
1730 pair.sym1.location(site, types), |
1730 pair.sym1.location(site, types), |
1731 kindName(pair.sym2), |
1731 kindName(pair.sym2), |