Skip to content

Byname implicits: could not find proxy for lazy var #3585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
OlivierBlanvillain opened this issue Nov 29, 2017 · 1 comment
Closed

Byname implicits: could not find proxy for lazy var #3585

OlivierBlanvillain opened this issue Nov 29, 2017 · 1 comment

Comments

@OlivierBlanvillain
Copy link
Contributor

OlivierBlanvillain commented Nov 29, 2017

This is test case taken scala/scala#6050:

trait Foo[T]

object Foo {
  implicit def pair[T, U]
    (implicit
      fooT: => Foo[(T, U)],
      fooU: => Foo[(U, T)]
    ): Foo[(T, U)] = ???

  implicit def int: Foo[Int] = ???
  implicit def string: Foo[String] = ???
}

object Test {
  implicitly[Foo[(Int, String)]]
}
Exception in thread "main" java.lang.IllegalArgumentException: Could not find proxy for lazy var $_lazy_implicit_$3$lzy1: dotty.run
time.LazyRef in List(val $_lazy_implicit_$3$lzy1, val <local Test$>, module class Test$, module class <empty>, module class <root>), encl = package <empty>, owners = package <empty>, package <root>; enclosures = package <empty>, package <root>
        at dotty.tools.dotc.transform.LambdaLift$Lifter.searchIn$1(LambdaLift.scala:374)
        at dotty.tools.dotc.transform.LambdaLift$Lifter.proxy(LambdaLift.scala:387)
        at dotty.tools.dotc.transform.LambdaLift$Lifter.proxyRef(LambdaLift.scala:405)
        at dotty.tools.dotc.transform.LambdaLift$Lifter.$anonfun$addFreeArgs$1(LambdaLift.scala:411)
        at scala.collection.immutable.List.map(List.scala:283)
        at dotty.tools.dotc.transform.LambdaLift$Lifter.addFreeArgs(LambdaLift.scala:411)
        at dotty.tools.dotc.transform.LambdaLift.transformApply(LambdaLift.scala:532)
        at dotty.tools.dotc.transform.LambdaLift.transformApply(LambdaLift.scala:486)
@OlivierBlanvillain
Copy link
Contributor Author

Here is the code generated by typer:

object Test {
  implicitly[Foo[Tuple2[Int, String]]](
    Foo.pair[Int, String](
      {
        lazy val $_lazy_implicit_$1: Foo[(Int, String)] =
          Foo.pair[Int, String]($_lazy_implicit_$1,
            {
              lazy val $_lazy_implicit_$3: Foo[(String, Int)] =
                Foo.pair[String, Int]($_lazy_implicit_$3, $_lazy_implicit_$1)
              $_lazy_implicit_$3
            }
          )
        $_lazy_implicit_$1
      }
    ,
      {
        lazy val $_lazy_implicit_$6: Foo[(String, Int)] =
          Foo.pair[String, Int]($_lazy_implicit_$6,
            {
              lazy val $_lazy_implicit_$8: Foo[(Int, String)] =
                Foo.pair[Int, String]($_lazy_implicit_$8, $_lazy_implicit_$6)
              $_lazy_implicit_$8
            }
          )
        $_lazy_implicit_$6
      }
    )
  )
}

Compiling with -Ycheck leads to a different error:

Exception in thread "main" java.lang.AssertionError: assertion failed: bad owner; lazy value $_lazy_implicit_$3 has owner value <lo
cal Test$>, expected was lazy value $_lazy_implicit_$1      

@smarter smarter closed this as completed in 3ec0b67 Jan 4, 2018
smarter added a commit that referenced this issue Jan 4, 2018
Fix #3585: Add missing changeOwner when building lazy implicits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant