Why does this explicit call of a Scala method allow it to be implicitly resolved?

后端 未结 3 517
闹比i
闹比i 2020-12-03 07:45

Why does this code fail to compile, but compiles successfully when I uncomment the indicated line? (I\'m using Scala 2.8 nightly). It seems that explicitly calling str

3条回答
  •  醉话见心
    2020-12-03 08:04

    If you put object Implicits first, it works. This looks like a bug to me in the logic for making multiple compiler passes; it assumes it can get away without really knowing about string2Wrapper when compiling bar. My guess is that if you use it, it knows it can't get away with not knowing what string2Wrapper really is, actually compiles Implicits, and then realizes that ==> is implicitly defined on String.

    Edit: Based on what Retronym posted, maybe it's a "feature" not a bug. Still seems screwy to me!

提交回复
热议问题