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

implicit ClassTag for value class alias is incorrect

    Details

      Description

      This can quite easily lead to ArrayStoreExceptions, as I'm sure you can imagine:

      scala> class Foo(val n: Int) extends AnyVal
      defined class Foo
      
      scala> type F = Foo
      defined type alias F
      
      scala> implicitly[ClassTag[Foo]]
      res0: scala.reflect.ClassTag[Foo] = Foo
      
      scala> implicitly[ClassTag[F]]
      res1: scala.reflect.ClassTag[F] = java.lang.Integer
      

        Issue Links

          Activity

          Hide
          James Iry added a comment -

          2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

          Show
          James Iry added a comment - 2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.
          Hide
          James Iry added a comment -

          2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.

          Show
          James Iry added a comment - 2.10.2 is about to be cut. Kicking down the road and un-assigning to foster work stealing.
          Hide
          Jason Zaugg added a comment -

          Could you take a look at this one please, Denys?

          Show
          Jason Zaugg added a comment - Could you take a look at this one please, Denys?
          Hide
          Denys Shabalin added a comment -

          Sure, I'll look into it.

          Show
          Denys Shabalin added a comment - Sure, I'll look into it.
          Hide
          Denys Shabalin added a comment -

          This bug might have been accidentally fixed along the way. Neither 2.10.x nor master exhibit given problem:

          scala> import scala.reflect.ClassTag
          import scala.reflect.ClassTag
          
          scala> class Foo(val n: Int) extends AnyVal
          defined class Foo
          
          scala> type F = Foo
          defined type alias F
          
          scala> println(implicitly[ClassTag[Foo]])
          $line4.$read$$iw$$iw$Foo
          
          scala> println(implicitly[ClassTag[F]])
          $line4.$read$$iw$$iw$Foo
          

          I'll submit a test case anyway.

          Show
          Denys Shabalin added a comment - This bug might have been accidentally fixed along the way. Neither 2.10.x nor master exhibit given problem: scala> import scala.reflect.ClassTag import scala.reflect.ClassTag scala> class Foo(val n: Int) extends AnyVal defined class Foo scala> type F = Foo defined type alias F scala> println(implicitly[ClassTag[Foo]]) $line4.$read$$iw$$iw$Foo scala> println(implicitly[ClassTag[F]]) $line4.$read$$iw$$iw$Foo I'll submit a test case anyway.
          Show
          Denys Shabalin added a comment - https://github.com/scala/scala/pull/3174

            People

            • Assignee:
              Eugene Burmako
              Reporter:
              Jeff Olson
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development