for (int i = length; --i >= 0;) {
pseudoArgs[i] = argumentTypes[i] == null ? TypeBinding.NULL : argumentTypes[i]; // replace args with errors with null type
}
this.binding = scope.findMethod((ReferenceBinding) receiverType, TypeConstants.INIT, pseudoArgs, this);
if (this.binding != null && !this.binding.isValidBinding()) {
MethodBinding closestMatch = ((ProblemMethodBinding)this.binding).closestMatch;
// record the closest match, for clients who may still need hint about possible method match
if (closestMatch != null) {
if (closestMatch.original().typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method
// shouldn't return generic method outside its context, rather convert it to raw method (175409)
closestMatch = scope.environment().createParameterizedGenericMethod(closestMatch.original(), (RawTypeBinding)null);
}
this.binding = closestMatch;
MethodBinding closestMatchOriginal = closestMatch.original();
if ((closestMatchOriginal.isPrivate() || closestMatchOriginal.declaringClass.isLocalType()) && !scope.isDefinedInMethod(closestMatchOriginal)) {
// ignore cases where method is used from within inside itself (e.g. direct recursions)
closestMatchOriginal.modifiers |= ExtraCompilerModifiers.AccLocallyUsed;
}
}
}
}
return this.resolvedType = receiverType;
}
if (this.anonymousType == null) {
// qualified allocation with no anonymous type
if (!receiverType.canBeInstantiated()) {
scope.problemReporter().cannotInstantiate(this.type, receiverType);
return this.resolvedType = receiverType;
}
ReferenceBinding allocationType = (ReferenceBinding) receiverType;
if ((this.binding = scope.getConstructor(allocationType, argumentTypes, this)).isValidBinding()) {
if (isMethodUseDeprecated(this.binding, scope, true)) {
scope.problemReporter().deprecatedMethod(this.binding, this);
}
checkInvocationArguments(scope, null, allocationType, this.binding, this.arguments, argumentTypes, argsContainCast, this);
} else {
if (this.binding.declaringClass == null) {
this.binding.declaringClass = allocationType;
}
scope.problemReporter().invalidConstructor(this, this.binding);
return this.resolvedType = receiverType;
}
// The enclosing instance must be compatible with the innermost enclosing type
ReferenceBinding expectedType = this.binding.declaringClass.enclosingType();
if (expectedType != enclosingInstanceType) // must call before computeConversion() and typeMismatchError()
scope.compilationUnitScope().recordTypeConversion(expectedType, enclosingInstanceType);
if (enclosingInstanceType.isCompatibleWith(expectedType) || scope.isBoxingCompatibleWith(enclosingInstanceType, expectedType)) {
this.enclosingInstance.computeConversion(scope, expectedType, enclosingInstanceType);
return this.resolvedType = receiverType;
}
scope.problemReporter().typeMismatchError(enclosingInstanceType, expectedType, this.enclosingInstance);
return this.resolvedType = receiverType;
}
if (receiverType.isTypeVariable()) {
receiverType = new ProblemReferenceBinding(receiverType.sourceName(), (ReferenceBinding)receiverType, ProblemReasons.IllegalSuperTypeVariable);
scope.problemReporter().invalidType(this, receiverType);
return null;
} else if (this.type != null && receiverType.isEnum()) { // tolerate enum constant body
scope.problemReporter().cannotInstantiate(this.type, receiverType);
return this.resolvedType = receiverType;
}
// anonymous type scenario
// an anonymous class inherits from java.lang.Object when declared "after" an interface
this.superTypeBinding = receiverType.isInterface() ? scope.getJavaLangObject() : (ReferenceBinding) receiverType;
// insert anonymous type in scope
scope.addAnonymousType(this.anonymousType, (ReferenceBinding) receiverType);
this.anonymousType.resolve(scope);
if (this.superTypeBinding.erasure().id == TypeIds.T_JavaLangEnum) {
scope.problemReporter().cannotExtendEnum(this.anonymousType.binding, this.type, this.superTypeBinding);
}
if ((receiverType.tagBits & TagBits.HasDirectWildcard) != 0) {
scope.problemReporter().superTypeCannotUseWildcard(this.anonymousType.binding, this.type, receiverType);
}
// find anonymous super constructor
MethodBinding inheritedBinding = scope.getConstructor(this.superTypeBinding, argumentTypes, this);
if (!inheritedBinding.isValidBinding()) {
if (inheritedBinding.declaringClass == null) {
inheritedBinding.declaringClass = this.superTypeBinding;
}
scope.problemReporter().invalidConstructor(this, inheritedBinding);
return this.resolvedType = this.anonymousType.binding;