Skip to content

Lazy does not instantiate type parameters #828

@Katrix

Description

@Katrix

From my testing, Lazy does not work if more than a single type parameter is involved. I have only tested two myself.

import shapeless._

object LazyTest {

  new FindSimpleFooer[Int].find
  new FindLazySimpleFooer[Int].find
  new FindFooer[Int].find
  new FindLazyFooer[Int].find
}

class FindSimpleFooer[Tpe] {
  def find(implicit fooer: SimpleFooer[Tpe]) = fooer
}

class FindLazySimpleFooer[Tpe] {
  def find(implicit fooer: Lazy[SimpleFooer[Tpe]]) = fooer
}

class FindFooer[Tpe] {
  def find[F <: Foo](implicit fooer: Fooer[Tpe, F]) = fooer
}

class FindLazyFooer[Tpe] {
  def find[F <: Foo](implicit fooer: Lazy[Fooer[Tpe, F]]) = fooer
}

trait Foo
case class BarFoo(i: Int) extends Foo

trait SimpleFooer[Tpe] {
  def makeFoo(obj: Tpe): Foo
}
object SimpleFooer {
  implicit val barFooer: SimpleFooer[Int] = (obj: Int) => BarFoo(obj)
}

trait Fooer[Tpe, FooTpe <: Foo] {
  def makeFoo(obj: Tpe): FooTpe
}
object Fooer {
  implicit val barFooer: Fooer[Int, BarFoo] = (obj: Int) => BarFoo(obj)
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions