You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class C
trait A {
implicit val cOne: C
}
abstract class B(implicit cTwo: C) extends A {
def foo = implicitly[C]
}
Without the plugin, the compiler picks cTwo. It's more specific than cOne because it's defined in a subclass.
When enabling the plugin the two implicits become ambiguous. The reason is that cOne is a reference to the getter function, which has a method type and an effect annotation. cTwo does not have a getter, so it's a direct reference to the field, and has no effect annotation:
[search] scala.this.Predef.implicitly[C] with pt=C in class B, eligible:
cTwo: C
cOne: => C @scala.annotation.effects.noIo
Implicit search will verify if cTwo improves over cOne, which is no longer the case. The problem is that C is not a subtype of C @noIo due to the annotation checker (which picks the top effect @io as default if there are no effect annotations).
Workaround: make cTwo a val parameter, then the implicit search will use the getter symbol which has a method type, and an effect annotation.
Fix: One way is to have a analyzer plugin hook in Implicits.improves, which invokes isStrictlyMoreSpecific. Then the plugin could remove the effect annotations from the types.
Without the plugin, the compiler picks
cTwo
. It's more specific thancOne
because it's defined in a subclass.When enabling the plugin the two implicits become ambiguous. The reason is that
cOne
is a reference to the getter function, which has a method type and an effect annotation.cTwo
does not have a getter, so it's a direct reference to the field, and has no effect annotation:Implicit search will verify if
cTwo
improves overcOne
, which is no longer the case. The problem is thatC
is not a subtype ofC @noIo
due to the annotation checker (which picks the top effect@io
as default if there are no effect annotations).Workaround: make
cTwo
aval
parameter, then the implicit search will use the getter symbol which has a method type, and an effect annotation.Fix: One way is to have a analyzer plugin hook in
Implicits.improves
, which invokesisStrictlyMoreSpecific
. Then the plugin could remove the effect annotations from the types.Pending test in https://github.com/lrytz/efftp/blob/master/tests/src/test/resources/scala/tools/nsc/effects/io/ClassesSuite-files/implicitsPending.scala
The text was updated successfully, but these errors were encountered: