Skip to content

Inline illegal access #13546

Closed
Closed
@soronpo

Description

@soronpo

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions