Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify @ContextResolved IR body generation #41

Open
kyay10 opened this issue Nov 15, 2022 · 0 comments
Open

Simplify @ContextResolved IR body generation #41

kyay10 opened this issue Nov 15, 2022 · 0 comments

Comments

@kyay10
Copy link

kyay10 commented Nov 15, 2022

Is there any reason why in the IR plugin, the body of the @ContextResolved functions that it creates consists of a call to arrow.inject.annotations.contextual(ev: T, f: T.() -> R) for each proof, nested in a lambda recursively, then finally a call to the original function? At least that's what I'm understanding from the code.

I've tried this out myself previously, and the IR backend seems to not really care as to what expression you place as a context receiver argument. In fact, arbitrary function calls work just fine

Is this some future-proofing measure or something that I'm not seeing? Because it seems to be extra code that will need to be maintained down-the-road.

Btw, there's one case in the compiler where a context receiver argument is not just simply a reference to a context in scope, and that is when an implicit receiver (which includes context receivers) has been smartcasted and hence needs a smart-cast expression wrapped around it, So I'm guessing that's why the compiler allows arbitrary expressions there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant