WIP: Implement Java Interfaces with Frege Records#363
WIP: Implement Java Interfaces with Frege Records#363matil019 wants to merge 23 commits intoFrege:masterfrom
Conversation
| --- Wraps an expression into Thunk.lazy, without generics arguments: | ||
| --- > Thunk.lazy(expr) | ||
| asLazy :: JExpr -> JExpr | ||
| asLazy expr = |
There was a problem hiding this comment.
This is slightly different from frege.compiler.gen.java.Common.lazyJX. This function doesn't take a JType. A java compiler can infer the generics of Thunk.lazy from its argument, so there isn't a need to emit one, or is it?
There was a problem hiding this comment.
That's probably so, however, I adopted the policy to not rely on Java type inference if at all possible, as the frege compiler should know the desired types anyway.
Or, to put it differently, if we don't know the types, then we might need to re-consider our code generation model.
Therefore, I prefer having everything explicit in general.
That being said, it is possible that we can avoid some clutter here and there in code generation primitives like "lazyJX". But then we should adopt this in general, not just for some code.
| let nativsi = evalStG g $ symInfo nativsym | ||
| fldsym <- TreeMap.lookup fldnm irsym.env | ||
| pure $ wrapIRMethod g (head args) (tauJT g $ head taus) fldsym fldnm nativsi nativnm | ||
| in JNewClass jrty (tail args) x |
There was a problem hiding this comment.
head args here is the IR itself, so it's omitted. args is ensured to be nonempty in the sanity function.
So that it is possible to run programs even if some of them failed to compile
This PR is not meant to be merged (yet)!
The ongoing effort to implement the feature #360.
The changes are in
frege/compiler/gen/java/MethodCall.fr.Cases to consider:
MaybetonullmarshallingEithertothrowmarshalling