Open scabug opened 10 years ago
Imported From: https://issues.scala-lang.org/browse/SI-8992?orig=1 Reporter: @TiarkRompf Affected Versions: 2.11.2, 2.11.4
@xeno-by said: Hi, sorry didn't have time to look into this issue yet. How urgent is is for you?
@TiarkRompf said: Hi Eugene, currently this is a blocker for switching Delite to 2.11, so it would be nice to have a fix soonish. Since it seems to be a regression from 2.10 I was hoping this would be an easy one. Thanks!
@TiarkRompf said: If this could be fixed for 2.11.5, that would be great.
@xeno-by said (edited on Dec 6, 2014 10:40:20 PM UTC): The exponential cascade of implicit searches is the result of the change introduced in #3346.
When trying to resolve the overload for infix_abs(Math,_arg0)
, scalac tries to see whether def infix_abs[T:Arith](self: Rep[DenseVector[T]]): Rep[DenseVector[T]]
is applicable. It sees an implicit conversion from Tuple2 to Rep[DenseVector], and goes for it, packing Math and _arg0 into a tuple and then trying to typecheck the application of the said conversion (implicit def tupleToDense2[A:Arith,B](t: Tuple2[A,B]): Rep[DenseVector[A]]
) to (Math,_arg0)
.
What happens then is caused by the aforementioned bugfix. In 2.10.x, tupleToDense2 implicit candidate is triaged without resolving implicit arguments (the A: Arith context bound), whereas in 2.11.x typedImplicit1 is changed to resolve implicit arguments during triaging. Therefore in 2.11.x, the mere fact of considering tupleToDense2 as an implicit conversion, will launch an implicit search for Arith[A].
Now, a bunch of implicit methods provide Arith[Something], and, what's worse, triaging those implicit methods will cause other Something: Arith
context bounds to be resolved, launching more and more implicit searches for Arith[Something]
. That quickly gets out of hand.
Do you think it would be possible for you to restructure the code so that this avalanche of implicit lookups doesn't get spawned?
@TiarkRompf said: Thanks for the analysis!
This particular case with Math
is easy to work around but unfortunately this bug tends to show up unexpectedly, and in very different places. So difficult to restructure globally. It's also very hard to debug for non-compiler experts because scalac just hangs without any error message.
Scala 2.11 can't type this over night, but 2.10 runs quickly.