mcimadamore@792: /*
mcimadamore@792: * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
mcimadamore@792: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mcimadamore@792: *
mcimadamore@792: * This code is free software; you can redistribute it and/or modify it
mcimadamore@792: * under the terms of the GNU General Public License version 2 only, as
mcimadamore@792: * published by the Free Software Foundation.
mcimadamore@792: *
mcimadamore@792: * This code is distributed in the hope that it will be useful, but WITHOUT
mcimadamore@792: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mcimadamore@792: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mcimadamore@792: * version 2 for more details (a copy is included in the LICENSE file that
mcimadamore@792: * accompanied this code).
mcimadamore@792: *
mcimadamore@792: * You should have received a copy of the GNU General Public License version
mcimadamore@792: * 2 along with this work; if not, write to the Free Software Foundation,
mcimadamore@792: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mcimadamore@792: *
mcimadamore@792: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mcimadamore@792: * or visit www.oracle.com if you need additional information or have any
mcimadamore@792: * questions.
mcimadamore@792: */
mcimadamore@792:
mcimadamore@792: import com.sun.tools.javac.code.BoundKind;
mcimadamore@792: import com.sun.tools.javac.code.Flags;
mcimadamore@792: import com.sun.tools.javac.util.Context;
mcimadamore@792: import com.sun.tools.javac.code.Types;
mcimadamore@792: import com.sun.tools.javac.code.Symtab;
mcimadamore@792: import com.sun.tools.javac.code.Type;
mcimadamore@792: import com.sun.tools.javac.code.Type.*;
mcimadamore@792: import com.sun.tools.javac.code.Symbol.*;
mcimadamore@792: import com.sun.tools.javac.util.List;
mcimadamore@792: import com.sun.tools.javac.util.ListBuffer;
mcimadamore@792: import com.sun.tools.javac.util.Name;
mcimadamore@792: import com.sun.tools.javac.util.Names;
mcimadamore@792: import com.sun.tools.javac.file.JavacFileManager;
mcimadamore@792:
mcimadamore@792: /**
mcimadamore@792: * Test harness whose goal is to simplify the task of writing type-system
mcimadamore@792: * regression test. It provides functionalities to build custom types as well
mcimadamore@792: * as to access the underlying javac's symbol table in order to retrieve
mcimadamore@792: * predefined types. Among the features supported by the harness are: type
mcimadamore@792: * substitution, type containment, subtyping, cast-conversion, assigment
mcimadamore@792: * conversion.
mcimadamore@792: *
mcimadamore@792: * This class is meant to be a common super class for all concrete type test
mcimadamore@792: * classes. A subclass can access the type-factory and the test methods so as
mcimadamore@792: * to write compact tests. An example is reported below:
mcimadamore@792: *
mcimadamore@792: *
mcimadamore@792: * Type X = fac.TypeVariable();
mcimadamore@792: * Type Y = fac.TypeVariable();
mcimadamore@792: * Type A_X_Y = fac.Class(0, X, Y);
mcimadamore@792: * Type A_Obj_Obj = fac.Class(0,
mcimadamore@792: * predef.objectType,
mcimadamore@792: * predef.objectType);
mcimadamore@792: * checkSameType(A_Obj_Obj, subst(A_X_Y,
mcimadamore@792: * Mapping(X, predef.objectType),
mcimadamore@792: * Mapping(Y, predef.objectType)));
mcimadamore@792: *
mcimadamore@792: *
mcimadamore@792: * The above code is used to create two class types, namely {@code A} and
mcimadamore@792: * {@code A