Details

    • Type: Bug
    • Status: CLOSED
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: Scala 2.10.0-M3
    • Fix Version/s: None
    • Component/s: Reflection

      Description

      scala> def foo[T: ClassTag] = println(classOf[T])
      <console>:7: error: class type required but T found
             def foo[T: ClassTag] = println(classOf[T])
                                                    ^
      

        Attachments

          Activity

          Hide
          moors Adriaan Moors added a comment -

          classOf[C] should be a constant, basically have the same meaning as C.class in Java

          Show
          moors Adriaan Moors added a comment - classOf [C] should be a constant, basically have the same meaning as C.class in Java
          Hide
          soc Simon Ochsenreither added a comment - - edited

          I'm not sure whether this can be called a bug or a missing feature, but I'd like to get this fixed in the long-term.

          If you provide a tag for new Array[T], it works. I think it is reasonable to expect the same for classOf[T].

          Maybe a future me is experienced enough to tackle this.

          Mailing list: https://groups.google.com/d/topic/scala-internals/-IFwlFk6Btc/discussion

          Show
          soc Simon Ochsenreither added a comment - - edited I'm not sure whether this can be called a bug or a missing feature, but I'd like to get this fixed in the long-term. If you provide a tag for new Array[T] , it works. I think it is reasonable to expect the same for classOf[T] . Maybe a future me is experienced enough to tackle this. Mailing list: https://groups.google.com/d/topic/scala-internals/-IFwlFk6Btc/discussion
          Hide
          retronym Jason Zaugg added a comment -

          That thread doesn't convince me that this should have been reopened. `classOf` has a very specific meaning in Scala as is does in Java, it is our class literal.

          Show
          retronym Jason Zaugg added a comment - That thread doesn't convince me that this should have been reopened. `classOf` has a very specific meaning in Scala as is does in Java, it is our class literal .
          Hide
          soc Simon Ochsenreither added a comment -

          Not trying to be nitpicky, but this reasoning is inconsistent with other things which also have a special meaning in Scala/Java. By that logic, we would need to throw out new Array[T], too, regardless of ClassTags in scope.

          You can just assign it to me, if I have time I'll look into it again.

          Show
          soc Simon Ochsenreither added a comment - Not trying to be nitpicky, but this reasoning is inconsistent with other things which also have a special meaning in Scala/Java. By that logic, we would need to throw out new Array [T] , too, regardless of ClassTags in scope. You can just assign it to me, if I have time I'll look into it again.

            People

            • Assignee:
              soc Simon Ochsenreither
              Reporter:
              burmako Eugene Burmako
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: