From dbce4d9c5c11fbe68dbbae0d613a177f64ea171f Mon Sep 17 00:00:00 2001 From: Georgi Krastev Date: Tue, 4 May 2021 10:34:45 +0200 Subject: [PATCH] Revert "Fix Lazy implicit resolution with type parameters" --- .../scala_2.13-/shapeless/LazyMacros.scala | 16 +++++-------- core/src/test/scala/shapeless/lazy.scala | 24 ------------------- 2 files changed, 6 insertions(+), 34 deletions(-) diff --git a/core/src/main/scala_2.13-/shapeless/LazyMacros.scala b/core/src/main/scala_2.13-/shapeless/LazyMacros.scala index d45e4031a..aa23abcc8 100644 --- a/core/src/main/scala_2.13-/shapeless/LazyMacros.scala +++ b/core/src/main/scala_2.13-/shapeless/LazyMacros.scala @@ -128,21 +128,17 @@ class LazyMacros(val c: whitebox.Context) extends CaseClassMacros with OpenImpli private var current = Option.empty[State] - private def typeParamsToWildcards(tpe: Type): Type = tpe.map { t => - val sym = t.typeSymbol - if (sym.isParameter) boundedWildcardType(sym.info.asInstanceOf[TypeBounds]) else t - } - def resolveInstance(state: State)(tpe: Type): Option[(State, Tree)] = { val former = State.current State.current = Some(state) val (state0, tree) = try { - val tree = c.inferImplicitValue(tpe, silent = true) orElse c.inferImplicitValue(typeParamsToWildcards(tpe), silent = true) - if (tree.isEmpty) { - tpe.typeSymbol.annotations - .find(_.tree.tpe =:= typeOf[_root_.scala.annotation.implicitNotFound]) - .foreach(_ => setAnnotation(implicitNotFoundMessage(c)(tpe))) + val tree = c.inferImplicitValue(tpe, silent = true) + if(tree.isEmpty) { + tpe.typeSymbol.annotations. + find(_.tree.tpe =:= typeOf[_root_.scala.annotation.implicitNotFound]).foreach { _ => + setAnnotation(implicitNotFoundMessage(c)(tpe)) + } } (State.current.get, tree) } finally { diff --git a/core/src/test/scala/shapeless/lazy.scala b/core/src/test/scala/shapeless/lazy.scala index cf3c19b2a..fa6eedbc5 100644 --- a/core/src/test/scala/shapeless/lazy.scala +++ b/core/src/test/scala/shapeless/lazy.scala @@ -336,27 +336,3 @@ class LazyStrictTests { implicitly[Strict[Readable[Id]]] } } - -object TestLazyWithTypeParametersAndBounds { - trait Foo - case class BarFoo(i: Int) extends Foo - - trait Fooer[Tpe, FooTpe] { - def makeFoo(obj: Tpe): FooTpe - } - - object Fooer { - implicit val barFooer: Fooer[Int, BarFoo] = null - } - - class Finder[Tpe] { - def find[F <: Foo](implicit fooer: Fooer[Tpe, F]) = fooer - def findLazy[F <: Foo](implicit fooer: Lazy[Fooer[Tpe, F]]) = fooer - def findNoBounds[F](implicit fooer: Lazy[Fooer[Tpe, F]]) = fooer - } - - val intFinder = new Finder[Int] - intFinder.find - intFinder.findLazy - intFinder.findNoBounds -}