use of dyvilx.tools.compiler.ast.context.IImplicitContext in project Dyvil by Dyvil.
the class ICall method resolveMethods.
static MatchList<IMethod> resolveMethods(IContext context, IValue receiver, Name name, ArgumentList arguments) {
@SuppressWarnings("UnnecessaryLocalVariable") final IImplicitContext implicitContext = context;
final MatchList<IMethod> matches = new MatchList<>(implicitContext);
// Methods available via the receiver type
if (receiver != null) {
receiver.getType().getMethodMatches(matches, receiver, name, arguments);
if (matches.hasCandidate()) {
return matches;
}
}
// Methods available via the first argument
if (arguments.size() == 1) {
arguments.getFirst().getType().getMethodMatches(matches, receiver, name, arguments);
// b) an implicit conversion function from int to SomeType
if (matches.hasCandidate()) {
return matches;
}
}
// Methods available in the enclosing context
context.getMethodMatches(matches, receiver, name, arguments);
if (matches.hasCandidate()) {
return matches;
}
// Methods available through implicit conversions of the receiver
if (receiver != null) {
MatchList<IMethod> implicits = IContext.resolveImplicits(implicitContext, receiver, null);
for (Candidate<IMethod> candidate : implicits) {
candidate.getMember().getType().getMethodMatches(matches, receiver, name, arguments);
}
// resolved again.
if (matches.hasCandidate()) {
return matches;
}
}
// Methods available through the Lang Header
Types.BASE_CONTEXT.getMethodMatches(matches, receiver, name, arguments);
return matches;
}
Aggregations