test/tools/javac/types/TypeHarness.java

changeset 821
c8d312dd17bc
parent 792
2199365892b1
child 962
0ff2bbd38f10
     1.1 --- a/test/tools/javac/types/TypeHarness.java	Fri Jan 14 09:45:04 2011 +0000
     1.2 +++ b/test/tools/javac/types/TypeHarness.java	Fri Jan 14 09:45:52 2011 +0000
     1.3 @@ -29,6 +29,7 @@
     1.4  import com.sun.tools.javac.code.Type;
     1.5  import com.sun.tools.javac.code.Type.*;
     1.6  import com.sun.tools.javac.code.Symbol.*;
     1.7 +import com.sun.tools.javac.comp.Check;
     1.8  import com.sun.tools.javac.util.List;
     1.9  import com.sun.tools.javac.util.ListBuffer;
    1.10  import com.sun.tools.javac.util.Name;
    1.11 @@ -68,6 +69,7 @@
    1.12  public class TypeHarness {
    1.13  
    1.14      protected Types types;
    1.15 +    protected Check chk;
    1.16      protected Symtab predef;
    1.17      protected Names names;
    1.18      protected Factory fac;
    1.19 @@ -76,6 +78,7 @@
    1.20          Context ctx = new Context();
    1.21          JavacFileManager.preRegister(ctx);
    1.22          types = Types.instance(ctx);
    1.23 +        chk = Check.instance(ctx);
    1.24          predef = Symtab.instance(ctx);
    1.25          names = Names.instance(ctx);
    1.26          fac = new Factory();
    1.27 @@ -157,6 +160,21 @@
    1.28              error(s + msg + t);
    1.29          }
    1.30      }
    1.31 +
    1.32 +    /** assert that generic type 't' is well-formed */
    1.33 +    public void assertValidGenericType(Type t) {
    1.34 +        assertValidGenericType(t, true);
    1.35 +    }
    1.36 +
    1.37 +    /** assert that 's' is/is not assignable to 't' */
    1.38 +    public void assertValidGenericType(Type t, boolean expected) {
    1.39 +        if (chk.checkValidGenericType(t) != expected) {
    1.40 +            String msg = expected ?
    1.41 +                " is not a valid generic type" :
    1.42 +                " is a valid generic type";
    1.43 +            error(t + msg + "   " + t.tsym.type);
    1.44 +        }
    1.45 +    }
    1.46      // </editor-fold>
    1.47  
    1.48      private void error(String msg) {

mercurial