Lines 12-21
Link Here
|
12 |
|
12 |
|
13 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
13 |
import org.eclipse.jdt.internal.compiler.ASTVisitor; |
14 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
14 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
15 |
import org.eclipse.jdt.internal.compiler.codegen.*; |
15 |
import org.eclipse.jdt.internal.compiler.codegen.CodeStream; |
16 |
import org.eclipse.jdt.internal.compiler.flow.*; |
16 |
import org.eclipse.jdt.internal.compiler.flow.FlowContext; |
|
|
17 |
import org.eclipse.jdt.internal.compiler.flow.FlowInfo; |
17 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
18 |
import org.eclipse.jdt.internal.compiler.impl.Constant; |
18 |
import org.eclipse.jdt.internal.compiler.lookup.*; |
19 |
import org.eclipse.jdt.internal.compiler.lookup.Binding; |
|
|
20 |
import org.eclipse.jdt.internal.compiler.lookup.BlockScope; |
21 |
import org.eclipse.jdt.internal.compiler.lookup.LocalTypeBinding; |
22 |
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; |
23 |
import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; |
24 |
import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; |
25 |
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding; |
26 |
import org.eclipse.jdt.internal.compiler.lookup.TagBits; |
27 |
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; |
28 |
import org.eclipse.jdt.internal.compiler.lookup.TypeIds; |
19 |
|
29 |
|
20 |
/** |
30 |
/** |
21 |
* Variation on allocation, where can optionally be specified any of: |
31 |
* Variation on allocation, where can optionally be specified any of: |
Lines 45-52
Link Here
|
45 |
FlowInfo flowInfo) { |
55 |
FlowInfo flowInfo) { |
46 |
|
56 |
|
47 |
// analyse the enclosing instance |
57 |
// analyse the enclosing instance |
48 |
if (enclosingInstance != null) { |
58 |
if (this.enclosingInstance != null) { |
49 |
flowInfo = enclosingInstance.analyseCode(currentScope, flowContext, flowInfo); |
59 |
flowInfo = this.enclosingInstance.analyseCode(currentScope, flowContext, flowInfo); |
50 |
} |
60 |
} |
51 |
|
61 |
|
52 |
// check captured variables are initialized in current context (26134) |
62 |
// check captured variables are initialized in current context (26134) |
Lines 57-76
Link Here
|
57 |
flowInfo); |
67 |
flowInfo); |
58 |
|
68 |
|
59 |
// process arguments |
69 |
// process arguments |
60 |
if (arguments != null) { |
70 |
if (this.arguments != null) { |
61 |
for (int i = 0, count = arguments.length; i < count; i++) { |
71 |
for (int i = 0, count = this.arguments.length; i < count; i++) { |
62 |
flowInfo = arguments[i].analyseCode(currentScope, flowContext, flowInfo); |
72 |
flowInfo = this.arguments[i].analyseCode(currentScope, flowContext, flowInfo); |
63 |
} |
73 |
} |
64 |
} |
74 |
} |
65 |
|
75 |
|
66 |
// analyse the anonymous nested type |
76 |
// analyse the anonymous nested type |
67 |
if (anonymousType != null) { |
77 |
if (this.anonymousType != null) { |
68 |
flowInfo = anonymousType.analyseCode(currentScope, flowContext, flowInfo); |
78 |
flowInfo = this.anonymousType.analyseCode(currentScope, flowContext, flowInfo); |
69 |
} |
79 |
} |
70 |
|
80 |
|
71 |
// record some dependency information for exception types |
81 |
// record some dependency information for exception types |
72 |
ReferenceBinding[] thrownExceptions; |
82 |
ReferenceBinding[] thrownExceptions; |
73 |
if (((thrownExceptions = binding.thrownExceptions).length) != 0) { |
83 |
if (((thrownExceptions = this.binding.thrownExceptions).length) != 0) { |
74 |
// check exception handling |
84 |
// check exception handling |
75 |
flowContext.checkExceptionHandlers( |
85 |
flowContext.checkExceptionHandlers( |
76 |
thrownExceptions, |
86 |
thrownExceptions, |
Lines 85-91
Link Here
|
85 |
|
95 |
|
86 |
public Expression enclosingInstance() { |
96 |
public Expression enclosingInstance() { |
87 |
|
97 |
|
88 |
return enclosingInstance; |
98 |
return this.enclosingInstance; |
89 |
} |
99 |
} |
90 |
|
100 |
|
91 |
public void generateCode( |
101 |
public void generateCode( |
Lines 104-111
Link Here
|
104 |
codeStream.recordPositionsFrom(pc, this.type.sourceStart); |
114 |
codeStream.recordPositionsFrom(pc, this.type.sourceStart); |
105 |
} else { |
115 |
} else { |
106 |
// push enum constant name and ordinal |
116 |
// push enum constant name and ordinal |
107 |
codeStream.ldc(String.valueOf(enumConstant.name)); |
117 |
codeStream.ldc(String.valueOf(this.enumConstant.name)); |
108 |
codeStream.generateInlinedValue(enumConstant.binding.id); |
118 |
codeStream.generateInlinedValue(this.enumConstant.binding.id); |
109 |
} |
119 |
} |
110 |
// handling innerclass instance allocation - enclosing instance arguments |
120 |
// handling innerclass instance allocation - enclosing instance arguments |
111 |
if (allocatedType.isNestedType()) { |
121 |
if (allocatedType.isNestedType()) { |
Lines 116-122
Link Here
|
116 |
this); |
126 |
this); |
117 |
} |
127 |
} |
118 |
// generate the arguments for constructor |
128 |
// generate the arguments for constructor |
119 |
generateArguments(binding, arguments, currentScope, codeStream); |
129 |
generateArguments(this.binding, this.arguments, currentScope, codeStream); |
120 |
// handling innerclass instance allocation - outer local arguments |
130 |
// handling innerclass instance allocation - outer local arguments |
121 |
if (allocatedType.isNestedType()) { |
131 |
if (allocatedType.isNestedType()) { |
122 |
codeStream.generateSyntheticOuterArgumentValues( |
132 |
codeStream.generateSyntheticOuterArgumentValues( |
Lines 126-155
Link Here
|
126 |
} |
136 |
} |
127 |
|
137 |
|
128 |
// invoke constructor |
138 |
// invoke constructor |
129 |
if (syntheticAccessor == null) { |
139 |
if (this.syntheticAccessor == null) { |
130 |
codeStream.invokespecial(this.codegenBinding); |
140 |
codeStream.invokespecial(this.codegenBinding); |
131 |
} else { |
141 |
} else { |
132 |
// synthetic accessor got some extra arguments appended to its signature, which need values |
142 |
// synthetic accessor got some extra arguments appended to its signature, which need values |
133 |
for (int i = 0, |
143 |
for (int i = 0, |
134 |
max = syntheticAccessor.parameters.length - this.codegenBinding.parameters.length; |
144 |
max = this.syntheticAccessor.parameters.length - this.codegenBinding.parameters.length; |
135 |
i < max; |
145 |
i < max; |
136 |
i++) { |
146 |
i++) { |
137 |
codeStream.aconst_null(); |
147 |
codeStream.aconst_null(); |
138 |
} |
148 |
} |
139 |
codeStream.invokespecial(syntheticAccessor); |
149 |
codeStream.invokespecial(this.syntheticAccessor); |
140 |
} |
150 |
} |
141 |
codeStream.generateImplicitConversion(this.implicitConversion); |
151 |
codeStream.generateImplicitConversion(this.implicitConversion); |
142 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
152 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
143 |
|
153 |
|
144 |
if (anonymousType != null) { |
154 |
if (this.anonymousType != null) { |
145 |
anonymousType.generateCode(currentScope, codeStream); |
155 |
this.anonymousType.generateCode(currentScope, codeStream); |
146 |
} |
156 |
} |
147 |
} |
157 |
} |
148 |
|
158 |
|
149 |
public boolean isSuperAccess() { |
159 |
public boolean isSuperAccess() { |
150 |
|
160 |
|
151 |
// necessary to lookup super constructor of anonymous type |
161 |
// necessary to lookup super constructor of anonymous type |
152 |
return anonymousType != null; |
162 |
return this.anonymousType != null; |
153 |
} |
163 |
} |
154 |
|
164 |
|
155 |
/* Inner emulation consists in either recording a dependency |
165 |
/* Inner emulation consists in either recording a dependency |
Lines 162-178
Link Here
|
162 |
public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { |
172 |
public void manageEnclosingInstanceAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo) { |
163 |
|
173 |
|
164 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { |
174 |
if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) { |
165 |
ReferenceBinding allocatedTypeErasure = (ReferenceBinding) binding.declaringClass.erasure(); |
175 |
ReferenceBinding allocatedTypeErasure = (ReferenceBinding) this.binding.declaringClass.erasure(); |
166 |
|
176 |
|
167 |
// perform some extra emulation work in case there is some and we are inside a local type only |
177 |
// perform some extra emulation work in case there is some and we are inside a local type only |
168 |
if (allocatedTypeErasure.isNestedType() |
178 |
if (allocatedTypeErasure.isNestedType() |
169 |
&& currentScope.enclosingSourceType().isLocalType()) { |
179 |
&& currentScope.enclosingSourceType().isLocalType()) { |
170 |
|
180 |
|
171 |
if (allocatedTypeErasure.isLocalType()) { |
181 |
if (allocatedTypeErasure.isLocalType()) { |
172 |
((LocalTypeBinding) allocatedTypeErasure).addInnerEmulationDependent(currentScope, enclosingInstance != null); |
182 |
((LocalTypeBinding) allocatedTypeErasure).addInnerEmulationDependent(currentScope, this.enclosingInstance != null); |
173 |
} else { |
183 |
} else { |
174 |
// locally propagate, since we already now the desired shape for sure |
184 |
// locally propagate, since we already now the desired shape for sure |
175 |
currentScope.propagateInnerEmulation(allocatedTypeErasure, enclosingInstance != null); |
185 |
currentScope.propagateInnerEmulation(allocatedTypeErasure, this.enclosingInstance != null); |
176 |
} |
186 |
} |
177 |
} |
187 |
} |
178 |
} |
188 |
} |
Lines 180-190
Link Here
|
180 |
|
190 |
|
181 |
public StringBuffer printExpression(int indent, StringBuffer output) { |
191 |
public StringBuffer printExpression(int indent, StringBuffer output) { |
182 |
|
192 |
|
183 |
if (enclosingInstance != null) |
193 |
if (this.enclosingInstance != null) |
184 |
enclosingInstance.printExpression(0, output).append('.'); |
194 |
this.enclosingInstance.printExpression(0, output).append('.'); |
185 |
super.printExpression(0, output); |
195 |
super.printExpression(0, output); |
186 |
if (anonymousType != null) { |
196 |
if (this.anonymousType != null) { |
187 |
anonymousType.print(indent, output); |
197 |
this.anonymousType.print(indent, output); |
188 |
} |
198 |
} |
189 |
return output; |
199 |
return output; |
190 |
} |
200 |
} |
Lines 200-231
Link Here
|
200 |
// ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt |
210 |
// ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt |
201 |
// ClassInstanceCreationExpression ::= Name '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt |
211 |
// ClassInstanceCreationExpression ::= Name '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt |
202 |
|
212 |
|
203 |
constant = Constant.NotAConstant; |
213 |
this.constant = Constant.NotAConstant; |
204 |
TypeBinding enclosingInstanceType = null; |
214 |
TypeBinding enclosingInstanceType = null; |
205 |
TypeBinding receiverType = null; |
215 |
TypeBinding receiverType = null; |
206 |
boolean hasError = false; |
216 |
boolean hasError = false; |
207 |
boolean enclosingInstanceContainsCast = false; |
217 |
boolean enclosingInstanceContainsCast = false; |
208 |
boolean argsContainCast = false; |
218 |
boolean argsContainCast = false; |
209 |
|
219 |
|
210 |
if (enclosingInstance != null) { |
220 |
if (this.enclosingInstance != null) { |
211 |
if (enclosingInstance instanceof CastExpression) { |
221 |
if (this.enclosingInstance instanceof CastExpression) { |
212 |
enclosingInstance.bits |= DisableUnnecessaryCastCheck; // will check later on |
222 |
this.enclosingInstance.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on |
213 |
enclosingInstanceContainsCast = true; |
223 |
enclosingInstanceContainsCast = true; |
214 |
} |
224 |
} |
215 |
if ((enclosingInstanceType = enclosingInstance.resolveType(scope)) == null){ |
225 |
if ((enclosingInstanceType = this.enclosingInstance.resolveType(scope)) == null){ |
216 |
hasError = true; |
226 |
hasError = true; |
217 |
} else if (enclosingInstanceType.isBaseType() || enclosingInstanceType.isArrayType()) { |
227 |
} else if (enclosingInstanceType.isBaseType() || enclosingInstanceType.isArrayType()) { |
218 |
scope.problemReporter().illegalPrimitiveOrArrayTypeForEnclosingInstance( |
228 |
scope.problemReporter().illegalPrimitiveOrArrayTypeForEnclosingInstance( |
219 |
enclosingInstanceType, |
229 |
enclosingInstanceType, |
220 |
enclosingInstance); |
230 |
this.enclosingInstance); |
221 |
hasError = true; |
231 |
hasError = true; |
222 |
} else if (type instanceof QualifiedTypeReference) { |
232 |
} else if (this.type instanceof QualifiedTypeReference) { |
223 |
scope.problemReporter().illegalUsageOfQualifiedTypeReference((QualifiedTypeReference)type); |
233 |
scope.problemReporter().illegalUsageOfQualifiedTypeReference((QualifiedTypeReference)this.type); |
224 |
hasError = true; |
234 |
hasError = true; |
225 |
} else { |
235 |
} else { |
226 |
receiverType = ((SingleTypeReference) type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType); |
236 |
receiverType = ((SingleTypeReference) this.type).resolveTypeEnclosing(scope, (ReferenceBinding) enclosingInstanceType); |
227 |
if (receiverType != null && enclosingInstanceContainsCast) { |
237 |
if (receiverType != null && enclosingInstanceContainsCast) { |
228 |
CastExpression.checkNeedForEnclosingInstanceCast(scope, enclosingInstance, enclosingInstanceType, receiverType); |
238 |
CastExpression.checkNeedForEnclosingInstanceCast(scope, this.enclosingInstance, enclosingInstanceType, receiverType); |
229 |
} |
239 |
} |
230 |
} |
240 |
} |
231 |
} else { |
241 |
} else { |
Lines 259-269
Link Here
|
259 |
} else if (((ReferenceBinding) receiverType).isFinal()) { |
269 |
} else if (((ReferenceBinding) receiverType).isFinal()) { |
260 |
if (this.anonymousType != null) { |
270 |
if (this.anonymousType != null) { |
261 |
if (!receiverType.isEnum()) { |
271 |
if (!receiverType.isEnum()) { |
262 |
scope.problemReporter().anonymousClassCannotExtendFinalClass(type, receiverType); |
272 |
scope.problemReporter().anonymousClassCannotExtendFinalClass(this.type, receiverType); |
263 |
hasError = true; |
273 |
hasError = true; |
264 |
} |
274 |
} |
265 |
} else if (!receiverType.canBeInstantiated()) { |
275 |
} else if (!receiverType.canBeInstantiated()) { |
266 |
scope.problemReporter().cannotInstantiate(type, receiverType); |
276 |
scope.problemReporter().cannotInstantiate(this.type, receiverType); |
267 |
return this.resolvedType = receiverType; |
277 |
return this.resolvedType = receiverType; |
268 |
} |
278 |
} |
269 |
} |
279 |
} |
Lines 286-298
Link Here
|
286 |
|
296 |
|
287 |
// will check for null after args are resolved |
297 |
// will check for null after args are resolved |
288 |
TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; |
298 |
TypeBinding[] argumentTypes = Binding.NO_PARAMETERS; |
289 |
if (arguments != null) { |
299 |
if (this.arguments != null) { |
290 |
int length = arguments.length; |
300 |
int length = this.arguments.length; |
291 |
argumentTypes = new TypeBinding[length]; |
301 |
argumentTypes = new TypeBinding[length]; |
292 |
for (int i = 0; i < length; i++) { |
302 |
for (int i = 0; i < length; i++) { |
293 |
Expression argument = this.arguments[i]; |
303 |
Expression argument = this.arguments[i]; |
294 |
if (argument instanceof CastExpression) { |
304 |
if (argument instanceof CastExpression) { |
295 |
argument.bits |= DisableUnnecessaryCastCheck; // will check later on |
305 |
argument.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on |
296 |
argsContainCast = true; |
306 |
argsContainCast = true; |
297 |
} |
307 |
} |
298 |
if ((argumentTypes[i] = argument.resolveType(scope)) == null){ |
308 |
if ((argumentTypes[i] = argument.resolveType(scope)) == null){ |
Lines 305-319
Link Here
|
305 |
if (this.anonymousType == null) { |
315 |
if (this.anonymousType == null) { |
306 |
// qualified allocation with no anonymous type |
316 |
// qualified allocation with no anonymous type |
307 |
if (!receiverType.canBeInstantiated()) { |
317 |
if (!receiverType.canBeInstantiated()) { |
308 |
scope.problemReporter().cannotInstantiate(type, receiverType); |
318 |
scope.problemReporter().cannotInstantiate(this.type, receiverType); |
309 |
return this.resolvedType = receiverType; |
319 |
return this.resolvedType = receiverType; |
310 |
} |
320 |
} |
311 |
ReferenceBinding allocationType = (ReferenceBinding) receiverType; |
321 |
ReferenceBinding allocationType = (ReferenceBinding) receiverType; |
312 |
if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { |
322 |
if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) { |
313 |
if (isMethodUseDeprecated(binding, scope, true)) { |
323 |
if (isMethodUseDeprecated(this.binding, scope, true)) { |
314 |
scope.problemReporter().deprecatedMethod(this.binding, this); |
324 |
scope.problemReporter().deprecatedMethod(this.binding, this); |
315 |
} |
325 |
} |
316 |
checkInvocationArguments(scope, null, allocationType, binding, this.arguments, argumentTypes, argsContainCast, this); |
326 |
checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this); |
317 |
} else { |
327 |
} else { |
318 |
if (this.binding.declaringClass == null) { |
328 |
if (this.binding.declaringClass == null) { |
319 |
this.binding.declaringClass = allocationType; |
329 |
this.binding.declaringClass = allocationType; |
Lines 327-333
Link Here
|
327 |
if (expectedType != enclosingInstanceType) // must call before computeConversion() and typeMismatchError() |
337 |
if (expectedType != enclosingInstanceType) // must call before computeConversion() and typeMismatchError() |
328 |
scope.compilationUnitScope().recordTypeConversion(expectedType, enclosingInstanceType); |
338 |
scope.compilationUnitScope().recordTypeConversion(expectedType, enclosingInstanceType); |
329 |
if (enclosingInstanceType.isCompatibleWith(expectedType) || scope.isBoxingCompatibleWith(enclosingInstanceType, expectedType)) { |
339 |
if (enclosingInstanceType.isCompatibleWith(expectedType) || scope.isBoxingCompatibleWith(enclosingInstanceType, expectedType)) { |
330 |
enclosingInstance.computeConversion(scope, expectedType, enclosingInstanceType); |
340 |
this.enclosingInstance.computeConversion(scope, expectedType, enclosingInstanceType); |
331 |
return this.resolvedType = receiverType; |
341 |
return this.resolvedType = receiverType; |
332 |
} |
342 |
} |
333 |
scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance); |
343 |
scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance); |
Lines 338-345
Link Here
|
338 |
receiverType = new ProblemReferenceBinding(receiverType.sourceName(), (ReferenceBinding)receiverType, ProblemReasons.IllegalSuperTypeVariable); |
348 |
receiverType = new ProblemReferenceBinding(receiverType.sourceName(), (ReferenceBinding)receiverType, ProblemReasons.IllegalSuperTypeVariable); |
339 |
scope.problemReporter().invalidType(this, receiverType); |
349 |
scope.problemReporter().invalidType(this, receiverType); |
340 |
return null; |
350 |
return null; |
341 |
} else if (type != null && receiverType.isEnum()) { // tolerate enum constant body |
351 |
} else if (this.type != null && receiverType.isEnum()) { // tolerate enum constant body |
342 |
scope.problemReporter().cannotInstantiate(type, receiverType); |
352 |
scope.problemReporter().cannotInstantiate(this.type, receiverType); |
343 |
return this.resolvedType = receiverType; |
353 |
return this.resolvedType = receiverType; |
344 |
} |
354 |
} |
345 |
// anonymous type scenario |
355 |
// anonymous type scenario |
Lines 348-359
Link Here
|
348 |
// insert anonymous type in scope |
358 |
// insert anonymous type in scope |
349 |
scope.addAnonymousType(this.anonymousType, (ReferenceBinding) receiverType); |
359 |
scope.addAnonymousType(this.anonymousType, (ReferenceBinding) receiverType); |
350 |
this.anonymousType.resolve(scope); |
360 |
this.anonymousType.resolve(scope); |
351 |
if (this.superTypeBinding.erasure().id == T_JavaLangEnum) { |
361 |
if (this.superTypeBinding.erasure().id == TypeIds.T_JavaLangEnum) { |
352 |
scope.problemReporter().cannotExtendEnum(this.anonymousType.binding, this.type, this.superTypeBinding); |
362 |
scope.problemReporter().cannotExtendEnum(this.anonymousType.binding, this.type, this.superTypeBinding); |
353 |
} |
363 |
} |
354 |
|
364 |
|
355 |
if ((receiverType.tagBits & TagBits.HasDirectWildcard) != 0) { |
365 |
if ((receiverType.tagBits & TagBits.HasDirectWildcard) != 0) { |
356 |
scope.problemReporter().superTypeCannotUseWildcard(anonymousType.binding, this.type, receiverType); |
366 |
scope.problemReporter().superTypeCannotUseWildcard(this.anonymousType.binding, this.type, receiverType); |
357 |
} |
367 |
} |
358 |
// find anonymous super constructor |
368 |
// find anonymous super constructor |
359 |
MethodBinding inheritedBinding = scope.getConstructor(this.superTypeBinding, argumentTypes, this); |
369 |
MethodBinding inheritedBinding = scope.getConstructor(this.superTypeBinding, argumentTypes, this); |
Lines 362-393
Link Here
|
362 |
inheritedBinding.declaringClass = this.superTypeBinding; |
372 |
inheritedBinding.declaringClass = this.superTypeBinding; |
363 |
} |
373 |
} |
364 |
scope.problemReporter().invalidConstructor(this, inheritedBinding); |
374 |
scope.problemReporter().invalidConstructor(this, inheritedBinding); |
365 |
return this.resolvedType = anonymousType.binding; |
375 |
return this.resolvedType = this.anonymousType.binding; |
366 |
} |
376 |
} |
367 |
if (enclosingInstance != null) { |
377 |
if (this.enclosingInstance != null) { |
368 |
ReferenceBinding targetEnclosing = inheritedBinding.declaringClass.enclosingType(); |
378 |
ReferenceBinding targetEnclosing = inheritedBinding.declaringClass.enclosingType(); |
369 |
if (targetEnclosing == null) { |
379 |
if (targetEnclosing == null) { |
370 |
scope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, (ReferenceBinding)receiverType); |
380 |
scope.problemReporter().unnecessaryEnclosingInstanceSpecification(this.enclosingInstance, (ReferenceBinding)receiverType); |
371 |
return this.resolvedType = anonymousType.binding; |
381 |
return this.resolvedType = this.anonymousType.binding; |
372 |
} else if (!enclosingInstanceType.isCompatibleWith(targetEnclosing) && !scope.isBoxingCompatibleWith(enclosingInstanceType, targetEnclosing)) { |
382 |
} else if (!enclosingInstanceType.isCompatibleWith(targetEnclosing) && !scope.isBoxingCompatibleWith(enclosingInstanceType, targetEnclosing)) { |
373 |
scope.problemReporter().typeMismatchError(enclosingInstanceType, targetEnclosing, enclosingInstance); |
383 |
scope.problemReporter().typeMismatchError(enclosingInstanceType, targetEnclosing, this.enclosingInstance); |
374 |
return this.resolvedType = anonymousType.binding; |
384 |
return this.resolvedType = this.anonymousType.binding; |
375 |
} |
385 |
} |
376 |
enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); |
386 |
this.enclosingInstance.computeConversion(scope, targetEnclosing, enclosingInstanceType); |
377 |
} |
387 |
} |
378 |
if (this.arguments != null) |
388 |
if (this.arguments != null) |
379 |
checkInvocationArguments(scope, null, this.superTypeBinding, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this); |
389 |
checkInvocationArguments(scope, null, this.superTypeBinding, inheritedBinding, this.arguments, argumentTypes, argsContainCast, this); |
380 |
|
390 |
|
381 |
// Update the anonymous inner class : superclass, interface |
391 |
// Update the anonymous inner class : superclass, interface |
382 |
binding = anonymousType.createDefaultConstructorWithBinding(inheritedBinding); |
392 |
this.binding = this.anonymousType.createDefaultConstructorWithBinding(inheritedBinding); |
383 |
return this.resolvedType = anonymousType.binding; // 1.2 change |
393 |
return this.resolvedType = this.anonymousType.binding; // 1.2 change |
384 |
} |
394 |
} |
385 |
|
395 |
|
386 |
public void traverse(ASTVisitor visitor, BlockScope scope) { |
396 |
public void traverse(ASTVisitor visitor, BlockScope scope) { |
387 |
|
397 |
|
388 |
if (visitor.visit(this, scope)) { |
398 |
if (visitor.visit(this, scope)) { |
389 |
if (enclosingInstance != null) |
399 |
if (this.enclosingInstance != null) |
390 |
enclosingInstance.traverse(visitor, scope); |
400 |
this.enclosingInstance.traverse(visitor, scope); |
391 |
if (this.typeArguments != null) { |
401 |
if (this.typeArguments != null) { |
392 |
for (int i = 0, typeArgumentsLength = this.typeArguments.length; i < typeArgumentsLength; i++) { |
402 |
for (int i = 0, typeArgumentsLength = this.typeArguments.length; i < typeArgumentsLength; i++) { |
393 |
this.typeArguments[i].traverse(visitor, scope); |
403 |
this.typeArguments[i].traverse(visitor, scope); |
Lines 395-407
Link Here
|
395 |
} |
405 |
} |
396 |
if (this.type != null) // case of enum constant |
406 |
if (this.type != null) // case of enum constant |
397 |
this.type.traverse(visitor, scope); |
407 |
this.type.traverse(visitor, scope); |
398 |
if (arguments != null) { |
408 |
if (this.arguments != null) { |
399 |
int argumentsLength = arguments.length; |
409 |
int argumentsLength = this.arguments.length; |
400 |
for (int i = 0; i < argumentsLength; i++) |
410 |
for (int i = 0; i < argumentsLength; i++) |
401 |
arguments[i].traverse(visitor, scope); |
411 |
this.arguments[i].traverse(visitor, scope); |
402 |
} |
412 |
} |
403 |
if (anonymousType != null) |
413 |
if (this.anonymousType != null) |
404 |
anonymousType.traverse(visitor, scope); |
414 |
this.anonymousType.traverse(visitor, scope); |
405 |
} |
415 |
} |
406 |
visitor.endVisit(this, scope); |
416 |
visitor.endVisit(this, scope); |
407 |
} |
417 |
} |