Lines 51-60
Link Here
|
51 |
int nonStaticFieldInfoReachMode = flowInfo.reachMode(); |
51 |
int nonStaticFieldInfoReachMode = flowInfo.reachMode(); |
52 |
flowInfo.setReachMode(initialReachMode); |
52 |
flowInfo.setReachMode(initialReachMode); |
53 |
|
53 |
|
54 |
if (this.binding != null && !this.binding.isUsed() && (this.binding.isPrivate() || (this.binding.declaringClass.tagBits & (TagBits.IsAnonymousType|TagBits.IsLocalType)) == TagBits.IsLocalType)) { |
54 |
checkUnused: { |
55 |
if (!classScope.referenceCompilationUnit().compilationResult.hasSyntaxError) { |
55 |
MethodBinding constructorBinding; |
56 |
this.scope.problemReporter().unusedPrivateConstructor(this); |
56 |
if ((constructorBinding = this.binding) == null) break checkUnused; |
|
|
57 |
if (this.isDefaultConstructor) break checkUnused; |
58 |
if (constructorBinding.isUsed()) break checkUnused; |
59 |
if (constructorBinding.isPrivate()) { |
60 |
if ((this.binding.declaringClass.tagBits & TagBits.HasNonPrivateConstructor) == 0) |
61 |
break checkUnused; // tolerate as known pattern to block instantiation |
62 |
} else if ((this.binding.declaringClass.tagBits & (TagBits.IsAnonymousType|TagBits.IsLocalType)) != TagBits.IsLocalType) { |
63 |
break checkUnused; |
57 |
} |
64 |
} |
|
|
65 |
// complain unused |
66 |
this.scope.problemReporter().unusedPrivateConstructor(this); |
58 |
} |
67 |
} |
59 |
|
68 |
|
60 |
// check constructor recursion, once all constructor got resolved |
69 |
// check constructor recursion, once all constructor got resolved |
Lines 412-440
Link Here
|
412 |
* for recursive constructor invocations. |
421 |
* for recursive constructor invocations. |
413 |
*/ |
422 |
*/ |
414 |
public void resolveStatements() { |
423 |
public void resolveStatements() { |
415 |
if (!CharOperation.equals(this.scope.enclosingSourceType().sourceName, this.selector)){ |
424 |
SourceTypeBinding sourceType = this.scope.enclosingSourceType(); |
|
|
425 |
if (!CharOperation.equals(sourceType.sourceName, this.selector)){ |
416 |
this.scope.problemReporter().missingReturnType(this); |
426 |
this.scope.problemReporter().missingReturnType(this); |
417 |
} |
427 |
} |
418 |
|
|
|
419 |
if (this.typeParameters != null) { |
428 |
if (this.typeParameters != null) { |
420 |
for (int i = 0, length = this.typeParameters.length; i < length; i++) { |
429 |
for (int i = 0, length = this.typeParameters.length; i < length; i++) { |
421 |
this.typeParameters[i].resolve(this.scope); |
430 |
this.typeParameters[i].resolve(this.scope); |
422 |
} |
431 |
} |
423 |
} |
432 |
} |
424 |
|
433 |
if (this.binding != null && !this.binding.isPrivate()) { |
|
|
434 |
sourceType.tagBits |= TagBits.HasNonPrivateConstructor; |
435 |
} |
425 |
// if null ==> an error has occurs at parsing time .... |
436 |
// if null ==> an error has occurs at parsing time .... |
426 |
if (this.constructorCall != null) { |
437 |
if (this.constructorCall != null) { |
427 |
// e.g. using super() in java.lang.Object |
438 |
if (sourceType.id == TypeIds.T_JavaLangObject |
428 |
if (this.binding != null |
439 |
&& this.constructorCall.accessMode != ExplicitConstructorCall.This) { |
429 |
&& this.binding.declaringClass.id == TypeIds.T_JavaLangObject |
440 |
// cannot use super() in java.lang.Object |
430 |
&& this.constructorCall.accessMode != ExplicitConstructorCall.This) { |
441 |
if (this.constructorCall.accessMode == ExplicitConstructorCall.Super) { |
431 |
if (this.constructorCall.accessMode == ExplicitConstructorCall.Super) { |
442 |
this.scope.problemReporter().cannotUseSuperInJavaLangObject(this.constructorCall); |
432 |
this.scope.problemReporter().cannotUseSuperInJavaLangObject(this.constructorCall); |
443 |
} |
433 |
} |
444 |
this.constructorCall = null; |
434 |
this.constructorCall = null; |
|
|
435 |
} else { |
445 |
} else { |
436 |
this.constructorCall.resolve(this.scope); |
446 |
this.constructorCall.resolve(this.scope); |
437 |
} |
447 |
} |
438 |
} |
448 |
} |
439 |
if ((this.modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0) { |
449 |
if ((this.modifiers & ExtraCompilerModifiers.AccSemicolonBody) != 0) { |
440 |
this.scope.problemReporter().methodNeedBody(this); |
450 |
this.scope.problemReporter().methodNeedBody(this); |