public NType resolve(Scope outer) throws Exception {
resolveList(defaults, outer);
resolveList(decoratorList, outer);
Scope funcTable = getTable();
NBinding selfBinding = funcTable.lookup("__self__");
if (selfBinding != null && !selfBinding.getType().isClassType()) {
selfBinding = null;
}
if (selfBinding != null) {
if (args.size() < 1) {
addWarning(name, "method should have at least one argument (self)");
} else if (!(args.get(0) instanceof NName)) {
addError(name, "self parameter must be an identifier");
}
}
NTupleType fromType = new NTupleType();
bindParamsToDefaults(selfBinding, fromType);
if (varargs != null) {
NBinding b = funcTable.lookupLocal(varargs.id);
if (b != null) {
fromType.add(b.getType());
}
}
if (kwargs != null) {
NBinding b = funcTable.lookupLocal(kwargs.id);
if (b != null) {
fromType.add(b.getType());
}
}
NType toType = resolveExpr(body, funcTable);
getType().asFuncType().setReturnType(toType);