Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major 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])
                                                    ^
      

        Activity

        Hide
        Adriaan Moors added a comment -

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

        Show
        Adriaan Moors added a comment - classOf [C] should be a constant, basically have the same meaning as C.class in Java
        Hide
        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
        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
        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
        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
        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
        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:
            Simon Ochsenreither
            Reporter:
            Eugene Burmako
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development