Skip to content

Unable to use self reference in refinement within quotes #17409

Closed
@steinybot

Description

@steinybot

Compiler version

3.3.0-RC3

Minimized code

import scala.quoted.*

transparent inline def thing =
  ${ thingImpl }

def thingImpl(using Quotes): Expr[Any] =
  '{
    def makeThing: { def me: this.type } = ???
    makeThing
  }

Output

access to <refinement>.this from wrong staging level:
 - the definition is at level 0,
 - but the access is at level 1.

Expectation

I think this should compile.

I know that self reference in refinement is deprecated but I haven't figured out another way to refer to the same type, especially since cyclic type references are illegal which is annoying.

I can't figure out how to do this with the Quotes API either. Refinement doesn't take a symbol so there is nothing to give to This.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions