Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

incomplete @specialized-ization doesn't work well in the REPL #8886

Closed
scabug opened this issue Oct 6, 2014 · 4 comments
Closed

incomplete @specialized-ization doesn't work well in the REPL #8886

scabug opened this issue Oct 6, 2014 · 4 comments

Comments

@scabug
Copy link

scabug commented Oct 6, 2014

(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...)

fukaeri:breeze dlwh (0.10)$ scala
Welcome to Scala version 2.11.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.

scala> def foo[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 type parameters for 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 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_21).
Type in expressions to have them evaluated.
Type :help for more information.

scala> def foo[@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> def foo[@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>
@scabug
Copy link
Author

scabug commented Oct 6, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8886?orig=1
Reporter: @dlwh
Affected Versions: 2.11.2
See #8871

@scabug
Copy link
Author

scabug commented Oct 6, 2014

@dlwh said:
(despite transcript, error occurs in 2.11.1 and 2.11.2)

@scabug
Copy link
Author

scabug commented Oct 7, 2014

@som-snytt said:
Do you mean like SI-8871?

@scabug
Copy link
Author

scabug commented Oct 7, 2014

@retronym said:
Yep, looks like a duplicate. I wan't aware that it is a regression though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants