// FIXME: should report all ambiguous matches here
msg += "\n\tfound: " + candidateID + " : "
+ candidateType.nominal();
msg += "\n\tfound: " + p.first() + " : "
+ p.second().nominal();
throw new ResolveError(msg);
}
}
}
if (candidateType == null) {
// second, didn't find matching message so generate error message
String msg = "no match for " + name + parameterString(parameters);
for (Pair<NameID, Nominal.FunctionOrMethod> p : candidates) {
msg += "\n\tfound: " + p.first() + " : " + p.second().nominal();
}
throw new ResolveError(msg);
} else {
// now check protection modifier
WhileyFile wf = builder.getSourceFile(candidateID.module());
if (wf != null) {
if (wf != context.file()) {
for (WhileyFile.FunctionOrMethod d : wf.declarations(
WhileyFile.FunctionOrMethod.class,
candidateID.name())) {
if (d.parameters.equals(candidateType.params())) {
if (!d.hasModifier(Modifier.PUBLIC)
&& !d.hasModifier(Modifier.PROTECTED)) {
String msg = candidateID.module() + "." + name
+ parameterString(parameters)
+ " is not visible";
throw new ResolveError(msg);
}
}
}
}
} else {
WyilFile m = builder.getModule(candidateID.module());
WyilFile.FunctionOrMethodDeclaration d = m.functionOrMethod(
candidateID.name(), candidateType.raw());
if (!d.hasModifier(Modifier.PUBLIC)
&& !d.hasModifier(Modifier.PROTECTED)) {
String msg = candidateID.module() + "." + name
+ parameterString(parameters) + " is not visible";
throw new ResolveError(msg);
}
}
}
return new Pair<NameID, Nominal.FunctionOrMethod>(candidateID,