6939620: Switch to 'complex' diamond inference scheme
authormcimadamore
Wed, 14 Apr 2010 12:31:55 +0100
changeset 5321 c8efe769cb3b
parent 5320 e2aaa958b02d
child 5322 ac6d66f658cb
6939620: Switch to 'complex' diamond inference scheme Summary: Implement new inference scheme for diamond operator that takes into account type of actual arguments supplied to constructor Reviewed-by: jjg, darcy
langtools/src/share/classes/com/sun/tools/javac/code/Source.java
langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java
langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
langtools/src/share/classes/com/sun/tools/javac/comp/Check.java
langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java
langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java
langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties
langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java
langtools/test/tools/javac/6840059/T6840059.out
langtools/test/tools/javac/generics/diamond/neg/Neg01.java
langtools/test/tools/javac/generics/diamond/neg/Neg01.out
langtools/test/tools/javac/generics/diamond/neg/Neg02.java
langtools/test/tools/javac/generics/diamond/neg/Neg02.out
langtools/test/tools/javac/generics/diamond/neg/Neg03.java
langtools/test/tools/javac/generics/diamond/neg/Neg03.out
langtools/test/tools/javac/generics/diamond/neg/Neg04.java
langtools/test/tools/javac/generics/diamond/neg/Neg04.out
langtools/test/tools/javac/generics/diamond/neg/Neg05.java
langtools/test/tools/javac/generics/diamond/neg/Neg05.out
langtools/test/tools/javac/generics/diamond/neg/Neg06.java
langtools/test/tools/javac/generics/diamond/neg/Neg06.out
langtools/test/tools/javac/generics/diamond/neg/Neg07.java
langtools/test/tools/javac/generics/diamond/neg/Neg07.out
langtools/test/tools/javac/generics/diamond/neg/Neg08.java
langtools/test/tools/javac/generics/diamond/neg/Neg08.out
langtools/test/tools/javac/generics/diamond/neg/Neg09.java
langtools/test/tools/javac/generics/diamond/neg/Neg09.out
langtools/test/tools/javac/generics/diamond/neg/Neg10.java
langtools/test/tools/javac/generics/diamond/neg/Neg10.out
langtools/test/tools/javac/generics/diamond/neg/Neg11.java
langtools/test/tools/javac/generics/diamond/neg/Neg11.out
langtools/test/tools/javac/generics/diamond/pos/Pos01.java
langtools/test/tools/javac/generics/diamond/pos/Pos02.java
langtools/test/tools/javac/generics/diamond/pos/Pos03.java
langtools/test/tools/javac/generics/diamond/pos/Pos04.java
langtools/test/tools/javac/generics/diamond/pos/Pos05.java
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Source.java	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Source.java	Wed Apr 14 12:31:55 2010 +0100
@@ -122,6 +122,9 @@
     public boolean allowGenerics() {
         return compareTo(JDK1_5) >= 0;
     }
+    public boolean allowDiamond() {
+        return compareTo(JDK1_7) >= 0;
+    }
     public boolean allowEnums() {
         return compareTo(JDK1_5) >= 0;
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java	Wed Apr 14 12:31:55 2010 +0100
@@ -225,6 +225,13 @@
             (owner.kind == TYP && owner.isLocal());
     }
 
+    /** Has this symbol an empty name? This includes anonymous
+     *  inner classses.
+     */
+    public boolean isAnonymous() {
+        return name.isEmpty();
+    }
+
     /** Is this symbol a constructor?
      */
     public boolean isConstructor() {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Apr 14 12:31:55 2010 +0100
@@ -72,6 +72,7 @@
     final Log log;
     final Symtab syms;
     final Resolve rs;
+    final Infer infer;
     final Check chk;
     final MemberEnter memberEnter;
     final TreeMaker make;
@@ -100,6 +101,7 @@
         memberEnter = MemberEnter.instance(context);
         make = TreeMaker.instance(context);
         enter = Enter.instance(context);
+        infer = Infer.instance(context);
         cfolder = ConstFold.instance(context);
         target = Target.instance(context);
         types = Types.instance(context);
@@ -425,7 +427,14 @@
     /** Derived visitor method: attribute a type tree.
      */
     Type attribType(JCTree tree, Env<AttrContext> env) {
-        Type result = attribTree(tree, env, TYP, Type.noType);
+        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);
         return result;
     }
 
