-
Notifications
You must be signed in to change notification settings - Fork 21
Type inference fails for singleton objects #1208
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-1208?orig=1 |
Aaron Harnly (aaronharnly) said: |
@odersky said: |
Geoffrey Alan Washburn (washburn) said: |
@odersky said: The type of a designator is the type I invite everyone to change this rule, and observe what breaks! |
Lauri Alanko (lealanko) said: Personally, I think it's a bad idea to infer a type into a non-positive position from a positive occurrence (i.e. the type of a value), and wouldn't mind requiring explicit type annotations/arguments for such situations, if that would make inference into positive positions work better. Granted, this would make local vars less practical, but personally I don't see much reason to make imperative programming too easy. :) |
@odersky said: |
@odersky said: |
@paulp said: |
@paulp said: This much beloved comment from #1208 has been on my radar for two scala> val x: Map[Int, Singleton] = Map(1 -> None) Now exudes a pleasing aura of workingness: scala> val x: Map[Int, Singleton] = Map(1 -> None) No review. |
@okomok said: |
The following fails with a type mismatch:
but succeeds with extra type annotation:
This is annoying and I wish it were different :) Especially for the case with multiple type parameters, all of which can be inferred except for the singleton...
The text was updated successfully, but these errors were encountered: