author | mcimadamore |
Wed, 17 Jul 2013 14:21:12 +0100 | |
changeset 18918 | 4e8769f15a95 |
parent 18911 | dcc1e26a8c9c |
child 19493 | f2028bc02f0c |
permissions | -rw-r--r-- |
10 | 1 |
/* |
15385 | 2 |
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.javac.code; |
|
27 |
||
16557
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
28 |
import java.lang.annotation.Annotation; |
9599
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
29 |
import java.util.Collections; |
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
30 |
import java.util.EnumMap; |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
31 |
import java.util.EnumSet; |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
32 |
import java.util.Map; |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
33 |
import java.util.Set; |
14052 | 34 |
|
10 | 35 |
import javax.lang.model.type.*; |
36 |
||
14258 | 37 |
import com.sun.tools.javac.code.Symbol.*; |
17578 | 38 |
import com.sun.tools.javac.model.JavacAnnoConstructs; |
14258 | 39 |
import com.sun.tools.javac.util.*; |
14052 | 40 |
import static com.sun.tools.javac.code.BoundKind.*; |
10 | 41 |
import static com.sun.tools.javac.code.Flags.*; |
42 |
import static com.sun.tools.javac.code.Kinds.*; |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
43 |
import static com.sun.tools.javac.code.TypeTag.*; |
10 | 44 |
|
45 |
/** This class represents Java types. The class itself defines the behavior of |
|
46 |
* the following types: |
|
47 |
* <pre> |
|
48 |
* base types (tags: BYTE, CHAR, SHORT, INT, LONG, FLOAT, DOUBLE, BOOLEAN), |
|
49 |
* type `void' (tag: VOID), |
|
50 |
* the bottom type (tag: BOT), |
|
51 |
* the missing type (tag: NONE). |
|
52 |
* </pre> |
|
53 |
* <p>The behavior of the following types is defined in subclasses, which are |
|
54 |
* all static inner classes of this class: |
|
55 |
* <pre> |
|
56 |
* class types (tag: CLASS, class: ClassType), |
|
57 |
* array types (tag: ARRAY, class: ArrayType), |
|
58 |
* method types (tag: METHOD, class: MethodType), |
|
59 |
* package types (tag: PACKAGE, class: PackageType), |
|
60 |
* type variables (tag: TYPEVAR, class: TypeVar), |
|
61 |
* type arguments (tag: WILDCARD, class: WildcardType), |
|
12915
28cf1e0dafdc
7166552: Inference: cleanup usage of Type.ForAll
mcimadamore
parents:
12468
diff
changeset
|
62 |
* generic method types (tag: FORALL, class: ForAll), |
10 | 63 |
* the error type (tag: ERROR, class: ErrorType). |
64 |
* </pre> |
|
65 |
* |
|
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
66 |
* <p><b>This is NOT part of any supported API. |
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
67 |
* If you write code that depends on this, you do so at your own risk. |
10 | 68 |
* This code and its internal interfaces are subject to change or |
69 |
* deletion without notice.</b> |
|
70 |
* |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
71 |
* @see TypeTag |
10 | 72 |
*/ |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
73 |
public abstract class Type implements TypeMirror { |
10 | 74 |
|
75 |
/** Constant type: no type at all. */ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
76 |
public static final JCNoType noType = new JCNoType(); |
10 | 77 |
|
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14052
diff
changeset
|
78 |
/** Constant type: special type to be used during recovery of deferred expressions. */ |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
79 |
public static final JCNoType recoveryType = new JCNoType(); |
14057
b4b0377b8dba
7177387: Add target-typing support in method context
mcimadamore
parents:
14052
diff
changeset
|
80 |
|
18902 | 81 |
/** Constant type: special type to be used for marking stuck trees. */ |
82 |
public static final JCNoType stuckType = new JCNoType(); |
|
83 |
||
10 | 84 |
/** If this switch is turned on, the names of type variables |
85 |
* and anonymous classes are printed with hashcodes appended. |
|
86 |
*/ |
|
87 |
public static boolean moreInfo = false; |
|
88 |
||
15385 | 89 |
/** The defining class / interface / package / type variable. |
10 | 90 |
*/ |
91 |
public TypeSymbol tsym; |
|
92 |
||
93 |
/** |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
94 |
* Checks if the current type tag is equal to the given tag. |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
95 |
* @return true if tag is equal to the current type tag. |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
96 |
*/ |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
97 |
public boolean hasTag(TypeTag tag) { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
98 |
return tag == getTag(); |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
99 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
100 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
101 |
/** |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
102 |
* Returns the current type tag. |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
103 |
* @return the value of the current type tag. |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
104 |
*/ |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
105 |
public abstract TypeTag getTag(); |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
106 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
107 |
public boolean isNumeric() { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
108 |
return false; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
109 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
110 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
111 |
public boolean isPrimitive() { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
112 |
return false; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
113 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
114 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
115 |
public boolean isPrimitiveOrVoid() { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
116 |
return false; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
117 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
118 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
119 |
public boolean isReference() { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
120 |
return false; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
121 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
122 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
123 |
public boolean isNullOrReference() { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
124 |
return false; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
125 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
126 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
127 |
public boolean isPartial() { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
128 |
return false; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
129 |
} |
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
130 |
|
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
131 |
/** |
10 | 132 |
* The constant value of this type, null if this type does not |
133 |
* have a constant value attribute. Only primitive types and |
|
134 |
* strings (ClassType) can have a constant value attribute. |
|
135 |
* @return the constant value attribute of this type |
|
136 |
*/ |
|
137 |
public Object constValue() { |
|
138 |
return null; |
|
139 |
} |
|
140 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
141 |
/** Is this a constant type whose value is false? |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
142 |
*/ |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
143 |
public boolean isFalse() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
144 |
return false; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
145 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
146 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
147 |
/** Is this a constant type whose value is true? |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
148 |
*/ |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
149 |
public boolean isTrue() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
150 |
return false; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
151 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
152 |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
153 |
/** |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
154 |
* Get the representation of this type used for modelling purposes. |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
155 |
* By default, this is itself. For ErrorType, a different value |
15385 | 156 |
* may be provided. |
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
157 |
*/ |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
158 |
public Type getModelType() { |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
159 |
return this; |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
160 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
161 |
|
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
162 |
public static List<Type> getModelTypes(List<Type> ts) { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
163 |
ListBuffer<Type> lb = new ListBuffer<>(); |
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
164 |
for (Type t: ts) |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
165 |
lb.append(t.getModelType()); |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
166 |
return lb.toList(); |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
167 |
} |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
168 |
|
10 | 169 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { return v.visitType(this, s); } |
170 |
||
171 |
/** Define a type given its tag and type symbol |
|
172 |
*/ |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
173 |
public Type(TypeSymbol tsym) { |
10 | 174 |
this.tsym = tsym; |
175 |
} |
|
176 |
||
177 |
/** An abstract class for mappings from types to types |
|
178 |
*/ |
|
179 |
public static abstract class Mapping { |
|
180 |
private String name; |
|
181 |
public Mapping(String name) { |
|
182 |
this.name = name; |
|
183 |
} |
|
184 |
public abstract Type apply(Type t); |
|
185 |
public String toString() { |
|
186 |
return name; |
|
187 |
} |
|
188 |
} |
|
189 |
||
190 |
/** map a type function over all immediate descendants of this type |
|
191 |
*/ |
|
192 |
public Type map(Mapping f) { |
|
193 |
return this; |
|
194 |
} |
|
195 |
||
196 |
/** map a type function over a list of types |
|
197 |
*/ |
|
198 |
public static List<Type> map(List<Type> ts, Mapping f) { |
|
199 |
if (ts.nonEmpty()) { |
|
200 |
List<Type> tail1 = map(ts.tail, f); |
|
201 |
Type t = f.apply(ts.head); |
|
202 |
if (tail1 != ts.tail || t != ts.head) |
|
203 |
return tail1.prepend(t); |
|
204 |
} |
|
205 |
return ts; |
|
206 |
} |
|
207 |
||
208 |
/** Define a constant type, of the same kind as this type |
|
209 |
* and with given constant value |
|
210 |
*/ |
|
211 |
public Type constType(Object constValue) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
212 |
throw new AssertionError(); |
10 | 213 |
} |
214 |
||
215 |
/** |
|
216 |
* If this is a constant type, return its underlying type. |
|
217 |
* Otherwise, return the type itself. |
|
218 |
*/ |
|
219 |
public Type baseType() { |
|
220 |
return this; |
|
221 |
} |
|
222 |
||
16556
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
223 |
public boolean isAnnotated() { |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
224 |
return false; |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
225 |
} |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
226 |
|
15385 | 227 |
/** |
228 |
* If this is an annotated type, return the underlying type. |
|
229 |
* Otherwise, return the type itself. |
|
230 |
*/ |
|
231 |
public Type unannotatedType() { |
|
232 |
return this; |
|
233 |
} |
|
234 |
||
16557
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
235 |
@Override |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
236 |
public List<? extends Attribute.TypeCompound> getAnnotationMirrors() { |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
237 |
return List.nil(); |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
238 |
} |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
239 |
|
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
240 |
@Override |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
241 |
public <A extends Annotation> A getAnnotation(Class<A> annotationType) { |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
242 |
return null; |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
243 |
} |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
244 |
|
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
245 |
@Override |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
246 |
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) { |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
247 |
@SuppressWarnings("unchecked") |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
248 |
A[] tmp = (A[]) java.lang.reflect.Array.newInstance(annotationType, 0); |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
249 |
return tmp; |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
250 |
} |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
251 |
|
10 | 252 |
/** Return the base types of a list of types. |
253 |
*/ |
|
254 |
public static List<Type> baseTypes(List<Type> ts) { |
|
255 |
if (ts.nonEmpty()) { |
|
256 |
Type t = ts.head.baseType(); |
|
257 |
List<Type> baseTypes = baseTypes(ts.tail); |
|
258 |
if (t != ts.head || baseTypes != ts.tail) |
|
259 |
return baseTypes.prepend(t); |
|
260 |
} |
|
261 |
return ts; |
|
262 |
} |
|
263 |
||
264 |
/** The Java source which this type represents. |
|
265 |
*/ |
|
266 |
public String toString() { |
|
267 |
String s = (tsym == null || tsym.name == null) |
|
268 |
? "<none>" |
|
269 |
: tsym.name.toString(); |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
270 |
if (moreInfo && hasTag(TYPEVAR)) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
271 |
s = s + hashCode(); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
272 |
} |
10 | 273 |
return s; |
274 |
} |
|
275 |
||
276 |
/** |
|
277 |
* The Java source which this type list represents. A List is |
|
278 |
* represented as a comma-spearated listing of the elements in |
|
279 |
* that list. |
|
280 |
*/ |
|
281 |
public static String toString(List<Type> ts) { |
|
282 |
if (ts.isEmpty()) { |
|
283 |
return ""; |
|
284 |
} else { |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
285 |
StringBuilder buf = new StringBuilder(); |
10 | 286 |
buf.append(ts.head.toString()); |
287 |
for (List<Type> l = ts.tail; l.nonEmpty(); l = l.tail) |
|
288 |
buf.append(",").append(l.head.toString()); |
|
289 |
return buf.toString(); |
|
290 |
} |
|
291 |
} |
|
292 |
||
293 |
/** |
|
294 |
* The constant value of this type, converted to String |
|
295 |
*/ |
|
296 |
public String stringValue() { |
|
8032 | 297 |
Object cv = Assert.checkNonNull(constValue()); |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
298 |
return cv.toString(); |
10 | 299 |
} |
300 |
||
301 |
/** |
|
302 |
* This method is analogous to isSameType, but weaker, since we |
|
303 |
* never complete classes. Where isSameType would complete a |
|
304 |
* class, equals assumes that the two types are different. |
|
305 |
*/ |
|
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14725
diff
changeset
|
306 |
@Override |
10 | 307 |
public boolean equals(Object t) { |
308 |
return super.equals(t); |
|
309 |
} |
|
310 |
||
14949
45f43822bbde
8000518: Javac generates duplicate name_and_type constant pool entry for class BinaryOpValueExp.java
vromero
parents:
14725
diff
changeset
|
311 |
@Override |
10 | 312 |
public int hashCode() { |
313 |
return super.hashCode(); |
|
314 |
} |
|
315 |
||
316 |
public String argtypes(boolean varargs) { |
|
317 |
List<Type> args = getParameterTypes(); |
|
318 |
if (!varargs) return args.toString(); |
|
7637 | 319 |
StringBuilder buf = new StringBuilder(); |
10 | 320 |
while (args.tail.nonEmpty()) { |
321 |
buf.append(args.head); |
|
322 |
args = args.tail; |
|
323 |
buf.append(','); |
|
324 |
} |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
325 |
if (args.head.unannotatedType().hasTag(ARRAY)) { |
15385 | 326 |
buf.append(((ArrayType)args.head.unannotatedType()).elemtype); |
16557
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
327 |
if (args.head.getAnnotationMirrors().nonEmpty()) { |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
328 |
buf.append(args.head.getAnnotationMirrors()); |
15385 | 329 |
} |
10 | 330 |
buf.append("..."); |
331 |
} else { |
|
332 |
buf.append(args.head); |
|
333 |
} |
|
334 |
return buf.toString(); |
|
335 |
} |
|
336 |
||
337 |
/** Access methods. |
|
338 |
*/ |
|
339 |
public List<Type> getTypeArguments() { return List.nil(); } |
|
15385 | 340 |
public Type getEnclosingType() { return null; } |
10 | 341 |
public List<Type> getParameterTypes() { return List.nil(); } |
342 |
public Type getReturnType() { return null; } |
|
15385 | 343 |
public Type getReceiverType() { return null; } |
10 | 344 |
public List<Type> getThrownTypes() { return List.nil(); } |
345 |
public Type getUpperBound() { return null; } |
|
346 |
public Type getLowerBound() { return null; } |
|
347 |
||
348 |
/** Navigation methods, these will work for classes, type variables, |
|
349 |
* foralls, but will return null for arrays and methods. |
|
350 |
*/ |
|
351 |
||
352 |
/** Return all parameters of this type and all its outer types in order |
|
353 |
* outer (first) to inner (last). |
|
354 |
*/ |
|
355 |
public List<Type> allparams() { return List.nil(); } |
|
356 |
||
357 |
/** Does this type contain "error" elements? |
|
358 |
*/ |
|
359 |
public boolean isErroneous() { |
|
360 |
return false; |
|
361 |
} |
|
362 |
||
363 |
public static boolean isErroneous(List<Type> ts) { |
|
364 |
for (List<Type> l = ts; l.nonEmpty(); l = l.tail) |
|
365 |
if (l.head.isErroneous()) return true; |
|
366 |
return false; |
|
367 |
} |
|
368 |
||
369 |
/** Is this type parameterized? |
|
370 |
* A class type is parameterized if it has some parameters. |
|
371 |
* An array type is parameterized if its element type is parameterized. |
|
372 |
* All other types are not parameterized. |
|
373 |
*/ |
|
374 |
public boolean isParameterized() { |
|
375 |
return false; |
|
376 |
} |
|
377 |
||
378 |
/** Is this type a raw type? |
|
379 |
* A class type is a raw type if it misses some of its parameters. |
|
380 |
* An array type is a raw type if its element type is raw. |
|
381 |
* All other types are not raw. |
|
382 |
* Type validation will ensure that the only raw types |
|
383 |
* in a program are types that miss all their type variables. |
|
384 |
*/ |
|
385 |
public boolean isRaw() { |
|
386 |
return false; |
|
387 |
} |
|
388 |
||
389 |
public boolean isCompound() { |
|
390 |
return tsym.completer == null |
|
391 |
// Compound types can't have a completer. Calling |
|
392 |
// flags() will complete the symbol causing the |
|
393 |
// compiler to load classes unnecessarily. This led |
|
394 |
// to regression 6180021. |
|
395 |
&& (tsym.flags() & COMPOUND) != 0; |
|
396 |
} |
|
397 |
||
398 |
public boolean isInterface() { |
|
399 |
return (tsym.flags() & INTERFACE) != 0; |
|
400 |
} |
|
401 |
||
6353
bb5c39054bf3
6932571: Compiling Generics causing Inconvertible types
mcimadamore
parents:
6348
diff
changeset
|
402 |
public boolean isFinal() { |
bb5c39054bf3
6932571: Compiling Generics causing Inconvertible types
mcimadamore
parents:
6348
diff
changeset
|
403 |
return (tsym.flags() & FINAL) != 0; |
bb5c39054bf3
6932571: Compiling Generics causing Inconvertible types
mcimadamore
parents:
6348
diff
changeset
|
404 |
} |
bb5c39054bf3
6932571: Compiling Generics causing Inconvertible types
mcimadamore
parents:
6348
diff
changeset
|
405 |
|
10 | 406 |
/** |
407 |
* Does this type contain occurrences of type t? |
|
408 |
*/ |
|
409 |
public boolean contains(Type t) { |
|
410 |
return t == this; |
|
411 |
} |
|
412 |
||
413 |
public static boolean contains(List<Type> ts, Type t) { |
|
414 |
for (List<Type> l = ts; |
|
415 |
l.tail != null /*inlined: l.nonEmpty()*/; |
|
416 |
l = l.tail) |
|
417 |
if (l.head.contains(t)) return true; |
|
418 |
return false; |
|
419 |
} |
|
420 |
||
6348
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
421 |
/** Does this type contain an occurrence of some type in 'ts'? |
10 | 422 |
*/ |
6348
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
423 |
public boolean containsAny(List<Type> ts) { |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
424 |
for (Type t : ts) |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
425 |
if (this.contains(t)) return true; |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
426 |
return false; |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
427 |
} |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
428 |
|
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
429 |
public static boolean containsAny(List<Type> ts1, List<Type> ts2) { |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
430 |
for (Type t : ts1) |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
431 |
if (t.containsAny(ts2)) return true; |
10 | 432 |
return false; |
433 |
} |
|
434 |
||
8044
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
435 |
public static List<Type> filter(List<Type> ts, Filter<Type> tf) { |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
436 |
ListBuffer<Type> buf = ListBuffer.lb(); |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
437 |
for (Type t : ts) { |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
438 |
if (tf.accepts(t)) { |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
439 |
buf.append(t); |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
440 |
} |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
441 |
} |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
442 |
return buf.toList(); |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
443 |
} |
7fd529d4472c
6943278: spurious error message for inference and type-variable with erroneous bound
mcimadamore
parents:
8032
diff
changeset
|
444 |
|
10 | 445 |
public boolean isSuperBound() { return false; } |
446 |
public boolean isExtendsBound() { return false; } |
|
447 |
public boolean isUnbound() { return false; } |
|
448 |
public Type withTypeVar(Type t) { return this; } |
|
449 |
||
450 |
/** The underlying method type of this type. |
|
451 |
*/ |
|
452 |
public MethodType asMethodType() { throw new AssertionError(); } |
|
453 |
||
454 |
/** Complete loading all classes in this type. |
|
455 |
*/ |
|
456 |
public void complete() {} |
|
457 |
||
458 |
public TypeSymbol asElement() { |
|
459 |
return tsym; |
|
460 |
} |
|
461 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
462 |
@Override |
10 | 463 |
public TypeKind getKind() { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
464 |
return TypeKind.OTHER; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
465 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
466 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
467 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
468 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
469 |
throw new AssertionError(); |
10 | 470 |
} |
471 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
472 |
public static class JCPrimitiveType extends Type |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
473 |
implements javax.lang.model.type.PrimitiveType { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
474 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
475 |
TypeTag tag; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
476 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
477 |
public JCPrimitiveType(TypeTag tag, TypeSymbol tsym) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
478 |
super(tsym); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
479 |
this.tag = tag; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
480 |
Assert.check(tag.isPrimitive); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
481 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
482 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
483 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
484 |
public boolean isNumeric() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
485 |
return tag != BOOLEAN; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
486 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
487 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
488 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
489 |
public boolean isPrimitive() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
490 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
491 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
492 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
493 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
494 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
495 |
return tag; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
496 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
497 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
498 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
499 |
public boolean isPrimitiveOrVoid() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
500 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
501 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
502 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
503 |
/** Define a constant type, of the same kind as this type |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
504 |
* and with given constant value |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
505 |
*/ |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
506 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
507 |
public Type constType(Object constValue) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
508 |
final Object value = constValue; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
509 |
return new JCPrimitiveType(tag, tsym) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
510 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
511 |
public Object constValue() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
512 |
return value; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
513 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
514 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
515 |
public Type baseType() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
516 |
return tsym.type; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
517 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
518 |
}; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
519 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
520 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
521 |
/** |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
522 |
* The constant value of this type, converted to String |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
523 |
*/ |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
524 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
525 |
public String stringValue() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
526 |
Object cv = Assert.checkNonNull(constValue()); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
527 |
if (tag == BOOLEAN) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
528 |
return ((Integer) cv).intValue() == 0 ? "false" : "true"; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
529 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
530 |
else if (tag == CHAR) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
531 |
return String.valueOf((char) ((Integer) cv).intValue()); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
532 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
533 |
else { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
534 |
return cv.toString(); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
535 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
536 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
537 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
538 |
/** Is this a constant type whose value is false? |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
539 |
*/ |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
540 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
541 |
public boolean isFalse() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
542 |
return |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
543 |
tag == BOOLEAN && |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
544 |
constValue() != null && |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
545 |
((Integer)constValue()).intValue() == 0; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
546 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
547 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
548 |
/** Is this a constant type whose value is true? |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
549 |
*/ |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
550 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
551 |
public boolean isTrue() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
552 |
return |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
553 |
tag == BOOLEAN && |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
554 |
constValue() != null && |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
555 |
((Integer)constValue()).intValue() != 0; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
556 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
557 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
558 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
559 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
10 | 560 |
return v.visitPrimitive(this, p); |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
561 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
562 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
563 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
564 |
public TypeKind getKind() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
565 |
switch (tag) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
566 |
case BYTE: return TypeKind.BYTE; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
567 |
case CHAR: return TypeKind.CHAR; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
568 |
case SHORT: return TypeKind.SHORT; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
569 |
case INT: return TypeKind.INT; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
570 |
case LONG: return TypeKind.LONG; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
571 |
case FLOAT: return TypeKind.FLOAT; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
572 |
case DOUBLE: return TypeKind.DOUBLE; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
573 |
case BOOLEAN: return TypeKind.BOOLEAN; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
574 |
} |
10 | 575 |
throw new AssertionError(); |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
576 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
577 |
|
10 | 578 |
} |
579 |
||
580 |
public static class WildcardType extends Type |
|
581 |
implements javax.lang.model.type.WildcardType { |
|
582 |
||
583 |
public Type type; |
|
584 |
public BoundKind kind; |
|
585 |
public TypeVar bound; |
|
586 |
||
587 |
@Override |
|
588 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
|
589 |
return v.visitWildcardType(this, s); |
|
590 |
} |
|
591 |
||
592 |
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
593 |
super(tsym); |
8032 | 594 |
this.type = Assert.checkNonNull(type); |
10 | 595 |
this.kind = kind; |
596 |
} |
|
597 |
public WildcardType(WildcardType t, TypeVar bound) { |
|
598 |
this(t.type, t.kind, t.tsym, bound); |
|
599 |
} |
|
600 |
||
601 |
public WildcardType(Type type, BoundKind kind, TypeSymbol tsym, TypeVar bound) { |
|
602 |
this(type, kind, tsym); |
|
603 |
this.bound = bound; |
|
604 |
} |
|
605 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
606 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
607 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
608 |
return WILDCARD; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
609 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
610 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
611 |
@Override |
6348
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
612 |
public boolean contains(Type t) { |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
613 |
return kind != UNBOUND && type.contains(t); |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
614 |
} |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
615 |
|
10 | 616 |
public boolean isSuperBound() { |
617 |
return kind == SUPER || |
|
618 |
kind == UNBOUND; |
|
619 |
} |
|
620 |
public boolean isExtendsBound() { |
|
621 |
return kind == EXTENDS || |
|
622 |
kind == UNBOUND; |
|
623 |
} |
|
624 |
public boolean isUnbound() { |
|
625 |
return kind == UNBOUND; |
|
626 |
} |
|
627 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
628 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
629 |
public boolean isReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
630 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
631 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
632 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
633 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
634 |
public boolean isNullOrReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
635 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
636 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
637 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
638 |
@Override |
10 | 639 |
public Type withTypeVar(Type t) { |
640 |
//-System.err.println(this+".withTypeVar("+t+");");//DEBUG |
|
641 |
if (bound == t) |
|
642 |
return this; |
|
643 |
bound = (TypeVar)t; |
|
644 |
return this; |
|
645 |
} |
|
646 |
||
647 |
boolean isPrintingBound = false; |
|
648 |
public String toString() { |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
649 |
StringBuilder s = new StringBuilder(); |
10 | 650 |
s.append(kind.toString()); |
651 |
if (kind != UNBOUND) |
|
652 |
s.append(type); |
|
653 |
if (moreInfo && bound != null && !isPrintingBound) |
|
654 |
try { |
|
655 |
isPrintingBound = true; |
|
656 |
s.append("{:").append(bound.bound).append(":}"); |
|
657 |
} finally { |
|
658 |
isPrintingBound = false; |
|
659 |
} |
|
660 |
return s.toString(); |
|
661 |
} |
|
662 |
||
663 |
public Type map(Mapping f) { |
|
664 |
//- System.err.println(" (" + this + ").map(" + f + ")");//DEBUG |
|
665 |
Type t = type; |
|
666 |
if (t != null) |
|
667 |
t = f.apply(t); |
|
668 |
if (t == type) |
|
669 |
return this; |
|
670 |
else |
|
671 |
return new WildcardType(t, kind, tsym, bound); |
|
672 |
} |
|
673 |
||
674 |
public Type getExtendsBound() { |
|
675 |
if (kind == EXTENDS) |
|
676 |
return type; |
|
677 |
else |
|
678 |
return null; |
|
679 |
} |
|
680 |
||
681 |
public Type getSuperBound() { |
|
682 |
if (kind == SUPER) |
|
683 |
return type; |
|
684 |
else |
|
685 |
return null; |
|
686 |
} |
|
687 |
||
688 |
public TypeKind getKind() { |
|
689 |
return TypeKind.WILDCARD; |
|
690 |
} |
|
691 |
||
692 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
693 |
return v.visitWildcard(this, p); |
|
694 |
} |
|
695 |
} |
|
696 |
||
697 |
public static class ClassType extends Type implements DeclaredType { |
|
698 |
||
699 |
/** The enclosing type of this type. If this is the type of an inner |
|
700 |
* class, outer_field refers to the type of its enclosing |
|
15385 | 701 |
* instance class, in all other cases it refers to noType. |
10 | 702 |
*/ |
703 |
private Type outer_field; |
|
704 |
||
705 |
/** The type parameters of this type (to be set once class is loaded). |
|
706 |
*/ |
|
707 |
public List<Type> typarams_field; |
|
708 |
||
709 |
/** A cache variable for the type parameters of this type, |
|
710 |
* appended to all parameters of its enclosing class. |
|
711 |
* @see #allparams |
|
712 |
*/ |
|
713 |
public List<Type> allparams_field; |
|
714 |
||
715 |
/** The supertype of this class (to be set once class is loaded). |
|
716 |
*/ |
|
717 |
public Type supertype_field; |
|
718 |
||
719 |
/** The interfaces of this class (to be set once class is loaded). |
|
720 |
*/ |
|
721 |
public List<Type> interfaces_field; |
|
722 |
||
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
723 |
/** All the interfaces of this class, including missing ones. |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
724 |
*/ |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
725 |
public List<Type> all_interfaces_field; |
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
726 |
|
10 | 727 |
public ClassType(Type outer, List<Type> typarams, TypeSymbol tsym) { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
728 |
super(tsym); |
10 | 729 |
this.outer_field = outer; |
730 |
this.typarams_field = typarams; |
|
731 |
this.allparams_field = null; |
|
732 |
this.supertype_field = null; |
|
733 |
this.interfaces_field = null; |
|
734 |
/* |
|
735 |
// this can happen during error recovery |
|
736 |
assert |
|
737 |
outer.isParameterized() ? |
|
738 |
typarams.length() == tsym.type.typarams().length() : |
|
739 |
outer.isRaw() ? |
|
740 |
typarams.length() == 0 : |
|
741 |
true; |
|
742 |
*/ |
|
743 |
} |
|
744 |
||
745 |
@Override |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
746 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
747 |
return CLASS; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
748 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
749 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
750 |
@Override |
10 | 751 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
752 |
return v.visitClassType(this, s); |
|
753 |
} |
|
754 |
||
755 |
public Type constType(Object constValue) { |
|
756 |
final Object value = constValue; |
|
757 |
return new ClassType(getEnclosingType(), typarams_field, tsym) { |
|
758 |
@Override |
|
759 |
public Object constValue() { |
|
760 |
return value; |
|
761 |
} |
|
762 |
@Override |
|
763 |
public Type baseType() { |
|
764 |
return tsym.type; |
|
765 |
} |
|
766 |
}; |
|
767 |
} |
|
768 |
||
769 |
/** The Java source which this type represents. |
|
770 |
*/ |
|
771 |
public String toString() { |
|
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
772 |
StringBuilder buf = new StringBuilder(); |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
773 |
if (getEnclosingType().hasTag(CLASS) && tsym.owner.kind == TYP) { |
10 | 774 |
buf.append(getEnclosingType().toString()); |
775 |
buf.append("."); |
|
776 |
buf.append(className(tsym, false)); |
|
777 |
} else { |
|
778 |
buf.append(className(tsym, true)); |
|
779 |
} |
|
780 |
if (getTypeArguments().nonEmpty()) { |
|
781 |
buf.append('<'); |
|
782 |
buf.append(getTypeArguments().toString()); |
|
783 |
buf.append(">"); |
|
784 |
} |
|
785 |
return buf.toString(); |
|
786 |
} |
|
787 |
//where |
|
788 |
private String className(Symbol sym, boolean longform) { |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
1257
diff
changeset
|
789 |
if (sym.name.isEmpty() && (sym.flags() & COMPOUND) != 0) { |
8625
6b51ef804d49
6639645: Modeling type implementing missing interfaces
jjg
parents:
8430
diff
changeset
|
790 |
StringBuilder s = new StringBuilder(supertype_field.toString()); |
10 | 791 |
for (List<Type> is=interfaces_field; is.nonEmpty(); is = is.tail) { |
792 |
s.append("&"); |
|
793 |
s.append(is.head.toString()); |
|
794 |
} |
|
795 |
return s.toString(); |
|
1260
a772ba9ba43d
6574134: Allow for alternative implementation of Name Table with garbage collection of name bytes
jjg
parents:
1257
diff
changeset
|
796 |
} else if (sym.name.isEmpty()) { |
10 | 797 |
String s; |
17578 | 798 |
ClassType norm = (ClassType) tsym.type.unannotatedType(); |
10 | 799 |
if (norm == null) { |
800 |
s = Log.getLocalizedString("anonymous.class", (Object)null); |
|
801 |
} else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) { |
|
802 |
s = Log.getLocalizedString("anonymous.class", |
|
803 |
norm.interfaces_field.head); |
|
804 |
} else { |
|
805 |
s = Log.getLocalizedString("anonymous.class", |
|
806 |
norm.supertype_field); |
|
807 |
} |
|
808 |
if (moreInfo) |
|
809 |
s += String.valueOf(sym.hashCode()); |
|
810 |
return s; |
|
811 |
} else if (longform) { |
|
812 |
return sym.getQualifiedName().toString(); |
|
813 |
} else { |
|
814 |
return sym.name.toString(); |
|
815 |
} |
|
816 |
} |
|
817 |
||
818 |
public List<Type> getTypeArguments() { |
|
819 |
if (typarams_field == null) { |
|
820 |
complete(); |
|
821 |
if (typarams_field == null) |
|
822 |
typarams_field = List.nil(); |
|
823 |
} |
|
824 |
return typarams_field; |
|
825 |
} |
|
826 |
||
514
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
827 |
public boolean hasErasedSupertypes() { |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
828 |
return isRaw(); |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
829 |
} |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
830 |
|
10 | 831 |
public Type getEnclosingType() { |
832 |
return outer_field; |
|
833 |
} |
|
834 |
||
835 |
public void setEnclosingType(Type outer) { |
|
836 |
outer_field = outer; |
|
837 |
} |
|
838 |
||
839 |
public List<Type> allparams() { |
|
840 |
if (allparams_field == null) { |
|
841 |
allparams_field = getTypeArguments().prependList(getEnclosingType().allparams()); |
|
842 |
} |
|
843 |
return allparams_field; |
|
844 |
} |
|
845 |
||
846 |
public boolean isErroneous() { |
|
847 |
return |
|
848 |
getEnclosingType().isErroneous() || |
|
849 |
isErroneous(getTypeArguments()) || |
|
17578 | 850 |
this != tsym.type.unannotatedType() && tsym.type.isErroneous(); |
10 | 851 |
} |
852 |
||
853 |
public boolean isParameterized() { |
|
854 |
return allparams().tail != null; |
|
855 |
// optimization, was: allparams().nonEmpty(); |
|
856 |
} |
|
857 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
858 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
859 |
public boolean isReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
860 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
861 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
862 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
863 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
864 |
public boolean isNullOrReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
865 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
866 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
867 |
|
10 | 868 |
/** A cache for the rank. */ |
869 |
int rank_field = -1; |
|
870 |
||
871 |
/** A class type is raw if it misses some |
|
872 |
* of its type parameter sections. |
|
873 |
* After validation, this is equivalent to: |
|
13844 | 874 |
* {@code allparams.isEmpty() && tsym.type.allparams.nonEmpty(); } |
10 | 875 |
*/ |
876 |
public boolean isRaw() { |
|
877 |
return |
|
878 |
this != tsym.type && // necessary, but not sufficient condition |
|
879 |
tsym.type.allparams().nonEmpty() && |
|
880 |
allparams().isEmpty(); |
|
881 |
} |
|
882 |
||
883 |
public Type map(Mapping f) { |
|
884 |
Type outer = getEnclosingType(); |
|
885 |
Type outer1 = f.apply(outer); |
|
886 |
List<Type> typarams = getTypeArguments(); |
|
887 |
List<Type> typarams1 = map(typarams, f); |
|
888 |
if (outer1 == outer && typarams1 == typarams) return this; |
|
889 |
else return new ClassType(outer1, typarams1, tsym); |
|
890 |
} |
|
891 |
||
892 |
public boolean contains(Type elem) { |
|
893 |
return |
|
894 |
elem == this |
|
895 |
|| (isParameterized() |
|
6348
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
896 |
&& (getEnclosingType().contains(elem) || contains(getTypeArguments(), elem))) |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
897 |
|| (isCompound() |
6c9b14d4a438
6369605: Unconstrained type variables fails to include bounds
mcimadamore
parents:
5847
diff
changeset
|
898 |
&& (supertype_field.contains(elem) || contains(interfaces_field, elem))); |
10 | 899 |
} |
900 |
||
901 |
public void complete() { |
|
902 |
if (tsym.completer != null) tsym.complete(); |
|
903 |
} |
|
904 |
||
905 |
public TypeKind getKind() { |
|
906 |
return TypeKind.DECLARED; |
|
907 |
} |
|
908 |
||
909 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
910 |
return v.visitDeclared(this, p); |
|
911 |
} |
|
912 |
} |
|
913 |
||
514
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
914 |
public static class ErasedClassType extends ClassType { |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
915 |
public ErasedClassType(Type outer, TypeSymbol tsym) { |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
916 |
super(outer, List.<Type>nil(), tsym); |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
917 |
} |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
918 |
|
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
919 |
@Override |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
920 |
public boolean hasErasedSupertypes() { |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
921 |
return true; |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
922 |
} |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
923 |
} |
3942d9cdc81c
6559182: Cast from a raw type with non-generic supertype to a raw type fails unexpectedly
mcimadamore
parents:
10
diff
changeset
|
924 |
|
9599
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
925 |
// a clone of a ClassType that knows about the alternatives of a union type. |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
926 |
public static class UnionClassType extends ClassType implements UnionType { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
927 |
final List<? extends Type> alternatives_field; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
928 |
|
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
929 |
public UnionClassType(ClassType ct, List<? extends Type> alternatives) { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
930 |
super(ct.outer_field, ct.typarams_field, ct.tsym); |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
931 |
allparams_field = ct.allparams_field; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
932 |
supertype_field = ct.supertype_field; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
933 |
interfaces_field = ct.interfaces_field; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
934 |
all_interfaces_field = ct.interfaces_field; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
935 |
alternatives_field = alternatives; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
936 |
} |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
937 |
|
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
938 |
public Type getLub() { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
939 |
return tsym.type; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
940 |
} |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
941 |
|
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
942 |
public java.util.List<? extends TypeMirror> getAlternatives() { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
943 |
return Collections.unmodifiableList(alternatives_field); |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
944 |
} |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
945 |
|
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
946 |
@Override |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
947 |
public TypeKind getKind() { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
948 |
return TypeKind.UNION; |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
949 |
} |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
950 |
|
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
951 |
@Override |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
952 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
953 |
return v.visitUnion(this, p); |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
954 |
} |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
955 |
} |
0996df19ea87
7029150: Project Coin: present union types from the tree API through to javax.lang.model
jjg
parents:
8625
diff
changeset
|
956 |
|
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
957 |
// a clone of a ClassType that knows about the bounds of an intersection type. |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
958 |
public static class IntersectionClassType extends ClassType implements IntersectionType { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
959 |
|
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
960 |
public boolean allInterfaces; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
961 |
|
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
962 |
public enum IntersectionKind { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
963 |
EXPLICIT, |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
964 |
IMPLICT; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
965 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
966 |
|
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
967 |
public IntersectionKind intersectionKind; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
968 |
|
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
969 |
public IntersectionClassType(List<Type> bounds, ClassSymbol csym, boolean allInterfaces) { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
970 |
super(Type.noType, List.<Type>nil(), csym); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
971 |
this.allInterfaces = allInterfaces; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
972 |
Assert.check((csym.flags() & COMPOUND) != 0); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
973 |
supertype_field = bounds.head; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
974 |
interfaces_field = bounds.tail; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
975 |
Assert.check(supertype_field.tsym.completer != null || |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
976 |
!supertype_field.isInterface(), supertype_field); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
977 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
978 |
|
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
979 |
public java.util.List<? extends TypeMirror> getBounds() { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
980 |
return Collections.unmodifiableList(getComponents()); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
981 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
982 |
|
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
983 |
public List<Type> getComponents() { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
984 |
return interfaces_field.prepend(supertype_field); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
985 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
986 |
|
16809
5acfcb821d65
8010822: Intersection type cast for functional expressions does not follow spec EDR
mcimadamore
parents:
16557
diff
changeset
|
987 |
public List<Type> getExplicitComponents() { |
5acfcb821d65
8010822: Intersection type cast for functional expressions does not follow spec EDR
mcimadamore
parents:
16557
diff
changeset
|
988 |
return allInterfaces ? |
5acfcb821d65
8010822: Intersection type cast for functional expressions does not follow spec EDR
mcimadamore
parents:
16557
diff
changeset
|
989 |
interfaces_field : |
5acfcb821d65
8010822: Intersection type cast for functional expressions does not follow spec EDR
mcimadamore
parents:
16557
diff
changeset
|
990 |
getComponents(); |
5acfcb821d65
8010822: Intersection type cast for functional expressions does not follow spec EDR
mcimadamore
parents:
16557
diff
changeset
|
991 |
} |
5acfcb821d65
8010822: Intersection type cast for functional expressions does not follow spec EDR
mcimadamore
parents:
16557
diff
changeset
|
992 |
|
14725
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
993 |
@Override |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
994 |
public TypeKind getKind() { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
995 |
return TypeKind.INTERSECTION; |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
996 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
997 |
|
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
998 |
@Override |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
999 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
1000 |
return intersectionKind == IntersectionKind.EXPLICIT ? |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
1001 |
v.visitIntersection(this, p) : |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
1002 |
v.visitDeclared(this, p); |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
1003 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
1004 |
} |
65836e833f59
8002099: Add support for intersection types in cast expression
mcimadamore
parents:
14359
diff
changeset
|
1005 |
|
10 | 1006 |
public static class ArrayType extends Type |
1007 |
implements javax.lang.model.type.ArrayType { |
|
1008 |
||
1009 |
public Type elemtype; |
|
1010 |
||
1011 |
public ArrayType(Type elemtype, TypeSymbol arrayClass) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1012 |
super(arrayClass); |
10 | 1013 |
this.elemtype = elemtype; |
1014 |
} |
|
1015 |
||
1016 |
@Override |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1017 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1018 |
return ARRAY; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1019 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1020 |
|
10 | 1021 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1022 |
return v.visitArrayType(this, s); |
|
1023 |
} |
|
1024 |
||
1025 |
public String toString() { |
|
1026 |
return elemtype + "[]"; |
|
1027 |
} |
|
1028 |
||
1029 |
public boolean equals(Object obj) { |
|
1030 |
return |
|
1031 |
this == obj || |
|
1032 |
(obj instanceof ArrayType && |
|
1033 |
this.elemtype.equals(((ArrayType)obj).elemtype)); |
|
1034 |
} |
|
1035 |
||
1036 |
public int hashCode() { |
|
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
1037 |
return (ARRAY.ordinal() << 5) + elemtype.hashCode(); |
10 | 1038 |
} |
1039 |
||
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1040 |
public boolean isVarargs() { |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1041 |
return false; |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1042 |
} |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1043 |
|
10 | 1044 |
public List<Type> allparams() { return elemtype.allparams(); } |
1045 |
||
1046 |
public boolean isErroneous() { |
|
1047 |
return elemtype.isErroneous(); |
|
1048 |
} |
|
1049 |
||
1050 |
public boolean isParameterized() { |
|
1051 |
return elemtype.isParameterized(); |
|
1052 |
} |
|
1053 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1054 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1055 |
public boolean isReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1056 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1057 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1058 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1059 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1060 |
public boolean isNullOrReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1061 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1062 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1063 |
|
10 | 1064 |
public boolean isRaw() { |
1065 |
return elemtype.isRaw(); |
|
1066 |
} |
|
1067 |
||
7643
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1068 |
public ArrayType makeVarargs() { |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1069 |
return new ArrayType(elemtype, tsym) { |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1070 |
@Override |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1071 |
public boolean isVarargs() { |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1072 |
return true; |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1073 |
} |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1074 |
}; |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1075 |
} |
a067a0cda531
6993978: Project Coin: Compiler support of annotation to reduce varargs warnings
mcimadamore
parents:
7637
diff
changeset
|
1076 |
|
10 | 1077 |
public Type map(Mapping f) { |
1078 |
Type elemtype1 = f.apply(elemtype); |
|
1079 |
if (elemtype1 == elemtype) return this; |
|
1080 |
else return new ArrayType(elemtype1, tsym); |
|
1081 |
} |
|
1082 |
||
1083 |
public boolean contains(Type elem) { |
|
1084 |
return elem == this || elemtype.contains(elem); |
|
1085 |
} |
|
1086 |
||
1087 |
public void complete() { |
|
1088 |
elemtype.complete(); |
|
1089 |
} |
|
1090 |
||
1091 |
public Type getComponentType() { |
|
1092 |
return elemtype; |
|
1093 |
} |
|
1094 |
||
1095 |
public TypeKind getKind() { |
|
1096 |
return TypeKind.ARRAY; |
|
1097 |
} |
|
1098 |
||
1099 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
1100 |
return v.visitArray(this, p); |
|
1101 |
} |
|
1102 |
} |
|
1103 |
||
8430 | 1104 |
public static class MethodType extends Type implements ExecutableType { |
10 | 1105 |
|
1106 |
public List<Type> argtypes; |
|
1107 |
public Type restype; |
|
1108 |
public List<Type> thrown; |
|
1109 |
||
15385 | 1110 |
/** The type annotations on the method receiver. |
1111 |
*/ |
|
1112 |
public Type recvtype; |
|
1113 |
||
10 | 1114 |
public MethodType(List<Type> argtypes, |
1115 |
Type restype, |
|
1116 |
List<Type> thrown, |
|
1117 |
TypeSymbol methodClass) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1118 |
super(methodClass); |
10 | 1119 |
this.argtypes = argtypes; |
1120 |
this.restype = restype; |
|
1121 |
this.thrown = thrown; |
|
1122 |
} |
|
1123 |
||
1124 |
@Override |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1125 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1126 |
return METHOD; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1127 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1128 |
|
10 | 1129 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1130 |
return v.visitMethodType(this, s); |
|
1131 |
} |
|
1132 |
||
1133 |
/** The Java source which this type represents. |
|
1134 |
* |
|
1135 |
* XXX 06/09/99 iris This isn't correct Java syntax, but it probably |
|
1136 |
* should be. |
|
1137 |
*/ |
|
1138 |
public String toString() { |
|
1139 |
return "(" + argtypes + ")" + restype; |
|
1140 |
} |
|
1141 |
||
1142 |
public List<Type> getParameterTypes() { return argtypes; } |
|
1143 |
public Type getReturnType() { return restype; } |
|
15385 | 1144 |
public Type getReceiverType() { return recvtype; } |
10 | 1145 |
public List<Type> getThrownTypes() { return thrown; } |
1146 |
||
1147 |
public boolean isErroneous() { |
|
1148 |
return |
|
1149 |
isErroneous(argtypes) || |
|
1150 |
restype != null && restype.isErroneous(); |
|
1151 |
} |
|
1152 |
||
1153 |
public Type map(Mapping f) { |
|
1154 |
List<Type> argtypes1 = map(argtypes, f); |
|
1155 |
Type restype1 = f.apply(restype); |
|
1156 |
List<Type> thrown1 = map(thrown, f); |
|
1157 |
if (argtypes1 == argtypes && |
|
1158 |
restype1 == restype && |
|
1159 |
thrown1 == thrown) return this; |
|
1160 |
else return new MethodType(argtypes1, restype1, thrown1, tsym); |
|
1161 |
} |
|
1162 |
||
1163 |
public boolean contains(Type elem) { |
|
1164 |
return elem == this || contains(argtypes, elem) || restype.contains(elem); |
|
1165 |
} |
|
1166 |
||
1167 |
public MethodType asMethodType() { return this; } |
|
1168 |
||
1169 |
public void complete() { |
|
1170 |
for (List<Type> l = argtypes; l.nonEmpty(); l = l.tail) |
|
1171 |
l.head.complete(); |
|
1172 |
restype.complete(); |
|
15385 | 1173 |
recvtype.complete(); |
10 | 1174 |
for (List<Type> l = thrown; l.nonEmpty(); l = l.tail) |
1175 |
l.head.complete(); |
|
1176 |
} |
|
1177 |
||
1178 |
public List<TypeVar> getTypeVariables() { |
|
1179 |
return List.nil(); |
|
1180 |
} |
|
1181 |
||
1182 |
public TypeSymbol asElement() { |
|
1183 |
return null; |
|
1184 |
} |
|
1185 |
||
1186 |
public TypeKind getKind() { |
|
1187 |
return TypeKind.EXECUTABLE; |
|
1188 |
} |
|
1189 |
||
1190 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
1191 |
return v.visitExecutable(this, p); |
|
1192 |
} |
|
1193 |
} |
|
1194 |
||
1195 |
public static class PackageType extends Type implements NoType { |
|
1196 |
||
1197 |
PackageType(TypeSymbol tsym) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1198 |
super(tsym); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1199 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1200 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1201 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1202 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1203 |
return PACKAGE; |
10 | 1204 |
} |
1205 |
||
1206 |
@Override |
|
1207 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
|
1208 |
return v.visitPackageType(this, s); |
|
1209 |
} |
|
1210 |
||
1211 |
public String toString() { |
|
1212 |
return tsym.getQualifiedName().toString(); |
|
1213 |
} |
|
1214 |
||
1215 |
public TypeKind getKind() { |
|
1216 |
return TypeKind.PACKAGE; |
|
1217 |
} |
|
1218 |
||
1219 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
1220 |
return v.visitNoType(this, p); |
|
1221 |
} |
|
1222 |
} |
|
1223 |
||
1224 |
public static class TypeVar extends Type implements TypeVariable { |
|
1225 |
||
7637 | 1226 |
/** The upper bound of this type variable; set from outside. |
10 | 1227 |
* Must be nonempty once it is set. |
1228 |
* For a bound, `bound' is the bound type itself. |
|
1229 |
* Multiple bounds are expressed as a single class type which has the |
|
1230 |
* individual bounds as superclass, respectively interfaces. |
|
1231 |
* The class type then has as `tsym' a compiler generated class `c', |
|
1232 |
* which has a flag COMPOUND and whose owner is the type variable |
|
1233 |
* itself. Furthermore, the erasure_field of the class |
|
1234 |
* points to the first class or interface bound. |
|
1235 |
*/ |
|
1236 |
public Type bound = null; |
|
7637 | 1237 |
|
1238 |
/** The lower bound of this type variable. |
|
1239 |
* TypeVars don't normally have a lower bound, so it is normally set |
|
1240 |
* to syms.botType. |
|
1241 |
* Subtypes, such as CapturedType, may provide a different value. |
|
1242 |
*/ |
|
10 | 1243 |
public Type lower; |
1244 |
||
1245 |
public TypeVar(Name name, Symbol owner, Type lower) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1246 |
super(null); |
16967
79d444669f3f
7015104: use new subtype of TypeSymbol for type parameters
jfranck
parents:
16809
diff
changeset
|
1247 |
tsym = new TypeVariableSymbol(0, name, this, owner); |
10 | 1248 |
this.lower = lower; |
1249 |
} |
|
1250 |
||
1251 |
public TypeVar(TypeSymbol tsym, Type bound, Type lower) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1252 |
super(tsym); |
10 | 1253 |
this.bound = bound; |
1254 |
this.lower = lower; |
|
1255 |
} |
|
1256 |
||
1257 |
@Override |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1258 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1259 |
return TYPEVAR; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1260 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1261 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1262 |
@Override |
10 | 1263 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
1264 |
return v.visitTypeVar(this, s); |
|
1265 |
} |
|
1266 |
||
7637 | 1267 |
@Override |
15385 | 1268 |
public Type getUpperBound() { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1269 |
if ((bound == null || bound.hasTag(NONE)) && this != tsym.type) { |
15385 | 1270 |
bound = tsym.type.getUpperBound(); |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1271 |
} |
15385 | 1272 |
return bound; |
1273 |
} |
|
10 | 1274 |
|
1275 |
int rank_field = -1; |
|
1276 |
||
7637 | 1277 |
@Override |
10 | 1278 |
public Type getLowerBound() { |
1279 |
return lower; |
|
1280 |
} |
|
1281 |
||
1282 |
public TypeKind getKind() { |
|
1283 |
return TypeKind.TYPEVAR; |
|
1284 |
} |
|
1285 |
||
938
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1286 |
public boolean isCaptured() { |
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1287 |
return false; |
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1288 |
} |
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1289 |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1290 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1291 |
public boolean isReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1292 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1293 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1294 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1295 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1296 |
public boolean isNullOrReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1297 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1298 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1299 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1300 |
@Override |
10 | 1301 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1302 |
return v.visitTypeVariable(this, p); |
|
1303 |
} |
|
1304 |
} |
|
1305 |
||
1306 |
/** A captured type variable comes from wildcards which can have |
|
1307 |
* both upper and lower bound. CapturedType extends TypeVar with |
|
1308 |
* a lower bound. |
|
1309 |
*/ |
|
1310 |
public static class CapturedType extends TypeVar { |
|
1311 |
||
1312 |
public WildcardType wildcard; |
|
1313 |
||
1314 |
public CapturedType(Name name, |
|
1315 |
Symbol owner, |
|
1316 |
Type upper, |
|
1317 |
Type lower, |
|
1318 |
WildcardType wildcard) { |
|
1319 |
super(name, owner, lower); |
|
8032 | 1320 |
this.lower = Assert.checkNonNull(lower); |
10 | 1321 |
this.bound = upper; |
1322 |
this.wildcard = wildcard; |
|
1323 |
} |
|
1324 |
||
1325 |
@Override |
|
1326 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
|
1327 |
return v.visitCapturedType(this, s); |
|
1328 |
} |
|
1329 |
||
1330 |
@Override |
|
938
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1331 |
public boolean isCaptured() { |
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1332 |
return true; |
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1333 |
} |
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1334 |
|
13aae74ca013
6594284: NPE thrown when calling a method on an intersection type
mcimadamore
parents:
735
diff
changeset
|
1335 |
@Override |
10 | 1336 |
public String toString() { |
1337 |
return "capture#" |
|
2984
e15ff3a34054
6722234: javac diagnostics need better integration with the type-system
mcimadamore
parents:
1527
diff
changeset
|
1338 |
+ (hashCode() & 0xFFFFFFFFL) % Printer.PRIME |
10 | 1339 |
+ " of " |
1340 |
+ wildcard; |
|
1341 |
} |
|
1342 |
} |
|
1343 |
||
1344 |
public static abstract class DelegatedType extends Type { |
|
1345 |
public Type qtype; |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1346 |
public TypeTag tag; |
14359
d4099818ab70
7200915: convert TypeTags from a series of small ints to an enum
jjg
parents:
14258
diff
changeset
|
1347 |
public DelegatedType(TypeTag tag, Type qtype) { |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1348 |
super(qtype.tsym); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1349 |
this.tag = tag; |
10 | 1350 |
this.qtype = qtype; |
1351 |
} |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1352 |
public TypeTag getTag() { return tag; } |
10 | 1353 |
public String toString() { return qtype.toString(); } |
1354 |
public List<Type> getTypeArguments() { return qtype.getTypeArguments(); } |
|
1355 |
public Type getEnclosingType() { return qtype.getEnclosingType(); } |
|
1356 |
public List<Type> getParameterTypes() { return qtype.getParameterTypes(); } |
|
1357 |
public Type getReturnType() { return qtype.getReturnType(); } |
|
15385 | 1358 |
public Type getReceiverType() { return qtype.getReceiverType(); } |
10 | 1359 |
public List<Type> getThrownTypes() { return qtype.getThrownTypes(); } |
1360 |
public List<Type> allparams() { return qtype.allparams(); } |
|
1361 |
public Type getUpperBound() { return qtype.getUpperBound(); } |
|
1362 |
public boolean isErroneous() { return qtype.isErroneous(); } |
|
1363 |
} |
|
1364 |
||
12915
28cf1e0dafdc
7166552: Inference: cleanup usage of Type.ForAll
mcimadamore
parents:
12468
diff
changeset
|
1365 |
/** |
28cf1e0dafdc
7166552: Inference: cleanup usage of Type.ForAll
mcimadamore
parents:
12468
diff
changeset
|
1366 |
* The type of a generic method type. It consists of a method type and |
28cf1e0dafdc
7166552: Inference: cleanup usage of Type.ForAll
mcimadamore
parents:
12468
diff
changeset
|
1367 |
* a list of method type-parameters that are used within the method |
28cf1e0dafdc
7166552: Inference: cleanup usage of Type.ForAll
mcimadamore
parents:
12468
diff
changeset
|
1368 |
* type. |
28cf1e0dafdc
7166552: Inference: cleanup usage of Type.ForAll
mcimadamore
parents:
12468
diff
changeset
|
1369 |
*/ |
8430 | 1370 |
public static class ForAll extends DelegatedType implements ExecutableType { |
10 | 1371 |
public List<Type> tvars; |
1372 |
||
1373 |
public ForAll(List<Type> tvars, Type qtype) { |
|
12915
28cf1e0dafdc
7166552: Inference: cleanup usage of Type.ForAll
mcimadamore
parents:
12468
diff
changeset
|
1374 |
super(FORALL, (MethodType)qtype); |
10 | 1375 |
this.tvars = tvars; |
1376 |
} |
|
1377 |
||
1378 |
@Override |
|
1379 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
|
1380 |
return v.visitForAll(this, s); |
|
1381 |
} |
|
1382 |
||
1383 |
public String toString() { |
|
1384 |
return "<" + tvars + ">" + qtype; |
|
1385 |
} |
|
1386 |
||
1387 |
public List<Type> getTypeArguments() { return tvars; } |
|
1388 |
||
1389 |
public boolean isErroneous() { |
|
1390 |
return qtype.isErroneous(); |
|
1391 |
} |
|
1392 |
||
1393 |
public Type map(Mapping f) { |
|
1394 |
return f.apply(qtype); |
|
1395 |
} |
|
1396 |
||
1397 |
public boolean contains(Type elem) { |
|
1398 |
return qtype.contains(elem); |
|
1399 |
} |
|
1400 |
||
1401 |
public MethodType asMethodType() { |
|
12915
28cf1e0dafdc
7166552: Inference: cleanup usage of Type.ForAll
mcimadamore
parents:
12468
diff
changeset
|
1402 |
return (MethodType)qtype; |
10 | 1403 |
} |
1404 |
||
1405 |
public void complete() { |
|
1406 |
for (List<Type> l = tvars; l.nonEmpty(); l = l.tail) { |
|
1407 |
((TypeVar)l.head).bound.complete(); |
|
1408 |
} |
|
1409 |
qtype.complete(); |
|
1410 |
} |
|
1411 |
||
1412 |
public List<TypeVar> getTypeVariables() { |
|
1413 |
return List.convert(TypeVar.class, getTypeArguments()); |
|
1414 |
} |
|
1415 |
||
1416 |
public TypeKind getKind() { |
|
1417 |
return TypeKind.EXECUTABLE; |
|
1418 |
} |
|
1419 |
||
1420 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
1421 |
return v.visitExecutable(this, p); |
|
1422 |
} |
|
1423 |
} |
|
1424 |
||
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1425 |
/** A class for inference variables, for use during method/diamond type |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1426 |
* inference. An inference variable has upper/lower bounds and a set |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1427 |
* of equality constraints. Such bounds are set during subtyping, type-containment, |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1428 |
* type-equality checks, when the types being tested contain inference variables. |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1429 |
* A change listener can be attached to an inference variable, to receive notifications |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1430 |
* whenever the bounds of an inference variable change. |
10 | 1431 |
*/ |
1432 |
public static class UndetVar extends DelegatedType { |
|
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1433 |
|
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1434 |
/** Inference variable change listener. The listener method is called |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1435 |
* whenever a change to the inference variable's bounds occurs |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1436 |
*/ |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1437 |
public interface UndetVarListener { |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1438 |
/** called when some inference variable bounds (of given kinds ibs) change */ |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1439 |
void varChanged(UndetVar uv, Set<InferenceBound> ibs); |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1440 |
} |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1441 |
|
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1442 |
/** |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1443 |
* Inference variable bound kinds |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1444 |
*/ |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1445 |
public enum InferenceBound { |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1446 |
/** upper bounds */ |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1447 |
UPPER, |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1448 |
/** lower bounds */ |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1449 |
LOWER, |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1450 |
/** equality constraints */ |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1451 |
EQ; |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1452 |
} |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1453 |
|
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1454 |
/** inference variable bounds */ |
18911 | 1455 |
protected Map<InferenceBound, List<Type>> bounds; |
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1456 |
|
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1457 |
/** inference variable's inferred type (set from Infer.java) */ |
10 | 1458 |
public Type inst = null; |
1459 |
||
15705 | 1460 |
/** number of declared (upper) bounds */ |
1461 |
public int declaredCount; |
|
1462 |
||
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1463 |
/** inference variable's change listener */ |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1464 |
public UndetVarListener listener = null; |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1465 |
|
10 | 1466 |
@Override |
1467 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
|
1468 |
return v.visitUndetVar(this, s); |
|
1469 |
} |
|
1470 |
||
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1471 |
public UndetVar(TypeVar origin, Types types) { |
10 | 1472 |
super(UNDETVAR, origin); |
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1473 |
bounds = new EnumMap<InferenceBound, List<Type>>(InferenceBound.class); |
15705 | 1474 |
List<Type> declaredBounds = types.getBounds(origin); |
1475 |
declaredCount = declaredBounds.length(); |
|
1476 |
bounds.put(InferenceBound.UPPER, declaredBounds); |
|
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1477 |
bounds.put(InferenceBound.LOWER, List.<Type>nil()); |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1478 |
bounds.put(InferenceBound.EQ, List.<Type>nil()); |
10 | 1479 |
} |
1480 |
||
1481 |
public String toString() { |
|
1482 |
if (inst != null) return inst.toString(); |
|
1483 |
else return qtype + "?"; |
|
1484 |
} |
|
1485 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1486 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1487 |
public boolean isPartial() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1488 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1489 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1490 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1491 |
@Override |
10 | 1492 |
public Type baseType() { |
1493 |
if (inst != null) return inst.baseType(); |
|
1494 |
else return this; |
|
1495 |
} |
|
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1496 |
|
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1497 |
/** get all bounds of a given kind */ |
15705 | 1498 |
public List<Type> getBounds(InferenceBound... ibs) { |
1499 |
ListBuffer<Type> buf = ListBuffer.lb(); |
|
1500 |
for (InferenceBound ib : ibs) { |
|
1501 |
buf.appendList(bounds.get(ib)); |
|
1502 |
} |
|
1503 |
return buf.toList(); |
|
1504 |
} |
|
1505 |
||
1506 |
/** get the list of declared (upper) bounds */ |
|
1507 |
public List<Type> getDeclaredBounds() { |
|
1508 |
ListBuffer<Type> buf = ListBuffer.lb(); |
|
1509 |
int count = 0; |
|
1510 |
for (Type b : getBounds(InferenceBound.UPPER)) { |
|
1511 |
if (count++ == declaredCount) break; |
|
1512 |
buf.append(b); |
|
1513 |
} |
|
1514 |
return buf.toList(); |
|
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1515 |
} |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1516 |
|
18904
3c4c6457ec5b
8019824: very long error messages on inference error
mcimadamore
parents:
18902
diff
changeset
|
1517 |
/** internal method used to override an undetvar bounds */ |
3c4c6457ec5b
8019824: very long error messages on inference error
mcimadamore
parents:
18902
diff
changeset
|
1518 |
public void setBounds(InferenceBound ib, List<Type> newBounds) { |
3c4c6457ec5b
8019824: very long error messages on inference error
mcimadamore
parents:
18902
diff
changeset
|
1519 |
bounds.put(ib, newBounds); |
3c4c6457ec5b
8019824: very long error messages on inference error
mcimadamore
parents:
18902
diff
changeset
|
1520 |
} |
3c4c6457ec5b
8019824: very long error messages on inference error
mcimadamore
parents:
18902
diff
changeset
|
1521 |
|
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1522 |
/** add a bound of a given kind - this might trigger listener notification */ |
18911 | 1523 |
public final void addBound(InferenceBound ib, Type bound, Types types) { |
1524 |
addBound(ib, bound, types, false); |
|
1525 |
} |
|
1526 |
||
1527 |
protected void addBound(InferenceBound ib, Type bound, Types types, boolean update) { |
|
18918
4e8769f15a95
8019942: Graph inference: avoid redundant computation during bound incorporation
mcimadamore
parents:
18911
diff
changeset
|
1528 |
Type bound2 = toTypeVarMap.apply(bound); |
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1529 |
List<Type> prevBounds = bounds.get(ib); |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1530 |
for (Type b : prevBounds) { |
15705 | 1531 |
//check for redundancy - use strict version of isSameType on tvars |
1532 |
//(as the standard version will lead to false positives w.r.t. clones ivars) |
|
16341
cc4b4e3c0f12
8009545: Graph inference: dependencies between inference variables should be set during incorporation
mcimadamore
parents:
15705
diff
changeset
|
1533 |
if (types.isSameType(b, bound2, true) || bound == qtype) return; |
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1534 |
} |
15705 | 1535 |
bounds.put(ib, prevBounds.prepend(bound2)); |
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1536 |
notifyChange(EnumSet.of(ib)); |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1537 |
} |
15705 | 1538 |
//where |
18918
4e8769f15a95
8019942: Graph inference: avoid redundant computation during bound incorporation
mcimadamore
parents:
18911
diff
changeset
|
1539 |
Type.Mapping toTypeVarMap = new Mapping("toTypeVarMap") { |
15705 | 1540 |
@Override |
1541 |
public Type apply(Type t) { |
|
1542 |
if (t.hasTag(UNDETVAR)) { |
|
1543 |
UndetVar uv = (UndetVar)t; |
|
18904
3c4c6457ec5b
8019824: very long error messages on inference error
mcimadamore
parents:
18902
diff
changeset
|
1544 |
return uv.inst != null ? uv.inst : uv.qtype; |
15705 | 1545 |
} else { |
1546 |
return t.map(this); |
|
1547 |
} |
|
1548 |
} |
|
1549 |
}; |
|
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1550 |
|
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1551 |
/** replace types in all bounds - this might trigger listener notification */ |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1552 |
public void substBounds(List<Type> from, List<Type> to, Types types) { |
15705 | 1553 |
List<Type> instVars = from.diff(to); |
1554 |
//if set of instantiated ivars is empty, there's nothing to do! |
|
1555 |
if (instVars.isEmpty()) return; |
|
1556 |
final EnumSet<InferenceBound> boundsChanged = EnumSet.noneOf(InferenceBound.class); |
|
1557 |
UndetVarListener prevListener = listener; |
|
1558 |
try { |
|
1559 |
//setup new listener for keeping track of changed bounds |
|
1560 |
listener = new UndetVarListener() { |
|
1561 |
public void varChanged(UndetVar uv, Set<InferenceBound> ibs) { |
|
1562 |
boundsChanged.addAll(ibs); |
|
1563 |
} |
|
1564 |
}; |
|
1565 |
for (Map.Entry<InferenceBound, List<Type>> _entry : bounds.entrySet()) { |
|
1566 |
InferenceBound ib = _entry.getKey(); |
|
1567 |
List<Type> prevBounds = _entry.getValue(); |
|
1568 |
ListBuffer<Type> newBounds = ListBuffer.lb(); |
|
1569 |
ListBuffer<Type> deps = ListBuffer.lb(); |
|
1570 |
//step 1 - re-add bounds that are not dependent on ivars |
|
1571 |
for (Type t : prevBounds) { |
|
1572 |
if (!t.containsAny(instVars)) { |
|
1573 |
newBounds.append(t); |
|
1574 |
} else { |
|
1575 |
deps.append(t); |
|
1576 |
} |
|
1577 |
} |
|
1578 |
//step 2 - replace bounds |
|
1579 |
bounds.put(ib, newBounds.toList()); |
|
1580 |
//step 3 - for each dependency, add new replaced bound |
|
1581 |
for (Type dep : deps) { |
|
18911 | 1582 |
addBound(ib, types.subst(dep, from, to), types, true); |
15705 | 1583 |
} |
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1584 |
} |
15705 | 1585 |
} finally { |
1586 |
listener = prevListener; |
|
1587 |
if (!boundsChanged.isEmpty()) { |
|
1588 |
notifyChange(boundsChanged); |
|
1589 |
} |
|
14048
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1590 |
} |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1591 |
} |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1592 |
|
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1593 |
private void notifyChange(EnumSet<InferenceBound> ibs) { |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1594 |
if (listener != null) { |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1595 |
listener.varChanged(this, ibs); |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1596 |
} |
308d1cf8fe46
7177306: Regression: unchecked method call does not erase return type
mcimadamore
parents:
13844
diff
changeset
|
1597 |
} |
18911 | 1598 |
|
1599 |
public boolean isCaptured() { |
|
1600 |
return false; |
|
1601 |
} |
|
1602 |
} |
|
1603 |
||
1604 |
/** |
|
1605 |
* This class is used to represent synthetic captured inference variables |
|
1606 |
* that can be generated during nested generic method calls. The only difference |
|
1607 |
* between these inference variables and ordinary ones is that captured inference |
|
1608 |
* variables cannot get new bounds through incorporation. |
|
1609 |
*/ |
|
1610 |
public static class CapturedUndetVar extends UndetVar { |
|
1611 |
||
1612 |
public CapturedUndetVar(CapturedType origin, Types types) { |
|
1613 |
super(origin, types); |
|
1614 |
if (!origin.lower.hasTag(BOT)) { |
|
1615 |
bounds.put(InferenceBound.LOWER, List.of(origin.lower)); |
|
1616 |
} |
|
1617 |
} |
|
1618 |
||
1619 |
@Override |
|
1620 |
public void addBound(InferenceBound ib, Type bound, Types types, boolean update) { |
|
1621 |
if (update) { |
|
1622 |
//only change bounds if request comes from substBounds |
|
1623 |
super.addBound(ib, bound, types, update); |
|
1624 |
} |
|
1625 |
} |
|
1626 |
||
1627 |
@Override |
|
1628 |
public boolean isCaptured() { |
|
1629 |
return true; |
|
1630 |
} |
|
10 | 1631 |
} |
1632 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1633 |
/** Represents NONE. |
10 | 1634 |
*/ |
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1635 |
public static class JCNoType extends Type implements NoType { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1636 |
public JCNoType() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1637 |
super(null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1638 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1639 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1640 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1641 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1642 |
return NONE; |
10 | 1643 |
} |
1644 |
||
1645 |
@Override |
|
1646 |
public TypeKind getKind() { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1647 |
return TypeKind.NONE; |
10 | 1648 |
} |
1649 |
||
1650 |
@Override |
|
1651 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
1652 |
return v.visitNoType(this, p); |
|
1653 |
} |
|
1654 |
} |
|
1655 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1656 |
/** Represents VOID. |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1657 |
*/ |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1658 |
public static class JCVoidType extends Type implements NoType { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1659 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1660 |
public JCVoidType() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1661 |
super(null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1662 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1663 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1664 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1665 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1666 |
return VOID; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1667 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1668 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1669 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1670 |
public TypeKind getKind() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1671 |
return TypeKind.VOID; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1672 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1673 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1674 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1675 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1676 |
return v.visitNoType(this, p); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1677 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1678 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1679 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1680 |
public boolean isPrimitiveOrVoid() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1681 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1682 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1683 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1684 |
|
10 | 1685 |
static class BottomType extends Type implements NullType { |
1686 |
public BottomType() { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1687 |
super(null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1688 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1689 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1690 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1691 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1692 |
return BOT; |
10 | 1693 |
} |
1694 |
||
1695 |
@Override |
|
1696 |
public TypeKind getKind() { |
|
1697 |
return TypeKind.NULL; |
|
1698 |
} |
|
1699 |
||
1700 |
@Override |
|
1701 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
1702 |
return v.visitNull(this, p); |
|
1703 |
} |
|
1704 |
||
1705 |
@Override |
|
1706 |
public Type constType(Object value) { |
|
1707 |
return this; |
|
1708 |
} |
|
1709 |
||
1710 |
@Override |
|
1711 |
public String stringValue() { |
|
1712 |
return "null"; |
|
1713 |
} |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1714 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1715 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1716 |
public boolean isNullOrReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1717 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1718 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1719 |
|
10 | 1720 |
} |
1721 |
||
1722 |
public static class ErrorType extends ClassType |
|
1723 |
implements javax.lang.model.type.ErrorType { |
|
1724 |
||
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1725 |
private Type originalType = null; |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1726 |
|
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1727 |
public ErrorType(Type originalType, TypeSymbol tsym) { |
10 | 1728 |
super(noType, List.<Type>nil(), null); |
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1729 |
this.tsym = tsym; |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1730 |
this.originalType = (originalType == null ? noType : originalType); |
10 | 1731 |
} |
1732 |
||
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1733 |
public ErrorType(ClassSymbol c, Type originalType) { |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1734 |
this(originalType, c); |
10 | 1735 |
c.type = this; |
1736 |
c.kind = ERR; |
|
1737 |
c.members_field = new Scope.ErrorScope(c); |
|
1738 |
} |
|
1739 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1740 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1741 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1742 |
return ERROR; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1743 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1744 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1745 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1746 |
public boolean isPartial() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1747 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1748 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1749 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1750 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1751 |
public boolean isReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1752 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1753 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1754 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1755 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1756 |
public boolean isNullOrReference() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1757 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1758 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1759 |
|
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1760 |
public ErrorType(Name name, TypeSymbol container, Type originalType) { |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1761 |
this(new ClassSymbol(PUBLIC|STATIC|ACYCLIC, name, null, container), originalType); |
10 | 1762 |
} |
1763 |
||
1764 |
@Override |
|
1765 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
|
1766 |
return v.visitErrorType(this, s); |
|
1767 |
} |
|
1768 |
||
1769 |
public Type constType(Object constValue) { return this; } |
|
15385 | 1770 |
public Type getEnclosingType() { return this; } |
10 | 1771 |
public Type getReturnType() { return this; } |
1772 |
public Type asSub(Symbol sym) { return this; } |
|
1773 |
public Type map(Mapping f) { return this; } |
|
1774 |
||
1775 |
public boolean isGenType(Type t) { return true; } |
|
1776 |
public boolean isErroneous() { return true; } |
|
1777 |
public boolean isCompound() { return false; } |
|
1778 |
public boolean isInterface() { return false; } |
|
1779 |
||
1780 |
public List<Type> allparams() { return List.nil(); } |
|
1781 |
public List<Type> getTypeArguments() { return List.nil(); } |
|
1782 |
||
1783 |
public TypeKind getKind() { |
|
1784 |
return TypeKind.ERROR; |
|
1785 |
} |
|
1786 |
||
1257
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1787 |
public Type getOriginalType() { |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1788 |
return originalType; |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1789 |
} |
873b053bf757
6557752: Original type of an AST should be made available even if it is replaced with an ErrorType
jjg
parents:
1206
diff
changeset
|
1790 |
|
10 | 1791 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
1792 |
return v.visitError(this, p); |
|
1793 |
} |
|
1794 |
} |
|
1795 |
||
15385 | 1796 |
public static class AnnotatedType extends Type |
16556
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1797 |
implements |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1798 |
javax.lang.model.type.ArrayType, |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1799 |
javax.lang.model.type.DeclaredType, |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1800 |
javax.lang.model.type.PrimitiveType, |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1801 |
javax.lang.model.type.TypeVariable, |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1802 |
javax.lang.model.type.WildcardType { |
15385 | 1803 |
/** The type annotations on this type. |
1804 |
*/ |
|
1805 |
public List<Attribute.TypeCompound> typeAnnotations; |
|
1806 |
||
1807 |
/** The underlying type that is annotated. |
|
1808 |
*/ |
|
1809 |
public Type underlyingType; |
|
1810 |
||
1811 |
public AnnotatedType(Type underlyingType) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1812 |
super(underlyingType.tsym); |
15385 | 1813 |
this.typeAnnotations = List.nil(); |
1814 |
this.underlyingType = underlyingType; |
|
16556
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1815 |
Assert.check(!underlyingType.isAnnotated(), |
15385 | 1816 |
"Can't annotate already annotated type: " + underlyingType); |
1817 |
} |
|
1818 |
||
1819 |
public AnnotatedType(List<Attribute.TypeCompound> typeAnnotations, |
|
1820 |
Type underlyingType) { |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1821 |
super(underlyingType.tsym); |
15385 | 1822 |
this.typeAnnotations = typeAnnotations; |
1823 |
this.underlyingType = underlyingType; |
|
16556
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1824 |
Assert.check(!underlyingType.isAnnotated(), |
15385 | 1825 |
"Can't annotate already annotated type: " + underlyingType + |
1826 |
"; adding: " + typeAnnotations); |
|
1827 |
} |
|
1828 |
||
1829 |
@Override |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1830 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1831 |
return underlyingType.getTag(); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1832 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1833 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1834 |
@Override |
16556
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1835 |
public boolean isAnnotated() { |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1836 |
return true; |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1837 |
} |
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1838 |
|
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1839 |
@Override |
16557
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1840 |
public List<? extends Attribute.TypeCompound> getAnnotationMirrors() { |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1841 |
return typeAnnotations; |
15385 | 1842 |
} |
1843 |
||
1844 |
@Override |
|
16557
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1845 |
public <A extends Annotation> A getAnnotation(Class<A> annotationType) { |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1846 |
return JavacAnnoConstructs.getAnnotation(this, annotationType); |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1847 |
} |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1848 |
|
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1849 |
@Override |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1850 |
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) { |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1851 |
return JavacAnnoConstructs.getAnnotationsByType(this, annotationType); |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1852 |
} |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1853 |
|
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1854 |
@Override |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1855 |
public TypeKind getKind() { |
67a3ae363f03
8007803: Implement javax.lang.model API for Type Annotations
jjg
parents:
16556
diff
changeset
|
1856 |
return underlyingType.getKind(); |
15385 | 1857 |
} |
1858 |
||
1859 |
@Override |
|
1860 |
public Type unannotatedType() { |
|
1861 |
return underlyingType; |
|
1862 |
} |
|
1863 |
||
1864 |
@Override |
|
1865 |
public <R,S> R accept(Type.Visitor<R,S> v, S s) { |
|
1866 |
return v.visitAnnotatedType(this, s); |
|
1867 |
} |
|
1868 |
||
1869 |
@Override |
|
1870 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
|
16556
f4adc5bb4652
8008425: Remove interim new javax.lang.model API for type-annotations
jjg
parents:
16341
diff
changeset
|
1871 |
return underlyingType.accept(v, p); |
15385 | 1872 |
} |
1873 |
||
1874 |
@Override |
|
1875 |
public Type map(Mapping f) { |
|
1876 |
underlyingType.map(f); |
|
1877 |
return this; |
|
1878 |
} |
|
1879 |
||
1880 |
@Override |
|
1881 |
public Type constType(Object constValue) { return underlyingType.constType(constValue); } |
|
1882 |
@Override |
|
1883 |
public Type getEnclosingType() { return underlyingType.getEnclosingType(); } |
|
1884 |
||
1885 |
@Override |
|
1886 |
public Type getReturnType() { return underlyingType.getReturnType(); } |
|
1887 |
@Override |
|
1888 |
public List<Type> getTypeArguments() { return underlyingType.getTypeArguments(); } |
|
1889 |
@Override |
|
1890 |
public List<Type> getParameterTypes() { return underlyingType.getParameterTypes(); } |
|
1891 |
@Override |
|
1892 |
public Type getReceiverType() { return underlyingType.getReceiverType(); } |
|
1893 |
@Override |
|
1894 |
public List<Type> getThrownTypes() { return underlyingType.getThrownTypes(); } |
|
1895 |
@Override |
|
1896 |
public Type getUpperBound() { return underlyingType.getUpperBound(); } |
|
1897 |
@Override |
|
1898 |
public Type getLowerBound() { return underlyingType.getLowerBound(); } |
|
1899 |
||
1900 |
@Override |
|
1901 |
public boolean isErroneous() { return underlyingType.isErroneous(); } |
|
1902 |
@Override |
|
1903 |
public boolean isCompound() { return underlyingType.isCompound(); } |
|
1904 |
@Override |
|
1905 |
public boolean isInterface() { return underlyingType.isInterface(); } |
|
1906 |
@Override |
|
1907 |
public List<Type> allparams() { return underlyingType.allparams(); } |
|
1908 |
@Override |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1909 |
public boolean isPrimitive() { return underlyingType.isPrimitive(); } |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1910 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1911 |
public boolean isPrimitiveOrVoid() { return underlyingType.isPrimitiveOrVoid(); } |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1912 |
@Override |
15385 | 1913 |
public boolean isNumeric() { return underlyingType.isNumeric(); } |
1914 |
@Override |
|
1915 |
public boolean isReference() { return underlyingType.isReference(); } |
|
1916 |
@Override |
|
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1917 |
public boolean isNullOrReference() { return underlyingType.isNullOrReference(); } |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1918 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1919 |
public boolean isPartial() { return underlyingType.isPartial(); } |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1920 |
@Override |
15385 | 1921 |
public boolean isParameterized() { return underlyingType.isParameterized(); } |
1922 |
@Override |
|
1923 |
public boolean isRaw() { return underlyingType.isRaw(); } |
|
1924 |
@Override |
|
1925 |
public boolean isFinal() { return underlyingType.isFinal(); } |
|
1926 |
@Override |
|
1927 |
public boolean isSuperBound() { return underlyingType.isSuperBound(); } |
|
1928 |
@Override |
|
1929 |
public boolean isExtendsBound() { return underlyingType.isExtendsBound(); } |
|
1930 |
@Override |
|
1931 |
public boolean isUnbound() { return underlyingType.isUnbound(); } |
|
1932 |
||
1933 |
@Override |
|
1934 |
public String toString() { |
|
17578 | 1935 |
// This method is only used for internal debugging output. |
1936 |
// See |
|
1937 |
// com.sun.tools.javac.code.Printer.visitAnnotatedType(AnnotatedType, Locale) |
|
1938 |
// for the user-visible logic. |
|
15385 | 1939 |
if (typeAnnotations != null && |
1940 |
!typeAnnotations.isEmpty()) { |
|
1941 |
return "(" + typeAnnotations.toString() + " :: " + underlyingType.toString() + ")"; |
|
1942 |
} else { |
|
1943 |
return "({} :: " + underlyingType.toString() +")"; |
|
1944 |
} |
|
1945 |
} |
|
1946 |
||
1947 |
@Override |
|
1948 |
public boolean contains(Type t) { return underlyingType.contains(t); } |
|
1949 |
||
1950 |
@Override |
|
17578 | 1951 |
public Type withTypeVar(Type t) { |
1952 |
// Don't create a new AnnotatedType, as 'this' will |
|
1953 |
// get its annotations set later. |
|
1954 |
underlyingType = underlyingType.withTypeVar(t); |
|
1955 |
return this; |
|
1956 |
} |
|
15385 | 1957 |
|
1958 |
// TODO: attach annotations? |
|
1959 |
@Override |
|
1960 |
public TypeSymbol asElement() { return underlyingType.asElement(); } |
|
1961 |
||
1962 |
// TODO: attach annotations? |
|
1963 |
@Override |
|
1964 |
public MethodType asMethodType() { return underlyingType.asMethodType(); } |
|
1965 |
||
1966 |
@Override |
|
1967 |
public void complete() { underlyingType.complete(); } |
|
1968 |
||
1969 |
@Override |
|
1970 |
public TypeMirror getComponentType() { return ((ArrayType)underlyingType).getComponentType(); } |
|
1971 |
||
1972 |
// The result is an ArrayType, but only in the model sense, not the Type sense. |
|
1973 |
public AnnotatedType makeVarargs() { |
|
1974 |
AnnotatedType atype = new AnnotatedType(((ArrayType)underlyingType).makeVarargs()); |
|
1975 |
atype.typeAnnotations = this.typeAnnotations; |
|
1976 |
return atype; |
|
1977 |
} |
|
1978 |
||
1979 |
@Override |
|
1980 |
public TypeMirror getExtendsBound() { return ((WildcardType)underlyingType).getExtendsBound(); } |
|
1981 |
@Override |
|
1982 |
public TypeMirror getSuperBound() { return ((WildcardType)underlyingType).getSuperBound(); } |
|
1983 |
} |
|
1984 |
||
18646
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1985 |
public static class UnknownType extends Type { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1986 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1987 |
public UnknownType() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1988 |
super(null); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1989 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1990 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1991 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1992 |
public TypeTag getTag() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1993 |
return UNKNOWN; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1994 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1995 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1996 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1997 |
public <R, P> R accept(TypeVisitor<R, P> v, P p) { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1998 |
return v.visitUnknown(this, p); |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
1999 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
2000 |
|
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
2001 |
@Override |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
2002 |
public boolean isPartial() { |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
2003 |
return true; |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
2004 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
2005 |
} |
e628560a86d1
8017104: javac should have a class for primitive types that inherits from Type
vromero
parents:
18395
diff
changeset
|
2006 |
|
10 | 2007 |
/** |
2008 |
* A visitor for types. A visitor is used to implement operations |
|
2009 |
* (or relations) on types. Most common operations on types are |
|
2010 |
* binary relations and this interface is designed for binary |
|
15385 | 2011 |
* relations, that is, operations of the form |
10 | 2012 |
* Type × S → R. |
2013 |
* <!-- In plain text: Type x S -> R --> |
|
2014 |
* |
|
2015 |
* @param <R> the return type of the operation implemented by this |
|
2016 |
* visitor; use Void if no return type is needed. |
|
2017 |
* @param <S> the type of the second argument (the first being the |
|
2018 |
* type itself) of the operation implemented by this visitor; use |
|
2019 |
* Void if a second argument is not needed. |
|
2020 |
*/ |
|
2021 |
public interface Visitor<R,S> { |
|
2022 |
R visitClassType(ClassType t, S s); |
|
2023 |
R visitWildcardType(WildcardType t, S s); |
|
2024 |
R visitArrayType(ArrayType t, S s); |
|
2025 |
R visitMethodType(MethodType t, S s); |
|
2026 |
R visitPackageType(PackageType t, S s); |
|
2027 |
R visitTypeVar(TypeVar t, S s); |
|
2028 |
R visitCapturedType(CapturedType t, S s); |
|
2029 |
R visitForAll(ForAll t, S s); |
|
2030 |
R visitUndetVar(UndetVar t, S s); |
|
2031 |
R visitErrorType(ErrorType t, S s); |
|
15385 | 2032 |
R visitAnnotatedType(AnnotatedType t, S s); |
10 | 2033 |
R visitType(Type t, S s); |
2034 |
} |
|
2035 |
} |