Skip to content

Cyclic reference involving implicit value #4709

Closed
@allanrenucci

Description

@allanrenucci
class Context
class ContextBase { def settings = 1 }

class Test {
  implicit def toBase(ctx: Context): ContextBase = ???

  def test(ctx0: Context) = {
    implicit val ctx = { ctx0.settings; ??? }
  }
}

This code snippet above fails to compile:

-- [E047] Syntax Error: tests/allan/Test.scala:8:25 ----------------------------
8 |    implicit val ctx = { ctx0.settings; ??? }
  |                         ^
  |                         cyclic reference involving implicit value ctx

Adding an explicit type annotation to val ctx solves the issue

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions