Scala Programming Language
  1. Scala Programming Language
  2. SI-7228

weak subtyping does not handle types properly

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.11.0-M2
    • Component/s: None

      Description

      More of the usual with dealiasing, widening, etc, the problem neatly summarized here:

      scala> isWeakSubType(typeOf[Int], typeOf[Double])
      res0: Boolean = true
      
      scala> isWeakSubType(typeOf[Int].narrow, typeOf[Double])
      res1: Boolean = false
      

      I already fixed it, opening to have a reference. Test case:

      object AdaptWithWeaklyConformantType {
        implicit class D(d: Double) { def double = d*2 }
      
        val x1: Int = 1
        var x2: Int = 2
        val x3 = 3
        var x4 = 4
        final val x5 = 5
        final var x6 = 6
      
        def f1 = x1.double
        def f2 = x2.double
        def f3 = x3.double
        def f4 = x4.double
        def f5 = x5.double
        def f6 = x6.double
      }
      

        Activity

        Show
        Paul Phillips added a comment - https://github.com/paulp/scala/commit/ba159c1a2405d33186497163d61497bbbc563ea2
        Hide
        Jason Zaugg added a comment -

        Closing as I don't see residuals other than the commit message "probably not the ideal fix"

        Show
        Jason Zaugg added a comment - Closing as I don't see residuals other than the commit message "probably not the ideal fix"

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development