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

GenICode#adapt has several questionable cases

    Details

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

      Description

      In GenICode the definition of adapt has several questionable cases that do not seem reachable. Need to investigate and either comment why they are necessary and add tests, or remove them if they are dead code.

      This defines conforms as either a subtype relation or the case when from is null and to is nothing. When would we have a null when we expect nothing?

            val conforms = (from <:< to) || (from == NullReference && to == NothingReference)
      

      This is saying if we have a throwable and a non-throwable is expected then we should emit a cast? Why would we get here?

              case ThrowableReference if !(ThrowableClass.tpe <:< to.toType) => ctx.bb.emit(CHECK_CAST(to)) // downcast throwables
      

      And why do we need this special case? It's saying that from conformed with to, but that to is a LONG and from was int sized but that shouldn't happen, because conforms is defined as the subtype relation <:< and INT isn't a subtype of LONG however, removing it breaks test/files/run/t107.scala

              case _                                                         =>
                // widen subrange types
                if (from.isIntSizedType && to == LONG)
                  coerce(INT, LONG)
      

        Issue Links

          Activity

          Hide
          James Iry added a comment -

          I think the first two are legacies from early iterations on bolting "Null" and "Nothing" into the JVM. If I whack them the don't break any tests.

          The last one does break a test if removed. So I'll look into why we need it.

          Show
          James Iry added a comment - I think the first two are legacies from early iterations on bolting "Null" and "Nothing" into the JVM. If I whack them the don't break any tests. The last one does break a test if removed. So I'll look into why we need it.
          Hide
          Grzegorz Kossakowski added a comment -

          Since https://github.com/scala/scala/pull/2177 is merged, should we close this?

          Show
          Grzegorz Kossakowski added a comment - Since https://github.com/scala/scala/pull/2177 is merged, should we close this?
          Hide
          Grzegorz Kossakowski added a comment -

          James, can we close this ticket?

          Show
          Grzegorz Kossakowski added a comment - James, can we close this ticket?

            People

            • Assignee:
              James Iry
              Reporter:
              James Iry
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development