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

parameter type inference with type paramers broken #1803

Closed
scabug opened this issue Mar 18, 2009 · 6 comments
Closed

parameter type inference with type paramers broken #1803

scabug opened this issue Mar 18, 2009 · 6 comments
Labels
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Mar 18, 2009

the type infered for parameters of an overriding method do not refer to the right type parameter symbol (skolemized / deSkolemized).

lamppc26:~ luc$$ workspace/scala/build/quick/bin/scala -Xexperimental -uniqid
Welcome to Scala version (unknown) (Java HotSpot(TM) Client VM, Java 1.5.0_16).
Type in expressions to have them evaluated.
Type :help for more information.

scala> class A { def foo[A](a: A) = a }
defined class A

scala> class B extends A { override def foo[A](b) = b }
<console>:5: error: type mismatch;
 found   : ASI-10818
 required: ASI-10819
       class B extends A { override def foo[A](b) = b }
                                                    ^
@scabug
Copy link
Author

@scabug scabug commented Mar 18, 2009

Loading

@scabug
Copy link
Author

@scabug scabug commented Feb 6, 2015

kenji yoshida said:
resolved?

$ scala -Yinfer-argument-types -uniqid
Welcome to Scala version 2.11.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_72).
Type in expressions to have them evaluated.
Type :help for more information.

scala> class A { def foo[A](a: A) = a }
defined class A

scala> class B extends A { override def foo[A](b) = b }
defined class B

Loading

@scabug scabug added this to the Backlog milestone Apr 6, 2017
@spangaer
Copy link

@spangaer spangaer commented Apr 5, 2018

That one is indeed fixed but another one is broken.
When generic parameters are assigned in deriving class. Methods using those generic parameters used to support type inference when overridden (Scala 2.11), but now no longer do (Scala 2.12).

Scala 2.11

C:\Windows\System32>scala -Yinfer-argument-types
Welcome to Scala version 2.11.7 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions to have them evaluated.
Type :help for more information.

scala> trait X[T] {  def doit(t: T): T}
defined trait X

scala> class Y extends X[String] {  override def doit(s) =    s}
defined class Y

Scala 2.12

D:\data\downloads\java\scala\scala-2.12.5\scala-2.12.5\bin>scala -Yinfer-argument-types
Welcome to Scala 2.12.5 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_112).
Type in expressions for evaluation. Or try :help.

scala> trait X[T] {  def doit(t: T): T}
defined trait X

scala> class Y extends X[String] {  override def doit(s) =    s}
<console>:12: error: type mismatch;
 found   : T
 required: String
       class Y extends X[String] {  override def doit(s) =    s}
                                                              ^

Loading

@hrhino
Copy link
Member

@hrhino hrhino commented Apr 5, 2018

I think this feature may be on the chopping block (as part of scala/scala-dev#430), so this might become a won't-fix soon.

Loading

@adriaanm
Copy link
Contributor

@adriaanm adriaanm commented Apr 5, 2018

Yes, this will go away, sorry.

Loading

@adriaanm adriaanm closed this Apr 5, 2018
@spangaer
Copy link

@spangaer spangaer commented Apr 5, 2018

Faster response than expected.

Well, I got this in via -Xexperimental which I had put in in the process of enabling Java 8 lambda bytecode in 2.11. Wasn't aware of the matter, but built quite a bit of code base that relied on it :(

Ok, out it goes. Hope you get a chance to respond to my comment in the referred issue equally fast ;).

Loading

@scala scala deleted a comment from scabug Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants