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
SI-10081 Avoid diverging implicit scope search #5742
Conversation
Storing empty infos into the infoMap (thus avoiding recomputation) prevents the endless recursion. This is an alternative to scala#5734 that avoids the expensive annotation removal and the regression in pos/t1203a.scala.
Rebased on top of 2.12.x head in order to build a version that also includes #5708, so I can use it in collection-strawman. |
I've started to take a look at this. One concrete suggestion is to filter out the commit 27fb723071fe7b1263df00fea67c1db8eaa2e9d9
Author: Jason Zaugg <jzaugg@gmail.com>
Date: Sat Mar 4 13:38:02 2017 +1000
Remove empty entries (cycle markers) from companionImplicitMap after computation
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 5b89faa3e8..4a39752a91 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -1130,7 +1130,7 @@ trait Implicits {
case None =>
val start = if (Statistics.canEnable) Statistics.startTimer(subtypeETNanos) else null
// val implicitInfoss = companionImplicits(pt)
- val implicitInfoss1 = companionImplicitMap(pt).valuesIterator.toList
+ val implicitInfoss1 = companionImplicitMap(pt).valuesIterator.filterNot(_.isEmpty).toList
// val is1 = implicitInfoss.flatten.toSet
// val is2 = implicitInfoss1.flatten.toSet
// for (i <- is1) I'm still trying to reason about whether or not this could change the result of this method for some type that currently does not diverge. Here's what I've tried so far. I was worried this would
This shows that your change does not prevent recursion into the type arguments ( |
That was my concern as well. I convinced myself that the change would be OK because this shouldn't depend on coming up with empty or non-empty infos for the symbol. |
I took this chance to get a little more familiar with the implementation of implicit search, looks good from what I can see. I agree with Jason that filtering out empty infos would be cleaner. |
Replaced by #5951 |
Storing empty infos into the infoMap (thus avoiding recomputation)
prevents the endless recursion.
This is an alternative to #5734 that
avoids the expensive annotation removal and the regression in
pos/t1203a.scala.