Skip to content

Eta-expansion for method with by-name parameter fail at runtime #5976

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

Closed
newca12 opened this issue Feb 23, 2019 · 0 comments
Closed

Eta-expansion for method with by-name parameter fail at runtime #5976

newca12 opened this issue Feb 23, 2019 · 0 comments

Comments

@newca12
Copy link
Contributor

newca12 commented Feb 23, 2019

def f(i: => Int) = i + i
implicit def ups(f: ((=>Int) => Int)): (Int => Int) = x => f(x)
val res = List(42).map(f)

work with scalac but fail with dotty even with -language:Scala2
Example come from : scala/bug#11414

java.lang.ClassCastException: class java.lang.Integer cannot be cast to class scala.Function0 (java.lang.Integer is in module java.base of loader 'bootstrap'; scala.Function0 is in unnamed module of loader 'app')
	at scala.collection.immutable.List.map(List.scala:286)
	at rs$line$1$.<init>(rs$line$1:3)
	at rs$line$1$.<clinit>(rs$line$1)
	at rs$line$1.res(rs$line$1)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at dotty.tools.repl.Rendering.$anonfun$3(Rendering.scala:57)
	at scala.Option.map(Option.scala:163)
	at dotty.tools.repl.Rendering.valueOf(Rendering.scala:57)
	at dotty.tools.repl.Rendering.renderVal(Rendering.scala:80)
	at dotty.tools.repl.ReplDriver.displayMembers$3$$anonfun$3(ReplDriver.scala:274)
	at scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:237)
	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:62)
	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:55)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:49)
	at scala.collection.TraversableLike.map(TraversableLike.scala:237)
	at scala.collection.TraversableLike.map$(TraversableLike.scala:230)
	at scala.collection.AbstractTraversable.map(Traversable.scala:108)
	at dotty.tools.repl.ReplDriver.displayMembers$7(ReplDriver.scala:274)
	at dotty.tools.repl.ReplDriver.displayDefinitions$$anonfun$3$$anonfun$2(ReplDriver.scala:301)
	at scala.Option.map(Option.scala:163)
	at dotty.tools.repl.ReplDriver.displayDefinitions$$anonfun$1(ReplDriver.scala:301)
	at dotty.tools.dotc.core.Periods.atPhase(Periods.scala:25)
	at dotty.tools.dotc.core.Phases.atPhase(Phases.scala:35)
	at dotty.tools.repl.ReplDriver.displayDefinitions(ReplDriver.scala:306)
	at dotty.tools.repl.ReplDriver.compile$$anonfun$2(ReplDriver.scala:230)
	at scala.util.Either.fold(Either.scala:191)
	at dotty.tools.repl.ReplDriver.compile(ReplDriver.scala:230)
	at dotty.tools.repl.ReplDriver.interpret(ReplDriver.scala:182)
	at dotty.tools.repl.ReplDriver.loop$1(ReplDriver.scala:127)
	at dotty.tools.repl.ReplDriver.runUntilQuit$$anonfun$1(ReplDriver.scala:130)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput$$anonfun$2$$anonfun$1(ReplDriver.scala:143)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withErr(Console.scala:196)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput$$anonfun$1(ReplDriver.scala:143)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:62)
	at scala.Console$.withOut(Console.scala:167)
	at dotty.tools.repl.ReplDriver.withRedirectedOutput(ReplDriver.scala:143)
	at dotty.tools.repl.ReplDriver.runUntilQuit(ReplDriver.scala:130)
	at dotty.tools.repl.Main$.main(Main.scala:6)
	at dotty.tools.repl.Main.main(Main.scala)
@newca12 newca12 changed the title Eta-expansion for method with by-name paramter fail at runtime Eta-expansion for method with by-name parameter fail at runtime Feb 23, 2019
@odersky odersky closed this as completed in 728225f Mar 1, 2019
odersky added a commit that referenced this issue Mar 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant