-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when initializing val in ByName closure (#22354)
This PR creates a new Env when evaluating a by name closure, fixing a crash due to duplicate initialization of the same value.
- Loading branch information
Showing
2 changed files
with
30 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
trait T: | ||
def bar(i: => Int): Int | ||
|
||
class A extends T: | ||
override def bar(i: => Int): Int = i + 1 | ||
|
||
class B extends T: | ||
override def bar(i: => Int): Int = i + 2 | ||
|
||
object A: | ||
val a: T = if ??? then new A else new B | ||
def foo(b: List[Int]) = a.bar(b match { | ||
case x :: xs => 1 | ||
case Nil => 0 | ||
}) | ||
|
||
val f = foo(Nil) |