Skip to content

Cyclic reference with transparent inline, summon and given #17430

Open
@steinybot

Description

@steinybot

Compiler version

3.3.0-RC5

Minimized code

import scala.quoted.*

trait Thing[A]

transparent inline def repro[T] =
  ${ reproImpl[T] }

private def reproImpl[T: Type](using Quotes): Expr[Any] =
  Expr.summon[Thing[T]]
  '{null}
trait Foo

object Bar:
  val instance = repro[Foo]
  given instance.type = instance

Output

[error] -- [E046] Cyclic Error: /Users/jason/src/bug-reports/app/src/main/scala/Main.scala:56:8
[error] 56 |  given instance.type = instance
[error]    |        ^
[error]    |        Cyclic reference involving val instance
[error]    |----------------------------------------------------------------------------
[error]    | Explanation (enabled by `-explain`)
[error]    |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[error]    | value instance is declared as part of a cycle which makes it impossible for the
[error]    | compiler to decide upon instance's type.
[error]    | To avoid this error, try giving instance an explicit type.
[error]     ----------------------------------------------------------------------------

Expectation

I'd expect this to compile.

This is as minimal as I could get it, the real use case would obviously be more useful than this. In this particular reproduction it needed instance.type to be involved in some given and reproImpl to summon some unrelated given (I was originally using a Mirror but that is not required).

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