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

Scala does not seem to identify the type of byname members #7975

Closed
scabug opened this issue Nov 17, 2013 · 3 comments
Closed

Scala does not seem to identify the type of byname members #7975

scabug opened this issue Nov 17, 2013 · 3 comments

Comments

@scabug
Copy link

scabug commented Nov 17, 2013

This is trivial outside of side-effecting code but I'm surprised Scala doesn't identify g as => Int => String.

scala> object Foo { val f = {println("A"); (_:Int).toString}; def g = {println("B"); (_:Int).toString } }
defined module Foo

scala> Foo
A
res15: Foo.type = Foo$@6ea4ffc6

scala> :t Foo.f
Int => String

scala> :t Foo.g
Int => String

scala> val x = Foo.f
x: Int => String = <function1>

scala> val y = Foo.g
B
y: Int => String = <function1>

scala> val y = Foo.g
B
y: Int => String = <function1>
@scabug
Copy link
Author

scabug commented Nov 17, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7975?orig=1
Reporter: Lanny Ripple (lanny ripple)
Affected Versions: 2.10.3

@scabug
Copy link
Author

scabug commented Nov 17, 2013

@paulp said:
That isn't a "by-name member", it's a method. There aren't any by-name members, there are only by-name parameters. Whether a member is a val or a def is not information which is encoded into its type.

@scabug
Copy link
Author

scabug commented Nov 17, 2013

Lanny Ripple (lanny ripple) said:
Paul's comment clears this up.

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

1 participant