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

Can't summon an ArrayTag for a type alias of an Array type

    Details

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

      Description

       ~/code/scala ./build/quick/bin/scala Welcome to Scala version 2.10.0-20120505-103711-7cac6334d4 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_29).
      
      scala> arrayTag[Array[Int]]
      res4: ArrayTag[Array[Int]] = ClassTag[class [I]
      
      scala> type AI=Array[Int]; arrayTag[AI]
      <console>:9: error: No ArrayTag available for AI
              arrayTag[AI]
                      ^
      

      Original report:

      http://stackoverflow.com/questions/10488007/toarray-in-scala-2-10-milestone

      By contrast, this works:

      
      scala> type I=Int; arrayTag[I]
      defined type alias I
      res6: ArrayTag[I] = ClassTag[int]
      

        Activity

        Hide
        Eugene Burmako added a comment -

        Hmm wait

        Show
        Eugene Burmako added a comment - Hmm wait
        Hide
        Eugene Burmako added a comment -

        Yeah, I see the point:

        scala> import scala.reflect.mirror._
        import scala.reflect.mirror._
        
        scala> type AI = Array[Int]
        defined type alias AI
        
        scala> reify{ val x: AI = null }
        res0: reflect.mirror.Expr[Unit] =
        Expr[Unit]({
          val x: Array = null;
          ()
        })
        
        scala> reify { val x: Array[Int] = null }
        res1: reflect.mirror.Expr[Unit] =
        Expr[Unit]({
          val x: Array[Int] = null;
          ()
        })
        
        Show
        Eugene Burmako added a comment - Yeah, I see the point: scala> import scala.reflect.mirror._ import scala.reflect.mirror._ scala> type AI = Array[Int] defined type alias AI scala> reify{ val x: AI = null } res0: reflect.mirror.Expr[Unit] = Expr[Unit]({ val x: Array = null; () }) scala> reify { val x: Array[Int] = null } res1: reflect.mirror.Expr[Unit] = Expr[Unit]({ val x: Array[Int] = null; () })
        Show
        Eugene Burmako added a comment - https://issues.scala-lang.org/browse/SI-5771
        Hide
        Paul Phillips added a comment -

        "In a lot of places in the compiler, aliases are silently converted to their underlying types."

        Types are converted to underlying types. That doesn't mean you can do it with bare symbols.

        Show
        Paul Phillips added a comment - "In a lot of places in the compiler, aliases are silently converted to their underlying types." Types are converted to underlying types . That doesn't mean you can do it with bare symbols.
        Hide
        Paul Phillips added a comment -

        When exactly to dealias is very tricky stuff; too eagerly will be wrong, too lazily will be wrong.

        Show
        Paul Phillips added a comment - When exactly to dealias is very tricky stuff; too eagerly will be wrong, too lazily will be wrong.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Jason Zaugg
          • Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development