Skip to content

Lose experimental scope while macro implementation has private/protected modifier #16091

Closed
@jilen

Description

@jilen

Compiler version

3.2.0

Minimized code

import scala.quoted._
import scala.annotation.experimental

trait Foo {}

object Macro {
 @experimental
  inline def foo() = ${ fooImpl }

  @experimental
  private def fooImpl(using Quotes) = {
    import quotes.reflect._
    val name: String = "TestFoo"
    val parents = List(TypeTree.of[Object])
    val cls = Symbol.newClass(
      Symbol.spliceOwner,
      name,
      parents = parents.map(_.tpe),
      _ => Nil,
      selfType = None
    )
    '{
      new Foo {}
    }
  }
}

Output

Report error

method fooImpl is marked @experimental and therefore may only be used in an experimental scope.

Expectation

private def fooImpl(using Quotes) = ...

Without private modifier, this example compiles (even without @experimental at call site.).
Should be same with private modifier.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions