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

Inline illegal access #13546

Closed
soronpo opened this issue Sep 16, 2021 · 0 comments · Fixed by #13547
Closed

Inline illegal access #13546

soronpo opened this issue Sep 16, 2021 · 0 comments · Fixed by #13547
Assignees
Milestone

Comments

@soronpo
Copy link
Contributor

soronpo commented Sep 16, 2021

It seems that #12948 was not completely resolved. I updated the minimized project branch.

Compiler version

v3.1.0-RC2

Minimized code

See minimized project at: https://github.com/soronpo/dottybug/tree/inline_illegal_access

mylib/Main.scala

package mylib
import scala.quoted.*

object Main:
  protected def foo: Unit = {}
  inline def fooCaller: Unit = foo
  inline def fooCallerM: Unit = ${ fooMacro }
  def fooMacro(using Quotes): Expr[Unit] =
    val fooExpr = '{ foo }
    '{ $fooExpr }

Test.scala

import mylib.Main

object Test:
  Main.fooCaller //works
  Main.fooCallerM //error

Output

[error] 5 |  Main.fooCallerM //error
[error]   |  ^^^^^^^^^^^^^^^
[error]   |  illegal access to protected method foo in object Main from object Test
[error]   | This location contains code that was inlined from Main.scala:9
[error]   | This location contains code that was inlined from Main.scala:9

Expectation

No error.

Note: the minimized example reports the warning Canceled splice directly inside a quote. '{ ${ XYZ } } is equivalent to XYZ., which is true for this simple case and can be ignored.

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

Successfully merging a pull request may close this issue.

3 participants