Skip to content

Regression from March: Incorrect quoted.Type instance required in quotes subclassing an inner trait #17293

Closed
@neko-kai

Description

@neko-kai

Compiler version

3.3.1-RC1-bin-20230407-bcaa1ca-NIGHTLY and 3.3.1-RC1-bin-20230416-2f4cc4c-NIGHTLY

Minimized code

https://scastie.scala-lang.org/E3WYTt73Ryqc3pzCY1xapQ

import scala.quoted.{Expr, Quotes, Type, quotes}

trait OuterTrait {
  trait X
}

def exampleMacro[T <: OuterTrait: Type](expr: Expr[T])(using Quotes): Expr[OuterTrait#X] = {
  '{
    val prefix: T = ${ expr }
    new prefix.X {}
  }
}

Output

[error] -- Error: exampleMacro.scala:12:19
[error] 12 |    new prefix.X {}
[error]    |                   ^
[error]    |Reference to T#X within quotes requires a given scala.quoted.Type[T#X] in scope.

Expectation

Expected to compile as on commit 7262437 (version 3.3.1-RC1-bin-20230331-7262437-NIGHTLY, https://scastie.scala-lang.org/y7mN6SA1REKvXAqIIEAbqw).

Constraint Type[T#X] is unwriteable since it's an abstract type projection and cannot be satisfied.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions