Skip to content

Cyclic reference error when refering to an implicit parameter from another implicit parameter's type #18258

Open
@Sporarum

Description

@Sporarum

Compiler version

3.3.0 / 3.3.1-RC1

Minimized code & Ouptut

class myAnnot(s: String) extends scala.annotation.Annotation

trait Showable[A]

def show[A : Showable](x: A) = x.toString


def f1(using Showable[Int])(otherParam: Int @myAnnot(show[Int](4))) = ???

def f2(using Showable[Int])(using otherParam: Int @myAnnot(show[Int](4))) = ??? // error: Cyclic reference involving implicit parameter otherParam

Expectation

Either both methods should compile, or neither of them should

As I don't see any cyclic reference with otherParam, I assume the correct fix is to make f2 succeed

This also has implications for the following:

def f3[A](x: A)(using shower: Showable[A], otherParam: Int @myAnnot(show[A](x))) = ??? // error: Cyclic reference involving implicit parameter otherParam

def f4[A : Showable](x: A)(using otherParam: Int @myAnnot(show[A](x))) = ??? // error: Cyclic reference involving implicit parameter otherParam

(f4 surprisingly desugars to f3: https://docs.scala-lang.org/scala3/reference/contextual/context-bounds.html#)

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