You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you specialize one type parameter of a method, but not all of them, and then use the method in the REPL, then you get a weird type error. Oddly, if the method is defined outside the REPL, then the call works the first time, but subsequent calls fail. Also oddly, the call works if both calls have an @specialized, even if the argument list is empty for one of them. (This last is a nice workaround...)
fukaeri:breeze dlwh (0.10)$ scala
Welcome to Scala version 2.11.0 (JavaHotSpot(TM) 64-BitServerVM, Java1.7.0_21).
Type in expressions to have them evaluated.
Type:help for more information.
scala>deffoo[A, @specialized(Double) V](a: A, b: V) = b
foo: [A, V](a: A, b: V)V
scala> foo("AAA", 3.0)
<console>:9:error: wrong number of typeparametersfor method foo$mDc$sp: [A](a: A, b: Double)Double
foo("AAA", 3.0)
^
scala> fukaeri:breeze dlwh (0.10)$ scala
Welcome to Scala version 2.11.0 (JavaHotSpot(TM) 64-BitServerVM, Java1.7.0_21).
Type in expressions to have them evaluated.
Type:help for more information.
scala>deffoo[@specialized(Int) A, @specialized(Double) V](a: A, b: V) = b
foo: [A, V](a: A, b: V)V
scala> foo("AAA", 3.0)
res0:Double=3.0
scala>deffoo[@specialized() A, @specialized(Double) V](a: A, b: V) = b
foo: [A, V](a: A, b: V)V
scala> foo("AAA", 3.0)
res1:Double=3.0
scala>
The text was updated successfully, but these errors were encountered:
(Regression since 2.10.4)
If you specialize one type parameter of a method, but not all of them, and then use the method in the REPL, then you get a weird type error. Oddly, if the method is defined outside the REPL, then the call works the first time, but subsequent calls fail. Also oddly, the call works if both calls have an @specialized, even if the argument list is empty for one of them. (This last is a nice workaround...)
The text was updated successfully, but these errors were encountered: