Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Scala 2.10.0-M3
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      I cannot call generic apply call for new instances. But according to spec it must run well:

      class A {
        def apply[T](x: Int) = 1
      }
      
      (new A)[Int](1)
      

        Activity

        Hide
        Ingo Maier added a comment -

        In the future, please be more verbose about where you think the problem is exactly.

        Show
        Ingo Maier added a comment - In the future, please be more verbose about where you think the problem is exactly.
        Hide
        Paul Phillips added a comment -

        Presumably he thinks "(new A)[Int](1)" ought to say "res0: 1" instead of "<console>:1: error: ';' expected but '[' found."

        I agree in principle, and trunk already has several fixes allowing for apply methods to be called more flexibly, for instance this doesn't work in 2.7.3:

        scala> def foo(x: Int, y: Int) = x + y
        foo: (Int,Int)Int
        
        scala> (foo _)(5, 10)
        res0: Int = 15
        

        However this would represent a rather more significant change to the parser and I'm not really convinced it's a good idea given that it works if you let the type argument be inferred or if you call apply explicitly.

        scala> (new A)(1)
        res0: Int = 1
        
        scala> (new A).apply[Int](1)
        res1: Int = 1
        

        So I recategorized to enhancement.

        Show
        Paul Phillips added a comment - Presumably he thinks "(new A) [Int] (1)" ought to say "res0: 1" instead of "<console>:1: error: ';' expected but '[' found." I agree in principle, and trunk already has several fixes allowing for apply methods to be called more flexibly, for instance this doesn't work in 2.7.3: scala> def foo(x: Int, y: Int) = x + y foo: (Int,Int)Int scala> (foo _)(5, 10) res0: Int = 15 However this would represent a rather more significant change to the parser and I'm not really convinced it's a good idea given that it works if you let the type argument be inferred or if you call apply explicitly. scala> (new A)(1) res0: Int = 1 scala> (new A).apply[Int](1) res1: Int = 1 So I recategorized to enhancement.
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/477
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/commit/74be1369a594370e41dce499f23875ebd3e1b088

          People

          • Assignee:
            Martin Odersky
            Reporter:
            Alexander
            TracCC:
            Paul Phillips
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development