Created
July 15, 2010 19:07
-
-
Save jorgeortiz85/477368 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> object Foo | |
defined module Foo | |
scala> val x = Foo | |
x: Foo.type = Foo$@24753433 | |
scala> val y = identity(Foo) | |
y: object Foo = Foo$@24753433 |
Hmm... yeah, I think I remember Martin saying that singleton types aren't inferred because then a singleton type would pretty much always be inferred.
Also, James Iry found this gem:
scala> def test(x: Foo.type) = x
test: (x: Foo.type)object Foo
scala> test(x)
res6: object Foo = Foo$@600ab1bf
From @collinmbulluck: Somehting to do with type inference and stable vs unstable identifiers?
scala> val x = Foo
x: Foo.type = Foo$@600ab1bf
scala> var y = Foo
y: object Foo = Foo$@600ab1bf
a) If singleton types were inferred, we wouldn't have the martin classic "I invite everyone to change this rule, and observe what breaks!"
https://lampsvn.epfl.ch/trac/scala/ticket/1208
b) See also comments in:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Singleton types aren't inferred as type arguments. Not sure of the rationale.