-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Child class cannot access exported inline methods from parent class #16469
Comments
It seemed to work until Scala 3.1.2 |
The export generates the fianl inline def inlineMethod(): String = Script.this.ctx.inlineMethod() If we define this method manually we see that it becomes final inline def inlineMethod(): String = this.Script$$inline$ctx.inlineMethod():String
final def Script$$inline$ctx: Context = Script.this.ctx This implies that when we generate the exports, we are not transforming the contents of the inline export accessor with |
We probably do something wrong here. Maybe we use the wrong context or the transformation is discarded. |
Half of the issue is that we need to call |
* Fix context owner of `PrepareInlineable.registerInlineInfo`. It should have as owner the inline method (`forwarder` in this case). * Eagerly compute the inlinable RHS. Because we create the forwarder already typed, we do not evaluate/force in typer the `LazyBodyAnnotation` which is what triggers the computation of the inline accessors. This happened in posttyper which was too late. There might be a cleaner solution to this problem, maybe forcing the annotation explicitly. Fixes #14131 Fixes #16469
Compiler version
3.2.1
Minimized code
Output
Compiling project (Scala 3.2.1, JVM) [error] ./scala/inline-export-inherit.sc:16:3: ctx cannot be accessed as a member of (Script_this : (MyScript.this : inline-export-inherit.MyScript)) from class MyScript. [error] inlineMethod() // error [error] ^^^^^^^^^^^^^^
Expectation
It should compile unless the restriction is intentional. In that case, the reason should be mentioned in the docs.
Making
ctx
aval
inScript
constructor makes it compile.The text was updated successfully, but these errors were encountered: