1586 } 1587 List<Type> tvars1 = st1.getTypeArguments(); 1588 List<Type> tvars2 = st2.getTypeArguments(); 1589 List<Type> tvars3 = st3.getTypeArguments(); 1590 Type rt1 = st1.getReturnType(); 1591 Type rt2 = st2.getReturnType(); 1592 Type rt13 = types.subst(st3.getReturnType(), tvars3, tvars1); 1593 Type rt23 = types.subst(st3.getReturnType(), tvars3, tvars2); 1594 boolean compat = 1595 rt13.tag >= CLASS && rt23.tag >= CLASS && 1596 (types.covariantReturnType(rt13, rt1, Warner.noWarnings) && 1597 types.covariantReturnType(rt23, rt2, Warner.noWarnings)); 1598 if (compat) 1599 return true; 1600 } 1601 } 1602 } 1603 return false; 1604 } 1605 1606 /** Check that a given method conforms with any method it overrides. 1607 * @param tree The tree from which positions are extracted 1608 * for errors. 1609 * @param m The overriding method. 1610 */ 1611 void checkOverride(JCTree tree, MethodSymbol m) { 1612 ClassSymbol origin = (ClassSymbol)m.owner; 1613 if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name)) 1614 if (m.overrides(syms.enumFinalFinalize, origin, types, false)) { 1615 log.error(tree.pos(), "enum.no.finalize"); 1616 return; 1617 } 1618 for (Type t = types.supertype(origin.type); t.tag == CLASS; 1619 t = types.supertype(t)) { 1620 TypeSymbol c = t.tsym; 1621 Scope.Entry e = c.members().lookup(m.name); 1622 while (e.scope != null) { 1623 if (m.overrides(e.sym, origin, types, false)) 1624 checkOverride(tree, m, (MethodSymbol)e.sym, origin); 1625 else if (e.sym.kind == MTH && | 1586 } 1587 List<Type> tvars1 = st1.getTypeArguments(); 1588 List<Type> tvars2 = st2.getTypeArguments(); 1589 List<Type> tvars3 = st3.getTypeArguments(); 1590 Type rt1 = st1.getReturnType(); 1591 Type rt2 = st2.getReturnType(); 1592 Type rt13 = types.subst(st3.getReturnType(), tvars3, tvars1); 1593 Type rt23 = types.subst(st3.getReturnType(), tvars3, tvars2); 1594 boolean compat = 1595 rt13.tag >= CLASS && rt23.tag >= CLASS && 1596 (types.covariantReturnType(rt13, rt1, Warner.noWarnings) && 1597 types.covariantReturnType(rt23, rt2, Warner.noWarnings)); 1598 if (compat) 1599 return true; 1600 } 1601 } 1602 } 1603 return false; 1604 } 1605 1606 /** 1607 * Check that a resource is a valid arm resource (e.g. the resource type must be 1608 * a subtype of java.lang.autoCloseable). 1609 * 1610 * @param resource resource tree 1611 */ 1612 void checkArmResource(JCTree resource) { 1613 if (types.asSuper(resource.type, syms.autoCloseableType.tsym) == null) { 1614 typeError(resource.pos(), 1615 diags.fragment("arm.not.applicable.to.type"), 1616 resource.type, 1617 syms.autoCloseableType); 1618 resource.type = types.createErrorType(resource.type); 1619 } 1620 } 1621 1622 /** Check that a given method conforms with any method it overrides. 1623 * @param tree The tree from which positions are extracted 1624 * for errors. 1625 * @param m The overriding method. 1626 */ 1627 void checkOverride(JCTree tree, MethodSymbol m) { 1628 ClassSymbol origin = (ClassSymbol)m.owner; 1629 if ((origin.flags() & ENUM) != 0 && names.finalize.equals(m.name)) 1630 if (m.overrides(syms.enumFinalFinalize, origin, types, false)) { 1631 log.error(tree.pos(), "enum.no.finalize"); 1632 return; 1633 } 1634 for (Type t = types.supertype(origin.type); t.tag == CLASS; 1635 t = types.supertype(t)) { 1636 TypeSymbol c = t.tsym; 1637 Scope.Entry e = c.members().lookup(m.name); 1638 while (e.scope != null) { 1639 if (m.overrides(e.sym, origin, types, false)) 1640 checkOverride(tree, m, (MethodSymbol)e.sym, origin); 1641 else if (e.sym.kind == MTH && |