Conversation
81d111c to
5b301e2
Compare
…uments if overloading fails
|
@jiribenes You might be interested in the change from the last commit: I changed it so implicts of boxed type |
| def intArg(v: Long, name: Option[String] = None): source.ValueArg = | ||
| ValueArg(name, Literal(v, builtins.TInt, Span.missing), Span.missing) |
There was a problem hiding this comment.
Writing name-resolved source Terms by hand is somewhat annoying.
If we do so more (i.e. if we generate more stuff in source than we do here already), we might want to consider extracting this function, generateResolvedId etc into a somewhat nice library for it. I did not do for the relatively small amount of code here, but decided to at least extract some helpers.
| */ | ||
| private var nextCallId: Long = 0 | ||
|
|
||
| private def generateResolvedId(sym: symbols.Symbol)(using Context): (source.IdDef, source.IdRef) = { |
There was a problem hiding this comment.
(Here's generateResolvedId, mentioned in the other comment)
97082df to
85be025
Compare
Co-authored-by: Jonathan Immanuel Brachthäuser <jonathan.brachthaeuser@uni-tuebingen.de>
| val interface = recvTpe.asInterfaceType | ||
| // filter out operations that do not fit the receiver | ||
| val candidates = methods.filter(op => op.interface == interface.typeConstructor) | ||
| val candidates = methods.filter( op => op.interface == interface.typeConstructor ) |
There was a problem hiding this comment.
| val candidates = methods.filter( op => op.interface == interface.typeConstructor ) | |
| val candidates = methods.filter(op => op.interface == interface.typeConstructor) |
This implements implicits similar to
It also implements their use to get source positions in the code.
Syntax and Intended Behaviour
Putting a
?in front of a value/block parameter makes it potentially implicit. If trailing implicit parameters are missing, an argument is generated as follows (e.g.):$x:$xsourcePosition:SourcePosition("somefilename.effekt",10,3,10,6)(corresponding to the source position of the called function,withoutwith argument list)callId: A statically unique integer for this call (unique within an Effekt compiler run).(...) => ... at {...}: instantiated tobox {...}with whatever the block argument would be instantiated to.$fooof type(A){B=>C} => D:{ (a: A){b: B => C} => $foo(a){b} }(eta-expanded to allow for this call to also receive implicit arguments)$x:$xImplementation strategy
Namer,Typer,ExplicitCapabilities, actually change the source to pass the annotated arguments explicitly.TODO and limitations
Check if this works for more than the existing examples (find at least the worst bugs)The tests should be testing a good part of possible uses now.quite indirect (and not actual recursion) in typer, and(we can check for recursive uses when checking implicit arguments after instantiating them - this is separate now anyway) at a point where we don't necessarily have the concrete types (due to unification), so checking for "decreasing type size" or similar is potentially hard.