We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 01a12df commit 20e28f0Copy full SHA for 20e28f0
tests/run/i19224.scala
@@ -1,9 +1,15 @@
1
+// scalajs: --skip
2
-object Test extends App:
3
+object Test extends App {
4
val field = 1
5
def x(): Int => String = (i: Int) => i.toString
6
def y(): () => String = () => field.toString
- locally:
7
+
8
+ locally {
9
assert(x() == x()) // true on Scala 2, was false on Scala 3...
10
assert(y() == y()) // also true if `y` accesses object-local fields
11
12
+ def z(): Int => String = (i: Int) => i.toString
13
+ assert(z() != z()) // lambdas in constructor are not lifted to static, so no memoization (Scala 2 lifts them, though).
14
+ }
15
+}
0 commit comments