@@ -532,6 +541,7 @@
     }
 
     /** Attribute type reference in an `extends' or `implements' clause.
+     *  Supertypes of anonymous inner classes are usually already attributed.
      *
      *  @param tree              The tree making up the type reference.
      *  @param env               The environment current at the reference.
@@ -543,7 +553,9 @@
                     boolean classExpected,
                     boolean interfaceExpected,
                     boolean checkExtensible) {
-        Type t = attribType(tree, env);
+        Type t = tree.type != null ?
+            tree.type :
+            attribType(tree, env);
         return checkBase(t, tree, env, classExpected, interfaceExpected, checkExtensible);
     }
     Type checkBase(Type t,
@@ -1448,13 +1460,16 @@
                               ((JCTypeApply) clazz).arguments);
             else
                 clazz = clazzid1;
-//          System.out.println(clazz + " generated.");//DEBUG
         }
 
         // Attribute clazz expression and store
         // symbol + type back into the attributed tree.
-        Type clazztype = chk.checkClassType(
-            tree.clazz.pos(), attribType(clazz, env), true);
+        Type clazztype = attribType(clazz, env);
+        Pair<Scope,Scope> mapping = getSyntheticScopeMapping((ClassType)clazztype);
+        if (!TreeInfo.isDiamond(tree)) {
+            clazztype = chk.checkClassType(
+                tree.clazz.pos(), clazztype, true);
+        }
         chk.validate(clazz, localEnv);
         if (tree.encl != null) {
             // We have to work in this case to store
@@ -1479,6 +1494,11 @@
         List<Type> argtypes = attribArgs(tree.args, localEnv);
         List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv);
 
+        if (TreeInfo.isDiamond(tree)) {
+            clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes, true);
+            clazz.type = clazztype;
+        }
+
         // If we have made no mistakes in the class type...
         if (clazztype.tag == CLASS) {
             // Enums may not be instantiated except implicitly
@@ -1516,12 +1536,12 @@
                 tree.constructor = rs.resolveConstructor(
                     tree.pos(), localEnv, clazztype, argtypes, typeargtypes);
                 tree.constructorType = checkMethod(clazztype,
-                                            tree.constructor,
-                                            localEnv,
-                                            tree.args,
-                                            argtypes,
-                                            typeargtypes,
-                                            localEnv.info.varArgs);
+                                                tree.constructor,
+                                                localEnv,
+                                                tree.args,
+                                                argtypes,
+                                                typeargtypes,
+                                                localEnv.info.varArgs);
                 if (localEnv.info.varArgs)
                     assert tree.constructorType.isErroneous() || tree.varargsElement != null;
             }
@@ -1606,6 +1626,136 @@
         chk.validate(tree.typeargs, localEnv);
     }
 
+    Type attribDiamond(Env<AttrContext> env,
+                        JCNewClass tree,
+                        Type clazztype,
+                        Pair<Scope, Scope> mapping,
+                        List<Type> argtypes,
+                        List<Type> typeargtypes,
+                        boolean reportErrors) {
+        if (clazztype.isErroneous()) {
+            //if the type of the instance creation expression is erroneous
+            //return the erroneous type itself
+            return clazztype;
+        }
+        else if (clazztype.isInterface()) {
+            //if the type of the instance creation expression is an interface
+            //skip the method resolution step (JLS 15.12.2.7). The type to be
+            //inferred is of the kind <X1,X2, ... Xn>C<X1,X2, ... Xn>
+            clazztype = new ForAll(clazztype.tsym.type.allparams(),
+                    clazztype.tsym.type);
+        } else {
+            //if the type of the instance creation expression is a class type
+            //apply method resolution inference (JLS 15.12.2.7). The return type
+            //of the resolved constructor will be a partially instantiated type
+            ((ClassSymbol) clazztype.tsym).members_field = mapping.snd;
+            Symbol constructor;
+            try {
+                constructor = rs.resolveDiamond(tree.pos(),
+                        env,
+                        clazztype.tsym.type,
+                        argtypes,
+                        typeargtypes, reportErrors);
+            } finally {
+                ((ClassSymbol) clazztype.tsym).members_field = mapping.fst;
+            }
+            if (constructor.kind == MTH) {
+                ClassType ct = new ClassType(clazztype.getEnclosingType(),
+                        clazztype.tsym.type.getTypeArguments(),
+                        clazztype.tsym);
+                clazztype = checkMethod(ct,
+                        constructor,
+                        env,
+                        tree.args,
+                        argtypes,
+                        typeargtypes,
+                        env.info.varArgs).getReturnType();
+            } else {
+                clazztype = syms.errType;
+            }
+        }
+        if (clazztype.tag == FORALL && !pt.isErroneous()) {
+            //if the resolved constructor's return type has some uninferred
+            //type-variables, infer them using the expected type and declared
+            //bounds (JLS 15.12.2.8).
+            try {
+                clazztype = infer.instantiateExpr((ForAll) clazztype,
+                        pt.tag == NONE ? syms.objectType : pt,
+                        Warner.noWarnings);
+            } catch (Infer.InferenceException ex) {
+                //an error occurred while inferring uninstantiated type-variables
+                //we need to optionally report an error
+                if (reportErrors) {
+                    log.error(tree.clazz.pos(),
+                            "cant.apply.diamond.1",
+                            diags.fragment("diamond", clazztype.tsym),
+                            ex.diagnostic);
+                }
+            }
+        }
+        if (reportErrors) {
+            clazztype = chk.checkClassType(tree.clazz.pos(),
+                    clazztype,
+                    true);
+            if (clazztype.tag == CLASS) {
+                List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype);
+                if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) {
+                    //one or more types inferred in the previous steps is either a
+                    //captured type or an intersection type --- we need to report an error.
+                    String subkey = invalidDiamondArgs.size() > 1 ?
+                        "diamond.invalid.args" :
+                        "diamond.invalid.arg";
+                    //The error message is of the kind:
+                    //
+                    //cannot infer type arguments for {clazztype}<>;
+                    //reason: {subkey}
+                    //
+                    //where subkey is a fragment of the kind:
+                    //
+                    //type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context
+                    log.error(tree.clazz.pos(),
+                                "cant.apply.diamond.1",
+                                diags.fragment("diamond", clazztype.tsym),
+                                diags.fragment(subkey,
+                                               invalidDiamondArgs,
+                                               diags.fragment("diamond", clazztype.tsym)));
+                }
+            }
+        }
+        return clazztype;
+    }
+
+    /** Creates a synthetic scope containing fake generic constructors.
+     *  Assuming that the original scope contains a constructor of the kind:
+     *  Foo(X x, Y y), where X,Y are class type-variables declared in Foo,
+     *  the synthetic scope is added a generic constructor of the kind:
+     *  <X,Y>Foo<X,Y>(X x, Y y). This is crucial in order to enable diamond
+     *  inference. The inferred return type of the synthetic constructor IS
+     *  the inferred type for the diamond operator.
+     */
+    private Pair<Scope, Scope> getSyntheticScopeMapping(ClassType ctype) {
+        Pair<Scope, Scope> mapping =
+                new Pair<Scope, Scope>(ctype.tsym.members(), new Scope(ctype.tsym));
+        List<Type> typevars = ctype.tsym.type.getTypeArguments();
+        for (Scope.Entry e = mapping.fst.lookup(names.init);
+                e.scope != null;
+                e = e.next()) {
+            MethodSymbol newConstr = (MethodSymbol) e.sym.clone(ctype.tsym);
+            newConstr.name = names.init;
+            List<Type> oldTypeargs = List.nil();
+            if (newConstr.type.tag == FORALL) {
+                oldTypeargs = ((ForAll) newConstr.type).tvars;
+            }
+            newConstr.type = new MethodType(newConstr.type.getParameterTypes(),
+                    new ClassType(ctype.getEnclosingType(), ctype.tsym.type.getTypeArguments(), ctype.tsym),
+                    newConstr.type.getThrownTypes(),
+                    syms.methodClass);
+            newConstr.type = new ForAll(typevars.prependList(oldTypeargs), newConstr.type);
+            mapping.snd.enter(newConstr);
+        }
+        return mapping;
+    }
+
     /** Make an attributed null check tree.
      */
     public JCExpression makeNullCheck(JCExpression arg) {
@@ -2547,7 +2697,7 @@
         if (clazztype.tag == CLASS) {
             List<Type> formals = clazztype.tsym.type.getTypeArguments();
 
-            if (actuals.length() == formals.length()) {
+            if (actuals.length() == formals.length() || actuals.length() == 0) {
                 List<Type> a = actuals;
                 List<Type> f = formals;
                 while (a.nonEmpty()) {
@@ -2788,9 +2938,12 @@
 
         // Validate type parameters, supertype and interfaces.
         attribBounds(tree.typarams);
-        chk.validate(tree.typarams, env);
-        chk.validate(tree.extending, env);
-        chk.validate(tree.implementing, env);
+        if (!c.isAnonymous()) {
+            //already checked if anonymous
+            chk.validate(tree.typarams, env);
+            chk.validate(tree.extending, env);
+            chk.validate(tree.implementing, env);
+        }
 
         // If this is a non-abstract class, check that it has no abstract
         // methods or unimplemented methods of an implemented interface.
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java	Wed Apr 14 12:31:55 2010 +0100
@@ -640,6 +640,43 @@
             return true;
     }
 
+    /** Check that the type inferred using the diamond operator does not contain
+     *  non-denotable types such as captured types or intersection types.
+     *  @param t the type inferred using the diamond operator
+     */
+    List<Type> checkDiamond(ClassType t) {
+        DiamondTypeChecker dtc = new DiamondTypeChecker();
+        ListBuffer<Type> buf = ListBuffer.lb();
+        for (Type arg : t.getTypeArguments()) {
+            if (!dtc.visit(arg, null)) {
+                buf.append(arg);
+            }
+        }
+        return buf.toList();
+    }
+
+    static class DiamondTypeChecker extends Types.SimpleVisitor<Boolean, Void> {
+        public Boolean visitType(Type t, Void s) {
+            return true;
+        }
+        @Override
+        public Boolean visitClassType(ClassType t, Void s) {
+            if (t.isCompound()) {
+                return false;
+            }
+            for (Type targ : t.getTypeArguments()) {
+                if (!visit(targ, s)) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        @Override
+        public Boolean visitCapturedType(CapturedType t, Void s) {
+            return false;
+        }
+    }
+
     /** Check that given modifiers are legal for given symbol and
      *  return modifiers together with any implicit modififiers for that symbol.
      *  Warning: we can't use flags() here since this method
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Apr 14 12:31:55 2010 +0100
@@ -788,6 +788,8 @@
                                            operator);
                 }
             }
+            if (name == names.init)
+                break;
             //- System.out.println(" - " + bestSoFar);
             if (abstractok) {
                 Symbol concrete = methodNotFound;
@@ -1409,6 +1411,48 @@
         return sym;
     }
 
+    /** Resolve constructor using diamond inference.
+     *  @param pos       The position to use for error reporting.
+     *  @param env       The environment current at the constructor invocation.
+     *  @param site      The type of class for which a constructor is searched.
+     *                   The scope of this class has been touched in attribution.
+     *  @param argtypes  The types of the constructor invocation's value
+     *                   arguments.
+     *  @param typeargtypes  The types of the constructor invocation's type
+     *                   arguments.
+     */
+    Symbol resolveDiamond(DiagnosticPosition pos,
+                              Env<AttrContext> env,
+                              Type site,
+                              List<Type> argtypes,
+                              List<Type> typeargtypes, boolean reportErrors) {
+        Symbol sym = methodNotFound;
+        JCDiagnostic explanation = null;
+        List<MethodResolutionPhase> steps = methodResolutionSteps;
+        while (steps.nonEmpty() &&
+               steps.head.isApplicable(boxingEnabled, varargsEnabled) &&
+               sym.kind >= ERRONEOUS) {
+            sym = resolveConstructor(pos, env, site, argtypes, typeargtypes,
+                    steps.head.isBoxingRequired(),
+                    env.info.varArgs = steps.head.isVarargsRequired());
+            methodResolutionCache.put(steps.head, sym);
+            if (sym.kind == WRONG_MTH &&
+                    ((InapplicableSymbolError)sym).explanation != null) {
+                //if the symbol is an inapplicable method symbol, then the
+                //explanation contains the reason for which inference failed
+                explanation = ((InapplicableSymbolError)sym).explanation;
+            }
+            steps = steps.tail;
+        }
+        if (sym.kind >= AMBIGUOUS && reportErrors) {
+            String key = explanation == null ?
+                "cant.apply.diamond" :
+                "cant.apply.diamond.1";
+            log.error(pos, key, diags.fragment("diamond", site.tsym), explanation);
+        }
+        return sym;
+    }
+
     /** Resolve constructor.
      *  @param pos       The position to use for error reporting.
      *  @param env       The environment current at the constructor invocation.
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java	Wed Apr 14 12:31:55 2010 +0100
@@ -131,6 +131,7 @@
         this.allowForeach = source.allowForeach();
         this.allowStaticImport = source.allowStaticImport();
         this.allowAnnotations = source.allowAnnotations();
+        this.allowDiamond = source.allowDiamond();
         this.allowTypeAnnotations = source.allowTypeAnnotations();
         this.keepDocComments = keepDocComments;
         if (keepDocComments)
@@ -148,6 +149,10 @@
      */
     boolean allowGenerics;
 
+    /** Switch: Should diamond operator be recognized?
+     */
+    boolean allowDiamond;
+
     /** Switch: Should varargs be recognized?
      */
     boolean allowVarargs;
@@ -190,10 +195,11 @@
      *     mode = NOPARAMS    : no parameters allowed for type
      *     mode = TYPEARG     : type argument
      */
-    static final int EXPR = 1;
-    static final int TYPE = 2;
-    static final int NOPARAMS = 4;
-    static final int TYPEARG = 8;
+    static final int EXPR = 0x1;
+    static final int TYPE = 0x2;
+    static final int NOPARAMS = 0x4;
+    static final int TYPEARG = 0x8;
+    static final int DIAMOND = 0x10;
 
     /** The current mode.
      */
@@ -1343,6 +1349,11 @@
         ListBuffer<JCExpression> args = lb();
         if (S.token() == LT) {
             S.nextToken();
+            if (S.token() == GT && (mode & DIAMOND) != 0) {
+                checkDiamond();
+                S.nextToken();
+                return List.nil();
+            }
             args.append(((mode & EXPR) == 0) ? typeArgument() : parseType());
             while (S.token() == COMMA) {
                 S.nextToken();
@@ -1516,7 +1527,7 @@
             t = F.AnnotatedType(newAnnotations, t);
 
         int oldmode = mode;
-        mode = TYPE;
+        mode = TYPE | DIAMOND;
         if (S.token() == LT) {
             checkGenerics();
             t = typeArguments(t);
@@ -1569,8 +1580,11 @@
     JCExpression innerCreator(int newpos, List<JCExpression> typeArgs, JCExpression encl) {
         JCExpression t = toP(F.at(S.pos()).Ident(ident()));
         if (S.token() == LT) {
+            int oldmode = mode;
+            mode |= DIAMOND;
             checkGenerics();
             t = typeArguments(t);
+            mode = oldmode;
         }
         return classCreatorRest(newpos, encl, typeArgs, t);
     }
@@ -3173,4 +3187,10 @@
             allowTypeAnnotations = true;
         }
     }
+    void checkDiamond() {
+        if (!allowDiamond) {
+            log.error(S.pos(), "diamond.not.supported.in.source", source.name);
+            allowDiamond = true;
+        }
+    }
 }
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Wed Apr 14 12:31:55 2010 +0100
@@ -479,6 +479,11 @@
     type parameters of {0} cannot be determined; {1}
 compiler.err.invalid.inferred.types=\
     invalid inferred types for {0}; {1}
+compiler.err.cant.apply.diamond=\
+    cannot infer type arguments for {0}
+compiler.err.cant.apply.diamond.1=\
+    cannot infer type arguments for {0};\n\
+    reason: {1}
 compiler.err.unreachable.stmt=\
     unreachable statement
 compiler.err.initializer.must.be.able.to.complete.normally=\
@@ -1030,7 +1035,12 @@
     actual arguments do not conform to inferred formal arguments\n\
     required: {0}\n\
     found: {1}
-
+compiler.misc.diamond=\
+    {0}<>
+compiler.misc.diamond.invalid.arg=\
+    type argument {0} inferred for {1} is not allowed in this context
+compiler.misc.diamond.invalid.args=\
+    type arguments {0} inferred for {1} are not allowed in this context
 #####
 
 ## The first argument ({0}) is a "kindname".
@@ -1163,6 +1173,8 @@
     {0} in {1} implements {2} in {3}
 compiler.misc.varargs.clash.with=\
     {0} in {1} overrides {2} in {3}
+compiler.misc.non.denotable.type=\
+    Non-denotable type {0} not allowed here
 
 ########################################
 # Diagnostics for language feature changes
--- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java	Wed Apr 14 12:31:55 2010 +0100
@@ -204,6 +204,15 @@
         return (JCMethodInvocation)exec.expr;
     }
 
+    /** Return true if a tree represents a diamond new expr. */
+    public static boolean isDiamond(JCTree tree) {
+        switch(tree.getTag()) {
+            case JCTree.TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty();
+            case JCTree.NEWCLASS: return isDiamond(((JCNewClass)tree).clazz);
+            default: return false;
+        }
+    }
+
     /** Return true if a tree represents the null literal. */
     public static boolean isNull(JCTree tree) {
         if (tree.getTag() != JCTree.LITERAL)
--- a/langtools/test/tools/javac/6840059/T6840059.out	Wed Apr 14 12:23:29 2010 +0100
+++ b/langtools/test/tools/javac/6840059/T6840059.out	Wed Apr 14 12:31:55 2010 +0100
@@ -1,3 +1,3 @@
-T6840059.java:15:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6840059, , java.lang.String, kindname.class, T6840059
-T6840059.java:15:25: compiler.err.cant.resolve.location.args: kindname.constructor, T6840059, , , kindname.class, T6840059
+T6840059.java:15:9: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, null
+T6840059.java:15:25: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, null
 2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg01.out Neg01.java -XDrawDiagnostics
+ *
+ */
+
+class Neg01<X extends Number> {
+
+    Neg01(X x) {}
+
+    <Z> Neg01(X x, Z z) {}
+
+    void test() {
+        Neg01<String> n1 = new Neg01<>("");
+        Neg01<? extends String> n2 = new Neg01<>("");
+        Neg01<?> n3 = new Neg01<>("");
+        Neg01<? super String> n4 = new Neg01<>("");
+
+        Neg01<String> n5 = new Neg01<>(""){};
+        Neg01<? extends String> n6 = new Neg01<>(""){};
+        Neg01<?> n7 = new Neg01<>(""){};
+        Neg01<? super String> n8 = new Neg01<>(""){};
+
+        Neg01<String> n9 = new Neg01<>("", "");
+        Neg01<? extends String> n10 = new Neg01<>("", "");
+        Neg01<?> n11 = new Neg01<>("", "");
+        Foo<? super String> n12 = new Neg01<>("", "");
+
+        Neg01<String> n13 = new Neg01<>("", ""){};
+        Neg01<? extends String> n14 = new Neg01<>("", ""){};
+        Neg01<?> n15 = new Neg01<>("", ""){};
+        Neg01<? super String> n16 = new Neg01<>("", ""){};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg01.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,29 @@
+Neg01.java:18:15: compiler.err.not.within.bounds: java.lang.String
+Neg01.java:18:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:19:15: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg01.java:19:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:20:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:21:15: compiler.err.not.within.bounds: ? super java.lang.String
+Neg01.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:23:15: compiler.err.not.within.bounds: java.lang.String
+Neg01.java:23:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:24:15: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg01.java:24:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:25:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:26:15: compiler.err.not.within.bounds: ? super java.lang.String
+Neg01.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:28:15: compiler.err.not.within.bounds: java.lang.String
+Neg01.java:28:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:29:15: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg01.java:29:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:30:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:31:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , kindname.class, Neg01<X>
+Neg01.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:33:15: compiler.err.not.within.bounds: java.lang.String
+Neg01.java:33:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:34:15: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg01.java:34:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:35:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+Neg01.java:36:15: compiler.err.not.within.bounds: ? super java.lang.String
+Neg01.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null
+28 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,61 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg02.out Neg02.java -XDrawDiagnostics
+ *
+ */
+
+class Neg02 {
+
+    static class Foo<X extends Number> {
+        Foo(X x) {}
+        <Z> Foo(X x, Z z) {}
+    }
+
+    void testSimple() {
+        Foo<String> f1 = new Foo<>("");
+        Foo<? extends String> f2 = new Foo<>("");
+        Foo<?> f3 = new Foo<>("");
+        Foo<? super String> f4 = new Foo<>("");
+
+        Foo<String> f5 = new Foo<>(""){};
+        Foo<? extends String> f6 = new Foo<>(""){};
+        Foo<?> f7 = new Foo<>(""){};
+        Foo<? super String> f8 = new Foo<>(""){};
+
+        Foo<String> f9 = new Foo<>("", "");
+        Foo<? extends String> f10 = new Foo<>("", "");
+        Foo<?> f11 = new Foo<>("", "");
+        Foo<? super String> f12 = new Foo<>("", "");
+
+        Foo<String> f13 = new Foo<>("", ""){};
+        Foo<? extends String> f14 = new Foo<>("", ""){};
+        Foo<?> f15 = new Foo<>("", ""){};
+        Foo<? super String> f16 = new Foo<>("", ""){};
+    }
+
+    void testQualified() {
+        Foo<String> f1 = new Neg02.Foo<>("");
+        Foo<? extends String> f2 = new Neg02.Foo<>("");
+        Foo<?> f3 = new Neg02.Foo<>("");
+        Foo<? super String> f4 = new Neg02.Foo<>("");
+
+        Foo<String> f5 = new Neg02.Foo<>(""){};
+        Foo<? extends String> f6 = new Neg02.Foo<>(""){};
+        Foo<?> f7 = new Neg02.Foo<>(""){};
+        Foo<? super String> f8 = new Neg02.Foo<>(""){};
+
+        Foo<String> f9 = new Neg02.Foo<>("", "");
+        Foo<? extends String> f10 = new Neg02.Foo<>("", "");
+        Foo<?> f11 = new Neg02.Foo<>("", "");
+        Foo<? super String> f12 = new Neg02.Foo<>("", "");
+
+        Foo<String> f13 = new Neg02.Foo<>("", ""){};
+        Foo<? extends String> f14 = new Neg02.Foo<>("", ""){};
+        Foo<?> f15 = new Neg02.Foo<>("", ""){};
+        Foo<? super String> f16 = new Neg02.Foo<>("", ""){};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg02.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,57 @@
+Neg02.java:19:13: compiler.err.not.within.bounds: java.lang.String
+Neg02.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg02.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg02.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:24:13: compiler.err.not.within.bounds: java.lang.String
+Neg02.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg02.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg02.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:29:13: compiler.err.not.within.bounds: java.lang.String
+Neg02.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg02.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg02.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:34:13: compiler.err.not.within.bounds: java.lang.String
+Neg02.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg02.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg02.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:41:13: compiler.err.not.within.bounds: java.lang.String
+Neg02.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg02.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg02.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:46:13: compiler.err.not.within.bounds: java.lang.String
+Neg02.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg02.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg02.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:51:13: compiler.err.not.within.bounds: java.lang.String
+Neg02.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg02.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg02.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:56:13: compiler.err.not.within.bounds: java.lang.String
+Neg02.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg02.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+Neg02.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg02.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null
+56 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,83 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg03.out Neg03.java -XDrawDiagnostics
+ *
+ */
+
+class Neg03<U> {
+
+    class Foo<V extends Number> {
+        Foo(V x) {}
+        <Z> Foo(V x, Z z) {}
+    }
+
+    void testSimple() {
+        Foo<String> f1 = new Foo<>("");
+        Foo<? extends String> f2 = new Foo<>("");
+        Foo<?> f3 = new Foo<>("");
+        Foo<? super String> f4 = new Foo<>("");
+
+        Foo<String> f5 = new Foo<>(""){};
+        Foo<? extends String> f6 = new Foo<>(""){};
+        Foo<?> f7 = new Foo<>(""){};
+        Foo<? super String> f8 = new Foo<>(""){};
+
+        Foo<String> f9 = new Foo<>("", "");
+        Foo<? extends String> f10 = new Foo<>("", "");
+        Foo<?> f11 = new Foo<>("", "");
+        Foo<? super String> f12 = new Foo<>("", "");
+
+        Foo<String> f13 = new Foo<>("", ""){};
+        Foo<? extends String> f14 = new Foo<>("", ""){};
+        Foo<?> f15 = new Foo<>("", ""){};
+        Foo<? super String> f16 = new Foo<>("", ""){};
+    }
+
+    void testQualified_1() {
+        Foo<String> f1 = new Neg03<U>.Foo<>("");
+        Foo<? extends String> f2 = new Neg03<U>.Foo<>("");
+        Foo<?> f3 = new Neg03<U>.Foo<>("");
+        Foo<? super String> f4 = new Neg03<U>.Foo<>("");
+
+        Foo<String> f5 = new Neg03<U>.Foo<>(""){};
+        Foo<? extends String> f6 = new Neg03<U>.Foo<>(""){};
+        Foo<?> f7 = new Neg03<U>.Foo<>(""){};
+        Foo<? super String> f8 = new Neg03<U>.Foo<>(""){};
+
+        Foo<String> f9 = new Neg03<U>.Foo<>("", "");
+        Foo<? extends String> f10 = new Neg03<U>.Foo<>("", "");
+        Foo<?> f11 = new Neg03<U>.Foo<>("", "");
+        Foo<? super String> f12 = new Neg03<U>.Foo<>("", "");
+
+        Foo<String> f13 = new Neg03<U>.Foo<>("", ""){};
+        Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){};
+        Foo<?> f15 = new Neg03<U>.Foo<>("", ""){};
+        Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){};
+    }
+
+    void testQualified_2(Neg03<U> n) {
+        Foo<String> f1 = n.new Foo<>("");
+        Foo<? extends String> f2 = n.new Foo<>("");
+        Foo<?> f3 = n.new Foo<>("");
+        Foo<? super String> f4 = n.new Foo<>("");
+
+        Foo<String> f5 = n.new Foo<>(""){};
+        Foo<? extends String> f6 = n.new Foo<>(""){};
+        Foo<?> f7 = n.new Foo<>(""){};
+        Foo<? super String> f8 = n.new Foo<>(""){};
+
+        Foo<String> f9 = n.new Foo<>("", "");
+        Foo<? extends String> f10 = n.new Foo<>("", "");
+        Foo<?> f11 = n.new Foo<>("", "");
+        Foo<? super String> f12 = n.new Foo<>("", "");
+
+        Foo<String> f13 = n.new Foo<>("", ""){};
+        Foo<? extends String> f14 = n.new Foo<>("", ""){};
+        Foo<?> f15 = n.new Foo<>("", ""){};
+        Foo<? super String> f16 = n.new Foo<>("", ""){};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg03.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,85 @@
+Neg03.java:19:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:24:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:29:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:34:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:41:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:46:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:51:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:56:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:63:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:63:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:64:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:64:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:65:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:66:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:66:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:68:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:68:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:69:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:69:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:70:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:71:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:71:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:73:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:73:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:74:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:74:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:75:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:76:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:76:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:78:13: compiler.err.not.within.bounds: java.lang.String
+Neg03.java:78:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:79:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg03.java:79:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:80:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+Neg03.java:81:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg03.java:81:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null
+84 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,38 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg04.out Neg04.java -XDrawDiagnostics
+ *
+ */
+
+class Neg04 {
+
+    void test() {
+        class Foo<V extends Number> {
+            Foo(V x) {}
+            <Z> Foo(V x, Z z) {}
+        }
+        Foo<String> n1 = new Foo<>("");
+        Foo<? extends String> n2 = new Foo<>("");
+        Foo<?> n3 = new Foo<>("");
+        Foo<? super String> n4 = new Foo<>("");
+
+        Foo<String> n5 = new Foo<>(""){};
+        Foo<? extends String> n6 = new Foo<>(""){};
+        Foo<?> n7 = new Foo<>(""){};
+        Foo<? super String> n8 = new Foo<>(""){};
+
+        Foo<String> n9 = new Foo<>("", "");
+        Foo<? extends String> n10 = new Foo<>("", "");
+        Foo<?> n11 = new Foo<>("", "");
+        Foo<? super String> n12 = new Foo<>("", "");
+
+        Foo<String> n13 = new Foo<>("", ""){};
+        Foo<? extends String> n14 = new Foo<>("", ""){};
+        Foo<?> n15 = new Foo<>("", ""){};
+        Foo<? super String> n16 = new Foo<>("", ""){};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg04.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,29 @@
+Neg04.java:18:13: compiler.err.not.within.bounds: java.lang.String
+Neg04.java:18:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:19:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg04.java:19:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:20:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:21:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg04.java:21:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:23:13: compiler.err.not.within.bounds: java.lang.String
+Neg04.java:23:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:24:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg04.java:24:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:25:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:26:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg04.java:26:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:28:13: compiler.err.not.within.bounds: java.lang.String
+Neg04.java:28:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:29:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg04.java:29:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:30:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:31:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg04.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:33:13: compiler.err.not.within.bounds: java.lang.String
+Neg04.java:33:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:34:13: compiler.err.not.within.bounds: ? extends java.lang.String
+Neg04.java:34:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:35:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+Neg04.java:36:13: compiler.err.not.within.bounds: ? super java.lang.String
+Neg04.java:36:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null
+28 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,61 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg05.out Neg05.java -XDrawDiagnostics
+ *
+ */
+
+class Neg05<U> {
+
+    class Foo<V> {
+        Foo(V x) {}
+        <Z> Foo(V x, Z z) {}
+    }
+
+    void testRare_1() {
+        Neg05<?>.Foo<String> f1 = new Neg05.Foo<>("");
+        Neg05<?>.Foo<? extends String> f2 = new Neg05.Foo<>("");
+        Neg05<?>.Foo<?> f3 = new Neg05.Foo<>("");
+        Neg05<?>.Foo<? super String> f4 = new Neg05.Foo<>("");
+
+        Neg05<?>.Foo<String> f5 = new Neg05.Foo<>(""){};
+        Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>(""){};
+        Neg05<?>.Foo<?> f7 = new Neg05.Foo<>(""){};
+        Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>(""){};
+
+        Neg05<?>.Foo<String> f9 = new Neg05.Foo<>("", "");
+        Neg05<?>.Foo<? extends String> f10 = new Neg05.Foo<>("", "");
+        Neg05<?>.Foo<?> f11 = new Neg05.Foo<>("", "");
+        Neg05<?>.Foo<? super String> f12 = new Neg05.Foo<>("", "");
+
+        Neg05<?>.Foo<String> f13 = new Neg05.Foo<>("", ""){};
+        Neg05<?>.Foo<? extends String> f14 = new Neg05.Foo<>("", ""){};
+        Neg05<?>.Foo<?> f15 = new Neg05.Foo<>("", ""){};
+        Neg05<?>.Foo<? super String> f16 = new Neg05.Foo<>("", ""){};
+    }
+
+    void testRare_2(Neg05 n) {
+        Neg05<?>.Foo<String> f1 = n.new Foo<>("");
+        Neg05<?>.Foo<? extends String> f2 = n.new Foo<>("");
+        Neg05<?>.Foo<?> f3 = n.new Foo<>("");
+        Neg05<?>.Foo<? super String> f4 = n.new Foo<>("");
+
+        Neg05<?>.Foo<String> f5 = n.new Foo<>(""){};
+        Neg05<?>.Foo<? extends String> f6 = n.new Foo<>(""){};
+        Neg05<?>.Foo<?> f7 = n.new Foo<>(""){};
+        Neg05<?>.Foo<? super String> f8 = n.new Foo<>(""){};
+
+        Neg05<?>.Foo<String> f9 = n.new Foo<>("", "");
+        Neg05<?>.Foo<? extends String> f10 = n.new Foo<>("", "");
+        Neg05<?>.Foo<?> f11 = n.new Foo<>("", "");
+        Neg05<?>.Foo<? super String> f12 = n.new Foo<>("", "");
+
+        Neg05<?>.Foo<String> f13 = n.new Foo<>("", ""){};
+        Neg05<?>.Foo<? extends String> f14 = n.new Foo<>("", ""){};
+        Neg05<?>.Foo<?> f15 = n.new Foo<>("", ""){};
+        Neg05<?>.Foo<? super String> f16 = n.new Foo<>("", ""){};
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg05.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,49 @@
+Neg05.java:19:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:19:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
+Neg05.java:20:58: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:20:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
+Neg05.java:21:43: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:21:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
+Neg05.java:22:56: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:22:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
+Neg05.java:24:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:24:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
+Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:25:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
+Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:26:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
+Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:27:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
+Neg05.java:29:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:29:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
+Neg05.java:30:59: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:30:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
+Neg05.java:31:44: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:31:31: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
+Neg05.java:32:57: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:32:44: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
+Neg05.java:34:49: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:34:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String>
+Neg05.java:35:59: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:35:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String>
+Neg05.java:36:44: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:36:31: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?>
+Neg05.java:37:57: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:37:44: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String>
+Neg05.java:41:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:42:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:43:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:44:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:46:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:47:47: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:48:32: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:49:45: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:51:37: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:52:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:53:33: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:54:46: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:56:38: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:57:48: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:58:33: compiler.err.improperly.formed.type.inner.raw.param
+Neg05.java:59:46: compiler.err.improperly.formed.type.inner.raw.param
+48 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg06.out Neg06.java -XDrawDiagnostics
+ *
+ */
+
+class Neg06 {
+   interface ISuperFoo<X> {}
+   interface IFoo<X extends Number> extends ISuperFoo<X> {}
+
+   static class CSuperFoo<X> {}
+   static class CFoo<X extends Number> extends CSuperFoo<X> {}
+
+   ISuperFoo<String> isf = new IFoo<>() {};
+   CSuperFoo<String> csf1 = new CFoo<>();
+   CSuperFoo<String> csf2 = new CFoo<>() {};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg06.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,4 @@
+Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.IFoo<X>, Neg06.ISuperFoo<java.lang.String>)
+Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
+Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>)
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,19 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg07.out Neg07.java -XDrawDiagnostics
+ *
+ */
+
+class Neg07 {
+   static class SuperFoo<X> {}
+   static class Foo<X extends Number> extends SuperFoo<X> {
+       Foo(X x) {}
+   }
+
+   SuperFoo<String> sf1 = new Foo<>("");
+   SuperFoo<String> sf2 = new Foo<>("") {};
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg07.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,3 @@
+Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number)
+Neg07.java:18:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number)
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg08.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,30 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620 6894753
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg08.out Neg08.java -XDrawDiagnostics
+ *
+ */
+
+class Neg08 {
+    static class Foo<X> {
+        Foo(X x) {  }
+    }
+
+    static class DoubleFoo<X,Y> {
+        DoubleFoo(X x,Y y) {  }
+    }
+
+    static class TripleFoo<X,Y,Z> {
+        TripleFoo(X x,Y y,Z z) {  }
+    }
+
+    Foo<? extends Integer> fi = new Foo<>(1);
+    Foo<?> fw = new Foo<>(fi);
+    Foo<? extends Double> fd = new Foo<>(3.0);
+    DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd);
+    Foo<String> fs = new Foo<>("one");
+    TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg08.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,4 @@
+Neg08.java:25:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.Foo), (compiler.misc.diamond.invalid.arg: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, (compiler.misc.diamond: Neg08.Foo))
+Neg08.java:27:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.DoubleFoo), (compiler.misc.diamond.invalid.args: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg08.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg08.DoubleFoo))
+Neg08.java:29:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.TripleFoo), (compiler.misc.diamond.invalid.args: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg08.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg08.TripleFoo))
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,22 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620 6894753
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg09.out Neg09.java -XDrawDiagnostics
+ *
+ */
+
+class Neg09 {
+    static class Foo<X extends Number & Comparable<Number>> {}
+    static class DoubleFoo<X extends Number & Comparable<Number>,
+                           Y extends Number & Comparable<Number>> {}
+    static class TripleFoo<X extends Number & Comparable<Number>,
+                           Y extends Number & Comparable<Number>,
+                           Z> {}
+
+    Foo<?> fw = new Foo<>();
+    DoubleFoo<?,?> dw = new DoubleFoo<>();
+    TripleFoo<?,?,?> tw = new TripleFoo<>();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg09.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,4 @@
+Neg09.java:19:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.Foo), (compiler.misc.diamond.invalid.arg: java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.Foo))
+Neg09.java:20:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.DoubleFoo), (compiler.misc.diamond.invalid.args: java.lang.Number&java.lang.Comparable<java.lang.Number>,java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.DoubleFoo))
+Neg09.java:21:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.TripleFoo), (compiler.misc.diamond.invalid.args: java.lang.Number&java.lang.Comparable<java.lang.Number>,java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.TripleFoo))
+3 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg10.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,17 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg10.out Neg10.java -XDrawDiagnostics
+ *
+ */
+
+class Neg10 {
+    static class Foo<X> {
+        Foo(X x) {}
+    }
+
+    Foo<Number> fw = new Foo<>(1);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg10.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,2 @@
+Neg10.java:16:22: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg10.Foo<java.lang.Integer>, Neg10.Foo<java.lang.Number>
+1 error
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg11.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile/fail/ref=Neg11.out Neg11.java -XDrawDiagnostics
+ *
+ */
+
+class Neg11 {
+
+    void test() {
+        class Foo<X extends Number> { }
+        Foo<?> f1 = new UndeclaredName<>(); //this is deliberate: aim is to test erroneous path
+        Foo<?> f2 = new UndeclaredName<>() {}; //this is deliberate: aim is to test erroneous path
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/neg/Neg11.out	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,3 @@
+Neg11.java:15:25: compiler.err.cant.resolve.location: kindname.class, UndeclaredName, , , kindname.class, Neg11
+Neg11.java:16:25: compiler.err.cant.resolve.location: kindname.class, UndeclaredName, , , kindname.class, Neg11
+2 errors
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos01.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile Pos01.java
+ * @run main Pos01
+ *
+ */
+
+public class Pos01<X> {
+
+    Pos01(X x) {}
+
+    <Z> Pos01(X x, Z z) {}
+
+    void test() {
+        Pos01<Integer> p1 = new Pos01<>(1);
+        Pos01<? extends Integer> p2 = new Pos01<>(1);
+        Pos01<?> p3 = new Pos01<>(1);
+        Pos01<? super Integer> p4 = new Pos01<>(1);
+
+        Pos01<Integer> p5 = new Pos01<>(1){};
+        Pos01<? extends Integer> p6 = new Pos01<>(1){};
+        Pos01<?> p7 = new Pos01<>(1){};
+        Pos01<? super Integer> p8 = new Pos01<>(1){};
+
+        Pos01<Integer> p9 = new Pos01<>(1, "");
+        Pos01<? extends Integer> p10 = new Pos01<>(1, "");
+        Pos01<?> p11 = new Pos01<>(1, "");
+        Pos01<? super Integer> p12 = new Pos01<>(1, "");
+
+        Pos01<Integer> p13 = new Pos01<>(1, ""){};
+        Pos01<? extends Integer> p14= new Pos01<>(1, ""){};
+        Pos01<?> p15 = new Pos01<>(1, ""){};
+        Pos01<? super Integer> p16 = new Pos01<>(1, ""){};
+    }
+
+    public static void main(String[] args) {
+        Pos01<String> p1 = new Pos01<>("");
+        p1.test();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos02.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile Pos02.java
+ * @run main Pos02
+ */
+
+public class Pos02 {
+
+    static class Foo<X> {
+        Foo(X x) {}
+        <Z> Foo(X x, Z z) {}
+    }
+
+    void testSimple() {
+        Foo<Integer> f1 = new Foo<>(1);
+        Foo<? extends Integer> f2 = new Foo<>(1);
+        Foo<?> f3 = new Foo<>(1);
+        Foo<? super Integer> f4 = new Foo<>(1);
+
+        Foo<Integer> f5 = new Foo<>(1){};
+        Foo<? extends Integer> f6 = new Foo<>(1){};
+        Foo<?> f7 = new Foo<>(1){};
+        Foo<? super Integer> f8 = new Foo<>(1){};
+
+        Foo<Integer> f9 = new Foo<>(1, "");
+        Foo<? extends Integer> f10 = new Foo<>(1, "");
+        Foo<?> f11 = new Foo<>(1, "");
+        Foo<? super Integer> f12 = new Foo<>(1, "");
+
+        Foo<Integer> f13 = new Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = new Foo<>(1, ""){};
+        Foo<?> f15 = new Foo<>(1, ""){};
+        Foo<? super Integer> f16 = new Foo<>(1, ""){};
+    }
+
+    void testQualified() {
+        Foo<Integer> f1 = new Pos02.Foo<>(1);
+        Foo<? extends Integer> f2 = new Pos02.Foo<>(1);
+        Foo<?> f3 = new Pos02.Foo<>(1);
+        Foo<? super Integer> f4 = new Pos02.Foo<>(1);
+
+        Foo<Integer> f5 = new Pos02.Foo<>(1){};
+        Foo<? extends Integer> f6 = new Pos02.Foo<>(1){};
+        Foo<?> f7 = new Pos02.Foo<>(1){};
+        Foo<? super Integer> f8 = new Pos02.Foo<>(1){};
+
+        Foo<Integer> f9 = new Pos02.Foo<>(1, "");
+        Foo<? extends Integer> f10 = new Pos02.Foo<>(1, "");
+        Foo<?> f11 = new Pos02.Foo<>(1, "");
+        Foo<? super Integer> f12 = new Pos02.Foo<>(1, "");
+
+        Foo<Integer> f13 = new Pos02.Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = new Pos02.Foo<>(1, ""){};
+        Foo<?> f15 = new Pos02.Foo<>(1, ""){};
+        Foo<? super Integer> f16 = new Pos02.Foo<>(1, ""){};
+    }
+
+    public static void main(String[] args) {
+        Pos02 p2 = new Pos02();
+        p2.testSimple();
+        p2.testQualified();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos03.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile Pos03.java
+ * @run main Pos03
+ *
+ */
+
+public class Pos03<U> {
+
+    class Foo<V> {
+        Foo(V x) {}
+        <Z> Foo(V x, Z z) {}
+    }
+
+    void testSimple() {
+        Foo<Integer> f1 = new Foo<>(1);
+        Foo<? extends Integer> f2 = new Foo<>(1);
+        Foo<?> f3 = new Foo<>(1);
+        Foo<? super Integer> f4 = new Foo<>(1);
+
+        Foo<Integer> f5 = new Foo<>(1){};
+        Foo<? extends Integer> f6 = new Foo<>(1){};
+        Foo<?> f7 = new Foo<>(1){};
+        Foo<? super Integer> f8 = new Foo<>(1){};
+
+        Foo<Integer> f9 = new Foo<>(1, "");
+        Foo<? extends Integer> f10 = new Foo<>(1, "");
+        Foo<?> f11 = new Foo<>(1, "");
+        Foo<? super Integer> f12 = new Foo<>(1, "");
+
+        Foo<Integer> f13 = new Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = new Foo<>(1, ""){};
+        Foo<?> f15 = new Foo<>(1, ""){};
+        Foo<? super Integer> f16 = new Foo<>(1, ""){};
+    }
+
+    void testQualified_1() {
+        Foo<Integer> f1 = new Pos03<U>.Foo<>(1);
+        Foo<? extends Integer> f2 = new Pos03<U>.Foo<>(1);
+        Foo<?> f3 = new Pos03<U>.Foo<>(1);
+        Foo<? super Integer> f4 = new Pos03<U>.Foo<>(1);
+
+        Foo<Integer> f5 = new Pos03<U>.Foo<>(1){};
+        Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1){};
+        Foo<?> f7 = new Pos03<U>.Foo<>(1){};
+        Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1){};
+
+        Foo<Integer> f9 = new Pos03<U>.Foo<>(1, "");
+        Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1, "");
+        Foo<?> f11 = new Pos03<U>.Foo<>(1, "");
+        Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1, "");
+
+        Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){};
+        Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){};
+        Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){};
+    }
+
+    void testQualified_2(Pos03<U> p) {
+        Foo<Integer> f1 = p.new Foo<>(1);
+        Foo<? extends Integer> f2 = p.new Foo<>(1);
+        Foo<?> f3 = p.new Foo<>(1);
+        Foo<? super Integer> f4 = p.new Foo<>(1);
+
+        Foo<Integer> f5 = p.new Foo<>(1){};
+        Foo<? extends Integer> f6 = p.new Foo<>(1){};
+        Foo<?> f7 = p.new Foo<>(1){};
+        Foo<? super Integer> f8 = p.new Foo<>(1){};
+
+        Foo<Integer> f9 = p.new Foo<>(1, "");
+        Foo<? extends Integer> f10 = p.new Foo<>(1, "");
+        Foo<?> f11 = p.new Foo<>(1, "");
+        Foo<? super Integer> f12 = p.new Foo<>(1, "");
+
+        Foo<Integer> f13 = p.new Foo<>(1, ""){};
+        Foo<? extends Integer> f14 = p.new Foo<>(1, ""){};
+        Foo<?> f15 = p.new Foo<>(1, ""){};
+        Foo<? super Integer> f16 = p.new Foo<>(1, ""){};
+    }
+
+    public static void main(String[] args) {
+        Pos03<String> p3 = new Pos03<>();
+        p3.testSimple();
+        p3.testQualified_1();
+        p3.testQualified_2(p3);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos04.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile Pos04.java
+ * @run main Pos04
+ *
+ */
+
+public class Pos04<U> {
+
+    void test() {
+        class Foo<V> {
+            Foo(V x) {}
+            <Z> Foo(V x, Z z) {}
+        }
+        Foo<Integer> p1 = new Foo<>(1);
+        Foo<? extends Integer> p2 = new Foo<>(1);
+        Foo<?> p3 = new Foo<>(1);
+        Foo<? super Integer> p4 = new Foo<>(1);
+
+        Foo<Integer> p5 = new Foo<>(1){};
+        Foo<? extends Integer> p6 = new Foo<>(1){};
+        Foo<?> p7 = new Foo<>(1){};
+        Foo<? super Integer> p8 = new Foo<>(1){};
+
+        Foo<Integer> p9 = new Foo<>(1, "");
+        Foo<? extends Integer> p10 = new Foo<>(1, "");
+        Foo<?> p11 = new Foo<>(1, "");
+        Foo<? super Integer> p12 = new Foo<>(1, "");
+
+        Foo<Integer> p13 = new Foo<>(1, ""){};
+        Foo<? extends Integer> p14 = new Foo<>(1, ""){};
+        Foo<?> p15 = new Foo<>(1, ""){};
+        Foo<? super Integer> p16 = new Foo<>(1, ""){};
+    }
+
+    public static void main(String[] args) {
+        Pos04<String> p4 = new Pos04<>();
+        p4.test();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/pos/Pos05.java	Wed Apr 14 12:31:55 2010 +0100
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2010 Sun Microsystems, Inc.  All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6939620
+ *
+ * @summary  Switch to 'complex' diamond inference scheme
+ * @author mcimadamore
+ * @compile Pos05.java
+ *
+ */
+
+public class Pos05 {
+
+    static class Foo<X> {
+        Foo(X x) {}
+    }
+
+    void m(Foo<Integer> fi) {}
+
+    void test() {
+        m(new Foo<>(1));
+    }
+}