Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
EnzeXing committed Sep 7, 2024
1 parent f97db49 commit 286f0c1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/init-global/pos/shared-local-var-between-recursion.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
trait Foo:
def f(): Int

object O1 extends Foo:
var a1: Int = bar(this).f()

def bar(param: Foo): Foo =
var local = param
bar(O2)
local
override def f(): Int = 0

object O2 extends Foo:
var a2 = 0
override def f(): Int = a2
8 changes: 8 additions & 0 deletions tests/init-global/warn/local-var-leak.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
object O1:
val a = O2.b()

object O2:
val b = f()
def f(): () => Int =
var local = 0
() => local // warn

0 comments on commit 286f0c1

Please sign in to comment.