2017-11-14 13 views
0
このREPLスニペットに示されているように、次の暗黙値の解像度の問題は、今日の私にまで潜入

:インポートされた暗黙の値a影が、暗黙の解像度の故障

scala> case class X(s:String,implicit val a:Int) 
defined class X 

scala> class C(i:X) { 
    def a:Int = 1 
    def b:Int = { 
    import i.a 
    implicitly[Int] 
    } 
} 
<console>:17: error: could not find implicit value for parameter e: Int 
      implicitly[Int] 
                    ^

scala> class C(i:X) { 
    def a:Int = 1 
    def b:Int = { 
    import i.{a=>c} 
    implicitly[Int] 
    } 
} 
defined class C 

同じ名前のメソッドは、暗黙の解決が失敗する理由がないはずです。 名前を変更する必要がある理由を誰かが明らかにすることができますか?

答えて

1

私はそれがバグだとはかなり確信していますが、私はすぐに既存のバグレポートを特定できませんでした。それはdottyの名前の変更なしで動作します。

+0

Dottyで試してみることをお勧めします。ありがとう!これがDottyと期待どおりに動作していることを聞いてうれしいです。 –