// prefix for setter method (to recognize special hiding argument)
private final static char[] SET = "set".toCharArray(); //$NON-NLS-1$
-
+
public Argument(char[] name, long posNom, TypeReference tr, int modifiers) {
super(name, (int) (posNom >>> 32), (int) posNom);
public void bind(MethodScope scope, TypeBinding typeBinding, boolean used) {
if (this.type != null)
- this.type.resolvedType = typeBinding;
+ this.type.resolvedType = typeBinding; // TODO (philippe) no longer necessary as when binding got resolved, it was recorded already (SourceTypeBinding#resolveTypesFor(MethodBinding))
// record the resolved type into the type reference
int modifierFlag = this.modifiers;
- Binding existingVariable = scope.getBinding(name, BindingIds.VARIABLE, this, false /*do not resolve hidden field*/);
+ Binding existingVariable = scope.getBinding(name, Binding.VARIABLE, this, false /*do not resolve hidden field*/);
if (existingVariable != null && existingVariable.isValidBinding()){
if (existingVariable instanceof LocalVariableBinding && this.hiddenVariableDepth == 0) {
scope.problemReporter().redefineArgument(this);
scope.addLocalVariable(
this.binding =
new LocalVariableBinding(this, typeBinding, modifierFlag, true));
+ resolveAnnotations(scope, this.annotations, this.binding);
//true stand for argument instead of just local
- if (typeBinding != null && isTypeUseDeprecated(typeBinding, scope))
- scope.problemReporter().deprecatedType(typeBinding, this.type);
this.binding.declaration = this;
this.binding.useFlag = used ? LocalVariableBinding.USED : LocalVariableBinding.UNUSED;
}
+ /**
+ * @see org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration#getKind()
+ */
+ public int getKind() {
+ return PARAMETER;
+ }
+
+ public boolean isVarArgs() {
+ return (this.type.bits & IsVarArgs) != 0;
+ }
+
public StringBuffer print(int indent, StringBuffer output) {
printIndent(indent, output);
printModifiers(this.modifiers, output);
+ if (this.annotations != null) printAnnotations(this.annotations, output);
+
if (type == null) {
output.append("<no type> "); //$NON-NLS-1$
} else {
// provide the scope with a side effect : insertion of a LOCAL
// that represents the argument. The type must be from JavaThrowable
- TypeBinding tb = type.resolveTypeExpecting(scope, scope.getJavaLangThrowable());
- if (tb == null)
+ TypeBinding exceptionType = this.type.resolveType(scope, true /* check bounds*/);
+ if (exceptionType == null) return null;
+ if (exceptionType.isGenericType() || exceptionType.isParameterizedType()) {
+ scope.problemReporter().invalidParameterizedExceptionType(exceptionType, this);
return null;
-
- Binding existingVariable = scope.getBinding(name, BindingIds.VARIABLE, this, false /*do not resolve hidden field*/);
+ }
+ if (exceptionType.isTypeVariable()) {
+ scope.problemReporter().invalidTypeVariableAsException(exceptionType, this);
+ return null;
+ }
+ TypeBinding throwable = scope.getJavaLangThrowable();
+ if (!exceptionType.isCompatibleWith(throwable)) {
+ scope.problemReporter().typeMismatchError(exceptionType, throwable, this);
+ return null;
+ }
+
+ Binding existingVariable = scope.getBinding(name, Binding.VARIABLE, this, false /*do not resolve hidden field*/);
if (existingVariable != null && existingVariable.isValidBinding()){
if (existingVariable instanceof LocalVariableBinding && this.hiddenVariableDepth == 0) {
scope.problemReporter().redefineArgument(this);
scope.problemReporter().localVariableHiding(this, existingVariable, false);
}
- binding = new LocalVariableBinding(this, tb, modifiers, false); // argument decl, but local var (where isArgument = false)
+ this.binding = new LocalVariableBinding(this, exceptionType, modifiers, false); // argument decl, but local var (where isArgument = false)
+ resolveAnnotations(scope, this.annotations, this.binding);
+
scope.addLocalVariable(binding);
- binding.constant = NotAConstant;
- return tb;
+ binding.setConstant(NotAConstant);
+ return exceptionType;
}
public void traverse(ASTVisitor visitor, BlockScope scope) {