What is the concept of “weak conformance” in Scala?

后端 未结 3 1502
伪装坚强ぢ
伪装坚强ぢ 2020-12-24 12:49

I just recently encountered the term \"Weak Conformance\" (in Stack Overflow user retronym\'s answer to How to set up implicit conversion to allow arithmetic between num

3条回答
  •  天涯浪人
    2020-12-24 13:24

    According to Scala lang spec 2.8:
    http://www.scala-lang.org/archives/downloads/distrib/files/nightly/pdfs/ScalaReference.pdf

    3.5.3 Weak Conformance
    In some situations Scala uses a more genral conformance relation. A type S weakly conforms to a type T , written S <:w T , if S <: T or both S and T are primitive number types and S precedes T in the following ordering.
    Byte <:w Short
    Byte <:w Character
    Short <:w Int
    Int <:w Long
    Long <:w Float
    Float <:w Double
    A weak least upper bound is a least upper bound with respect to weak conformance.

提交回复
热议问题