Lines 20-25
Link Here
|
20 |
|
20 |
|
21 |
public abstract class TypeReference extends Expression { |
21 |
public abstract class TypeReference extends Expression { |
22 |
|
22 |
|
|
|
23 |
// Depending on location of type references, certain checks are deferred |
24 |
// until later stages (i.e. when resolving super types or type variables) |
25 |
public static final int CHECK_ALL = 0; |
26 |
public static final int CHECK_NO_BOUND = 1; |
27 |
public static final int CHECK_NO_DEPRECATION = 2; |
28 |
|
23 |
public TypeReference() { |
29 |
public TypeReference() { |
24 |
super () ; |
30 |
super () ; |
25 |
} |
31 |
} |
Lines 104-110
Link Here
|
104 |
} |
110 |
} |
105 |
public TypeBinding resolveSuperType(ClassScope scope) { |
111 |
public TypeBinding resolveSuperType(ClassScope scope) { |
106 |
// assumes the implementation of resolveType(ClassScope) will call back to detect cycles |
112 |
// assumes the implementation of resolveType(ClassScope) will call back to detect cycles |
107 |
if (resolveType(scope) == null) return null; |
113 |
if (resolveType(scope, CHECK_NO_BOUND|CHECK_NO_DEPRECATION) == null) return null; |
108 |
|
114 |
|
109 |
if (this.resolvedType.isTypeVariable()) { |
115 |
if (this.resolvedType.isTypeVariable()) { |
110 |
this.resolvedType = new ProblemReferenceBinding(getTypeName(), (ReferenceBinding) this.resolvedType, ProblemReasons.IllegalSuperTypeVariable); |
116 |
this.resolvedType = new ProblemReferenceBinding(getTypeName(), (ReferenceBinding) this.resolvedType, ProblemReasons.IllegalSuperTypeVariable); |
Lines 115-124
Link Here
|
115 |
} |
121 |
} |
116 |
|
122 |
|
117 |
public final TypeBinding resolveType(BlockScope blockScope) { |
123 |
public final TypeBinding resolveType(BlockScope blockScope) { |
118 |
return resolveType(blockScope, true /* checkbounds if any */); |
124 |
return resolveType(blockScope, CHECK_ALL); |
119 |
} |
125 |
} |
120 |
|
126 |
|
121 |
public TypeBinding resolveType(BlockScope scope, boolean checkBounds) { |
127 |
public TypeBinding resolveType(BlockScope scope, int checkMode) { |
122 |
// handle the error here |
128 |
// handle the error here |
123 |
this.constant = Constant.NotAConstant; |
129 |
this.constant = Constant.NotAConstant; |
124 |
if (this.resolvedType != null) // is a shared type reference which was already resolved |
130 |
if (this.resolvedType != null) // is a shared type reference which was already resolved |
Lines 131-138
Link Here
|
131 |
reportInvalidType(scope); |
137 |
reportInvalidType(scope); |
132 |
return null; |
138 |
return null; |
133 |
} |
139 |
} |
134 |
if (isTypeUseDeprecated(this.resolvedType, scope)) |
140 |
if ((checkMode & CHECK_NO_DEPRECATION) == 0 && isTypeUseDeprecated(this.resolvedType, scope)) { |
135 |
reportDeprecatedType(scope); |
141 |
reportDeprecatedType(scope); |
|
|
142 |
} |
136 |
type = scope.environment().convertToRawType(type); |
143 |
type = scope.environment().convertToRawType(type); |
137 |
if (type.isRawType() |
144 |
if (type.isRawType() |
138 |
&& (this.bits & IgnoreRawTypeCheck) == 0 |
145 |
&& (this.bits & IgnoreRawTypeCheck) == 0 |
Lines 142-147
Link Here
|
142 |
return this.resolvedType = type; |
149 |
return this.resolvedType = type; |
143 |
} |
150 |
} |
144 |
public TypeBinding resolveType(ClassScope scope) { |
151 |
public TypeBinding resolveType(ClassScope scope) { |
|
|
152 |
return resolveType(scope, CHECK_NO_BOUND); |
153 |
} |
154 |
public TypeBinding resolveType(ClassScope scope, int checkMode) { |
145 |
// handle the error here |
155 |
// handle the error here |
146 |
this.constant = Constant.NotAConstant; |
156 |
this.constant = Constant.NotAConstant; |
147 |
if (this.resolvedType != null) // is a shared type reference which was already resolved |
157 |
if (this.resolvedType != null) // is a shared type reference which was already resolved |
Lines 154-161
Link Here
|
154 |
reportInvalidType(scope); |
164 |
reportInvalidType(scope); |
155 |
return null; |
165 |
return null; |
156 |
} |
166 |
} |
157 |
if (isTypeUseDeprecated(this.resolvedType, scope)) |
167 |
if ((checkMode & CHECK_NO_DEPRECATION) == 0 && isTypeUseDeprecated(this.resolvedType, scope)) { |
158 |
reportDeprecatedType(scope); |
168 |
reportDeprecatedType(scope); |
|
|
169 |
} |
159 |
type = scope.environment().convertToRawType(type); |
170 |
type = scope.environment().convertToRawType(type); |
160 |
if (type.isRawType() |
171 |
if (type.isRawType() |
161 |
&& (this.bits & IgnoreRawTypeCheck) == 0 |
172 |
&& (this.bits & IgnoreRawTypeCheck) == 0 |
Lines 166-182
Link Here
|
166 |
} |
177 |
} |
167 |
|
178 |
|
168 |
public TypeBinding resolveTypeArgument(BlockScope blockScope, ReferenceBinding genericType, int rank) { |
179 |
public TypeBinding resolveTypeArgument(BlockScope blockScope, ReferenceBinding genericType, int rank) { |
169 |
return resolveType(blockScope, true /* check bounds*/); |
180 |
return resolveType(blockScope, TypeReference.CHECK_ALL); |
170 |
} |
181 |
} |
171 |
|
182 |
|
172 |
public TypeBinding resolveTypeArgument(ClassScope classScope, ReferenceBinding genericType, int rank) { |
183 |
public TypeBinding resolveTypeArgument(ClassScope classScope, ReferenceBinding genericType, int rank) { |
173 |
return resolveType(classScope); |
184 |
return resolveType(classScope, TypeReference.CHECK_ALL); |
174 |
} |
185 |
} |
175 |
|
186 |
|
176 |
protected void reportInvalidType(Scope scope) { |
187 |
protected void reportInvalidType(Scope scope) { |
177 |
scope.problemReporter().invalidType(this, this.resolvedType); |
188 |
scope.problemReporter().invalidType(this, this.resolvedType); |
178 |
} |
189 |
} |
179 |
protected void reportDeprecatedType(Scope scope) { |
190 |
public void reportDeprecatedType(Scope scope) { |
180 |
scope.problemReporter().deprecatedType(this.resolvedType, this); |
191 |
scope.problemReporter().deprecatedType(this.resolvedType, this); |
181 |
} |
192 |
} |
182 |
public abstract void traverse(ASTVisitor visitor, ClassScope classScope); |
193 |
public abstract void traverse(ASTVisitor visitor, ClassScope classScope); |