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

by-name types inferred with eta-expansion #7899

Closed
scabug opened this issue Oct 7, 2013 · 5 comments
Closed

by-name types inferred with eta-expansion #7899

scabug opened this issue Oct 7, 2013 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Oct 7, 2013

scala> def foo[B](f: (=> Int) => B): Option[B] = ???
foo: [B](f: (=> Int) => B)Option[B]

scala> def b = foo(identity)
b: Option[=> Int]

scala> def b = foo(identity(_))
b: Option[Int]
@scabug
Copy link
Author

scabug commented Oct 7, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7899?orig=1
Reporter: @retronym
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Oct 7, 2013

@retronym said (edited on Oct 7, 2013 9:09:41 AM UTC):
This leads to ClassCastExceptions:

scala> def foo[B](f: (=> Int) => B): () => B = () => f(0)
foo: [B](f: (=> Int) => B)() => B

scala> def b = foo(identity(_))
b: () => Int

scala> def b = foo(identity)
b: () => => Int

scala> foo(identity)()
java.lang.ClassCastException: $anonfun$foo$1$$anonfun$apply$1 cannot be cast to java.lang.Integer
	at scala.runtime.BoxesRunTime.unboxToInt(BoxesRunTime.java:106)

@scabug
Copy link
Author

scabug commented Oct 7, 2013

@scabug
Copy link
Author

scabug commented Oct 7, 2013

@retronym said:
scala/scala#3022

@scabug scabug closed this as completed Oct 9, 2013
@scabug
Copy link
Author

scabug commented Oct 12, 2013

@retronym said:
I've moved this change behind -Xstict-inference to avoid the regression in Scala Free: scala/scala#3034.

Hopefully this will be a temporary measure.

@scabug scabug added this to the 2.11.0-M7 milestone Apr 7, 2017
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