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

Singleton-type inference in method return type #9023

Closed
scabug opened this issue Dec 1, 2014 · 5 comments
Closed

Singleton-type inference in method return type #9023

scabug opened this issue Dec 1, 2014 · 5 comments

Comments

@scabug
Copy link

scabug commented Dec 1, 2014

According to SLS, a type in value definition(in method definition, too) is not determined by the local type inference, so

scala> val p = "hello"
p: String = hello

scala> val v = p : p.type
v: p.type = hello

seems ok, but

scala> def v = p : p.type
v: String

. Or SLS is wrong?

@scabug
Copy link
Author

scabug commented Dec 1, 2014

Imported From: https://issues.scala-lang.org/browse/SI-9023?orig=1
Reporter: @okomok
Affected Versions: 2.11.4

@scabug
Copy link
Author

scabug commented Dec 1, 2014

@retronym said:
Type inference of vals, vars, and defs widen the type of the RHS. The rules are not (yet) specified.

We are reviewing this area in adriaanm/scala#12 and will specify them as part of that SIP.

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@okomok said:
So

scala> val v = p : p.type
v: p.type = hello

will be a bug with the upcoming specifications?

@scabug
Copy link
Author

scabug commented Dec 3, 2014

@okomok said:

val p = "hello"
val q = p : p.type
implicitly[q.type =:= p.type]

compiles (wrongly?).

@scabug
Copy link
Author

scabug commented Dec 5, 2014

@okomok said:
After all, this ticket seems a duplicate of #6767.
Thanks.

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