author | mcimadamore |
Mon, 13 Dec 2010 14:56:50 +0000 | |
changeset 7640 | 5d199da591db |
child 8037 | b3f278fe95d6 |
permissions | -rw-r--r-- |
7640
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
1 |
/* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
4 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
8 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
14 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
18 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
23 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
24 |
import com.sun.tools.javac.code.BoundKind; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
25 |
import com.sun.tools.javac.code.Flags; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
26 |
import com.sun.tools.javac.util.Context; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
27 |
import com.sun.tools.javac.code.Types; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
28 |
import com.sun.tools.javac.code.Symtab; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
29 |
import com.sun.tools.javac.code.Type; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
30 |
import com.sun.tools.javac.code.Type.*; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
31 |
import com.sun.tools.javac.code.Symbol.*; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
32 |
import com.sun.tools.javac.util.List; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
33 |
import com.sun.tools.javac.util.ListBuffer; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
34 |
import com.sun.tools.javac.util.Name; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
35 |
import com.sun.tools.javac.util.Names; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
36 |
import com.sun.tools.javac.file.JavacFileManager; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
37 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
38 |
/** |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
39 |
* Test harness whose goal is to simplify the task of writing type-system |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
40 |
* regression test. It provides functionalities to build custom types as well |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
41 |
* as to access the underlying javac's symbol table in order to retrieve |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
42 |
* predefined types. Among the features supported by the harness are: type |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
43 |
* substitution, type containment, subtyping, cast-conversion, assigment |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
44 |
* conversion. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
45 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
46 |
* This class is meant to be a common super class for all concrete type test |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
47 |
* classes. A subclass can access the type-factory and the test methods so as |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
48 |
* to write compact tests. An example is reported below: |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
49 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
50 |
* <pre> |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
51 |
* Type X = fac.TypeVariable(); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
52 |
* Type Y = fac.TypeVariable(); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
53 |
* Type A_X_Y = fac.Class(0, X, Y); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
54 |
* Type A_Obj_Obj = fac.Class(0, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
55 |
* predef.objectType, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
56 |
* predef.objectType); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
57 |
* checkSameType(A_Obj_Obj, subst(A_X_Y, |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
58 |
* Mapping(X, predef.objectType), |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
59 |
* Mapping(Y, predef.objectType))); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
60 |
* </pre> |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
61 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
62 |
* The above code is used to create two class types, namely {@code A<X,Y>} and |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
63 |
* {@code A<Object,Object>} where both {@code X} and {@code Y} are type-variables. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
64 |
* The code then verifies that {@code [X:=Object,Y:=Object]A<X,Y> == A<Object,Object>}. |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
65 |
* |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
66 |
* @author mcimadamore |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
67 |
*/ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
68 |
public class TypeHarness { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
69 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
70 |
protected Types types; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
71 |
protected Symtab predef; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
72 |
protected Names names; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
73 |
protected Factory fac; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
74 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
75 |
protected TypeHarness() { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
76 |
Context ctx = new Context(); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
77 |
JavacFileManager.preRegister(ctx); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
78 |
types = Types.instance(ctx); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
79 |
predef = Symtab.instance(ctx); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
80 |
names = Names.instance(ctx); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
81 |
fac = new Factory(); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
82 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
83 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
84 |
// <editor-fold defaultstate="collapsed" desc="type assertions"> |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
85 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
86 |
/** assert that 's' is a subtype of 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
87 |
public void assertSubtype(Type s, Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
88 |
assertSubtype(s, t, true); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
89 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
90 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
91 |
/** assert that 's' is/is not a subtype of 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
92 |
public void assertSubtype(Type s, Type t, boolean expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
93 |
if (types.isSubtype(s, t) != expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
94 |
String msg = expected ? |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
95 |
" is not a subtype of " : |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
96 |
" is a subtype of "; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
97 |
error(s + msg + t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
98 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
99 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
100 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
101 |
/** assert that 's' is the same type as 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
102 |
public void assertSameType(Type s, Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
103 |
assertSameType(s, t, true); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
104 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
105 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
106 |
/** assert that 's' is/is not the same type as 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
107 |
public void assertSameType(Type s, Type t, boolean expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
108 |
if (types.isSameType(s, t) != expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
109 |
String msg = expected ? |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
110 |
" is not the same type as " : |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
111 |
" is the same type as "; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
112 |
error(s + msg + t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
113 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
114 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
115 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
116 |
/** assert that 's' is castable to 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
117 |
public void assertCastable(Type s, Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
118 |
assertCastable(s, t, true); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
119 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
120 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
121 |
/** assert that 's' is/is not castable to 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
122 |
public void assertCastable(Type s, Type t, boolean expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
123 |
if (types.isCastable(s, t) != expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
124 |
String msg = expected ? |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
125 |
" is not castable to " : |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
126 |
" is castable to "; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
127 |
error(s + msg + t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
128 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
129 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
130 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
131 |
/** assert that 's' is convertible (method invocation conversion) to 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
132 |
public void assertConvertible(Type s, Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
133 |
assertCastable(s, t, true); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
134 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
135 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
136 |
/** assert that 's' is/is not convertible (method invocation conversion) to 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
137 |
public void assertConvertible(Type s, Type t, boolean expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
138 |
if (types.isConvertible(s, t) != expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
139 |
String msg = expected ? |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
140 |
" is not convertible to " : |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
141 |
" is convertible to "; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
142 |
error(s + msg + t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
143 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
144 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
145 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
146 |
/** assert that 's' is assignable to 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
147 |
public void assertAssignable(Type s, Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
148 |
assertCastable(s, t, true); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
149 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
150 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
151 |
/** assert that 's' is/is not assignable to 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
152 |
public void assertAssignable(Type s, Type t, boolean expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
153 |
if (types.isAssignable(s, t) != expected) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
154 |
String msg = expected ? |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
155 |
" is not assignable to " : |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
156 |
" is assignable to "; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
157 |
error(s + msg + t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
158 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
159 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
160 |
// </editor-fold> |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
161 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
162 |
private void error(String msg) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
163 |
throw new AssertionError("Unexpected result: " + msg); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
164 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
165 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
166 |
// <editor-fold defaultstate="collapsed" desc="type functions"> |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
167 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
168 |
/** compute the erasure of a type 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
169 |
public Type erasure(Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
170 |
return types.erasure(t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
171 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
172 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
173 |
/** compute the capture of a type 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
174 |
public Type capture(Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
175 |
return types.capture(t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
176 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
177 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
178 |
/** compute the boxed type associated with 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
179 |
public Type box(Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
180 |
if (!t.isPrimitive()) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
181 |
throw new AssertionError("Cannot box non-primitive type: " + t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
182 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
183 |
return types.boxedClass(t).type; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
184 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
185 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
186 |
/** compute the unboxed type associated with 't' */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
187 |
public Type unbox(Type t) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
188 |
Type u = types.unboxedType(t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
189 |
if (t == null) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
190 |
throw new AssertionError("Cannot unbox reference type: " + t); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
191 |
} else { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
192 |
return u; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
193 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
194 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
195 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
196 |
/** compute a type substitution on 't' given a list of type mappings */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
197 |
public Type subst(Type t, Mapping... maps) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
198 |
ListBuffer<Type> from = ListBuffer.lb(); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
199 |
ListBuffer<Type> to = ListBuffer.lb(); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
200 |
for (Mapping tm : maps) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
201 |
from.append(tm.from); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
202 |
to.append(tm.to); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
203 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
204 |
return types.subst(t, from.toList(), to.toList()); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
205 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
206 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
207 |
/** create a fresh type mapping from a type to another */ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
208 |
public Mapping Mapping(Type from, Type to) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
209 |
return new Mapping(from, to); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
210 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
211 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
212 |
public static class Mapping { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
213 |
Type from; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
214 |
Type to; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
215 |
private Mapping(Type from, Type to) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
216 |
this.from = from; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
217 |
this.to = to; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
218 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
219 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
220 |
// </editor-fold> |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
221 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
222 |
// <editor-fold defaultstate="collapsed" desc="type factory"> |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
223 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
224 |
/** |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
225 |
* This class is used to create Java types in a simple way. All main |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
226 |
* kinds of type are supported: primitive, reference, non-denotable. The |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
227 |
* factory also supports creation of constant types (used by the compiler |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
228 |
* to represent the type of a literal). |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
229 |
*/ |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
230 |
public class Factory { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
231 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
232 |
private int synthNameCount = 0; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
233 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
234 |
private Name syntheticName() { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
235 |
return names.fromString("A$" + synthNameCount++); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
236 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
237 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
238 |
public ClassType Class(long flags, Type... typeArgs) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
239 |
ClassSymbol csym = new ClassSymbol(flags, syntheticName(), predef.noSymbol); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
240 |
csym.type = new ClassType(Type.noType, List.from(typeArgs), csym); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
241 |
((ClassType)csym.type).supertype_field = predef.objectType; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
242 |
return (ClassType)csym.type; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
243 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
244 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
245 |
public ClassType Class(Type... typeArgs) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
246 |
return Class(0, typeArgs); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
247 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
248 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
249 |
public ClassType Interface(Type... typeArgs) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
250 |
return Class(Flags.INTERFACE, typeArgs); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
251 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
252 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
253 |
public ClassType Interface(long flags, Type... typeArgs) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
254 |
return Class(Flags.INTERFACE | flags, typeArgs); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
255 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
256 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
257 |
public Type Constant(byte b) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
258 |
return predef.byteType.constType(b); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
259 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
260 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
261 |
public Type Constant(short s) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
262 |
return predef.shortType.constType(s); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
263 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
264 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
265 |
public Type Constant(int i) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
266 |
return predef.intType.constType(i); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
267 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
268 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
269 |
public Type Constant(long l) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
270 |
return predef.longType.constType(l); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
271 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
272 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
273 |
public Type Constant(float f) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
274 |
return predef.floatType.constType(f); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
275 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
276 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
277 |
public Type Constant(double d) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
278 |
return predef.doubleType.constType(d); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
279 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
280 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
281 |
public Type Constant(char c) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
282 |
return predef.charType.constType(c + 0); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
283 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
284 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
285 |
public ArrayType Array(Type elemType) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
286 |
return new ArrayType(elemType, predef.arrayClass); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
287 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
288 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
289 |
public TypeVar TypeVariable() { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
290 |
return TypeVariable(predef.objectType); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
291 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
292 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
293 |
public TypeVar TypeVariable(Type bound) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
294 |
TypeSymbol tvsym = new TypeSymbol(0, syntheticName(), null, predef.noSymbol); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
295 |
tvsym.type = new TypeVar(tvsym, bound, null); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
296 |
return (TypeVar)tvsym.type; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
297 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
298 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
299 |
public WildcardType Wildcard(BoundKind bk, Type bound) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
300 |
return new WildcardType(bound, bk, predef.boundClass); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
301 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
302 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
303 |
public CapturedType CapturedVariable(Type upper, Type lower) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
304 |
return new CapturedType(syntheticName(), predef.noSymbol, upper, lower, null); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
305 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
306 |
|
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
307 |
public ClassType Intersection(Type classBound, Type... intfBounds) { |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
308 |
ClassType ct = Class(Flags.COMPOUND); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
309 |
ct.supertype_field = classBound; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
310 |
ct.interfaces_field = List.from(intfBounds); |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
311 |
return ct; |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
312 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
313 |
} |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
314 |
// </editor-fold> |
5d199da591db
7006109: Add test library to simplify the task of writing automated type-system tests
mcimadamore
parents:
diff
changeset
|
315 |
} |