Skip to content

Wrong staging level for quoted structural/refinement type with type member #22648

Open
@TomasMikula

Description

@TomasMikula

Compiler version

3.6.3

Minimized code

import scala.quoted.*

transparent inline def foo =
  ${ fooImpl }

def fooImpl(using Quotes): Expr[Any] =
  '{
    new AnyRef {
      type T = Unit
      def make: T = ()
      def take(t: T): Unit = ()
    }: {
      type T
      def make: T
      def take(t: T): Unit
    }
  }

Output

% ~/Downloads/scala3-3.6.3-aarch64-apple-darwin/bin/scalac test.scala
-- Error: test.scala:14:16 -----------------------------------------------------
14 |      def make: T
   |                ^
   |                access to trait <refinement> from wrong staging level:
   |                 - the definition is at level 0,
   |                 - but the access is at level 1
-- Error: test.scala:15:22 -----------------------------------------------------
15 |      def take(t: T): Unit
   |                      ^^^^
   |                  access to trait <refinement> from wrong staging level:
   |                   - the definition is at level 0,
   |                   - but the access is at level 1
-- Error: test.scala:15:18 -----------------------------------------------------
15 |      def take(t: T): Unit
   |                  ^
   |                  access to trait <refinement> from wrong staging level:
   |                   - the definition is at level 0,
   |                   - but the access is at level 1
3 errors found

Expectation

Should compile, as there is no stage mismatch.

A workaround would be appreciated.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions