Skip to content
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

Suppression of the "first and only divergence error" regressed #8460

Closed
scabug opened this issue Mar 28, 2014 · 4 comments
Closed

Suppression of the "first and only divergence error" regressed #8460

scabug opened this issue Mar 28, 2014 · 4 comments

Comments

@scabug
Copy link

scabug commented Mar 28, 2014

Spotted this one while building scalanlp/breeze is a final round of regression hunting ahead of the 2.11 release.

object tan extends UFunc {
  implicit def ImplDouble: Impl[Double, Double] = ???
}

trait UFunc {
  trait TC[+A]
  type Impl[V, VR] = UFunc.UImpl[this.type, V, VR]
}

object UFunc {
  class UImpl[A, B, C]
  implicit def implicitDoubleUTag[Tag, V, VR](implicit conv: V => Double, impl: UImpl[Tag, Double, VR]): UImpl[Tag, V, VR] = ???
}

object Test {
  implicitly[tan.Impl[Double, Double]]
  // we should discard the one and only divergent implicit (`implicitDoubleUTag`)
  // This is done under `scalac-hash v2.10.4 test.scala`, but not under
  // `scalac-hash v2.10.4 -Xdivergence211 test.scala`
  //
  // This seems to be because the companion implicits contain redundant entries
  //
  //  companionImplicitMap tan.Impl[Double,Double] {
  //    object UFunc  implicitDoubleUTag: [Tag, V, VR](implicit conv: V => Double, implicit impl: UFunc.UImpl[Tag,Double,VR])UFunc.UImpl[Tag,V,VR]
  //    object tan    ImplDouble: => tan.Impl[Double,Double]
  //    trait UFunc   implicitDoubleUTag: [Tag, V, VR](implicit conv: V => Double, implicit impl: UFunc.UImpl[Tag,Double,VR])UFunc.UImpl[Tag,V,VR]
  //  }
  //
}

See #7291 / scala/scala@accaa314

As best as I can tell, that uncovered a latent bug with companionImplicitMap, which ends up with redundant entries if the parts of the type we're dealing with contains both a class symbol and its companion module symbol.

@scabug
Copy link
Author

scabug commented Mar 28, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8460?orig=1
Reporter: @retronym
Affected Versions: 2.11.0-RC3

@scabug
Copy link
Author

scabug commented Mar 30, 2014

@scabug
Copy link
Author

scabug commented Mar 31, 2014

@retronym said:
scala/scala#3667

@scabug scabug closed this as completed Apr 2, 2014
@scabug
Copy link
Author

scabug commented Apr 4, 2014

@retronym said:
Turns out that the final version of this patch actually does not restore 2.10.x behaviour for the examples in shapeless 1.2.4. An earlier version of the patch did, but only by inadvertantly disabling divergence checking altogether.

I have extracted a test case from DeepSearch in shapeless, and judge that the new behaviour is correct. More details in this branch:

https://github.com/retronym/scala/tree/ticket/8460-3

I have also included a reworked version that uses implicit prioritization to shephard the search away from divergence.

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

2 participants