Skip to content

Commit 5715f78

Browse files
committed
Text #2527
1 parent 0ac256a commit 5715f78

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

tests/pos/i2527.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Foo {
2+
val f: Function0[Int]{ def apply(): Int } = () => 42
3+
}

tests/pos/i2527b.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Base
2+
3+
object Test {
4+
// OK
5+
val widen = {
6+
class Inner extends Base
7+
val f: () => Inner = { () => new Inner }
8+
f()
9+
}
10+
11+
// Crash
12+
val leak = {
13+
class Inner extends Base
14+
val f: (() => Inner){ def apply(): Inner } = { () => new Inner }
15+
f()
16+
}
17+
18+
}

0 commit comments

Comments
 (0)