--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Apr 09 15:39:39 2010 -0700
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 14 12:23:29 2010 +0100
@@ -207,21 +207,6 @@
return owntype;
}
- Type checkReturn(JCTree tree, Type owntype, int ownkind, int pkind, Type pt) {
- if (owntype.tag != ERROR && pt.tag != METHOD && pt.tag != FORALL) {
- if ((ownkind & ~pkind) == 0) {
- owntype = chk.checkReturnType(tree.pos(), owntype, pt);
- } else {
- log.error(tree.pos(), "unexpected.type",
- kindNames(pkind),
- kindName(ownkind));
- owntype = types.createErrorType(owntype);
- }
- }
- tree.type = owntype;
- return owntype;
- }
-
/** Is given blank final variable assignable, i.e. in a scope where it
* may be assigned to even though it is final?
* @param v The blank final variable.
@@ -440,14 +425,7 @@
/** Derived visitor method: attribute a type tree.
*/
Type attribType(JCTree tree, Env<AttrContext> env) {
- Type result = attribType(tree, env, Type.noType);
- return result;
- }
-
- /** Derived visitor method: attribute a type tree.
- */
- Type attribType(JCTree tree, Env<AttrContext> env, Type pt) {
- Type result = attribTree(tree, env, TYP, pt);
+ Type result = attribTree(tree, env, TYP, Type.noType);
return result;
}
@@ -1400,7 +1378,7 @@
// Check that value of resulting type is admissible in the
// current context. Also, capture the return type
- result = checkReturn(tree, capture(restype), VAL, pkind, pt);
+ result = check(tree, capture(restype), VAL, pkind, pt);
}
chk.validate(tree.typeargs, localEnv);
}
@@ -1475,9 +1453,9 @@
// Attribute clazz expression and store
// symbol + type back into the attributed tree.
- Type clazztype = attribType(clazz, env);
+ Type clazztype = chk.checkClassType(
+ tree.clazz.pos(), attribType(clazz, env), true);
chk.validate(clazz, localEnv);
- clazztype = chk.checkNewClassType(clazz.pos(), clazztype, true, pt);
if (tree.encl != null) {
// We have to work in this case to store
// symbol + type back into the attributed tree.
@@ -1582,9 +1560,7 @@
// ...
// }
if (Resolve.isStatic(env)) cdef.mods.flags |= STATIC;
- clazz = TreeInfo.isDiamond(tree) ?
- make.Type(clazztype)
- : clazz;
+
if (clazztype.tsym.isInterface()) {
cdef.implementing = List.of(clazz);
} else {
@@ -2571,7 +2547,7 @@
if (clazztype.tag == CLASS) {
List<Type> formals = clazztype.tsym.type.getTypeArguments();
- if (actuals.length() == formals.length() || actuals.isEmpty()) {
+ if (actuals.length() == formals.length()) {
List<Type> a = actuals;
List<Type> f = formals;
while (a.nonEmpty()) {
@@ -2597,18 +2573,7 @@
clazzOuter = site;
}
}
- if (actuals.nonEmpty()) {
- owntype = new ClassType(clazzOuter, actuals, clazztype.tsym);
- }
- else if (TreeInfo.isDiamond(tree)) {
- //a type apply with no explicit type arguments - diamond operator
- //the result type is a forall F where F's tvars are the type-variables
- //that will be inferred when F is checked against the expected type
- List<Type> ftvars = clazztype.tsym.type.getTypeArguments();
- List<Type> new_tvars = types.newInstances(ftvars);
- clazztype = new ClassType(clazzOuter, new_tvars, clazztype.tsym);
- owntype = new ForAll(new_tvars, clazztype);
- }
+ owntype = new ClassType(clazzOuter, actuals, clazztype.tsym);
} else {
if (formals.length() != 0) {
log.error(tree.pos(), "wrong.number.type.args",