Skip to content

Commit 84f407a

Browse files
author
EnzeXing
committed
Further modification; update tests
1 parent 9c3e637 commit 84f407a

17 files changed

+305
-216
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 196 additions & 171 deletions
Large diffs are not rendered by default.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class B {}
2+
3+
class C(c: B) extends B
4+
5+
object O:
6+
def f(param: B): Int = f(new C(param))
7+
val a = f(new B)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object O:
2+
val a = m(2)
3+
def m(f: Int) =
4+
val a = f
5+
() => a
6+
7+
object O2:
8+
val func = O.a
9+
val a = func()
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class A(val a: A)
2+
object B:
3+
val a: A = loop().a
4+
def loop(): A = new A(loop())
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Outer {
2+
def foo = {
3+
val y = 5
4+
class C {
5+
val x = y
6+
}
7+
class D {
8+
new C
9+
}
10+
11+
new D
12+
}
13+
14+
foo
15+
16+
val n = 10 // warn
17+
}
18+
19+
object O {
20+
val c = new Outer
21+
}

tests/init-global/warn/widen.scala renamed to tests/init-global/pos/lookup-outer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object O:
1010
def bar(t: T) = {
1111
class A {
1212
class B {
13-
t.foo() // warn
13+
t.foo()
1414
}
1515

1616
val b = new B

tests/init-global/warn/global-irrelevance3.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@
99
|│ ^^^^^^^
1010
|└── (() => x) // warn [ global-irrelevance3.scala:9 ]
1111
| ^
12+
|The mutable state is created through:
13+
|├── object A: [ global-irrelevance3.scala:1 ]
14+
|│ ^
15+
|└── val p: Pair = foo() [ global-irrelevance3.scala:3 ]
16+
| ^^^^^

tests/init-global/warn/global-irrelevance4.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@
99
| │ ^^^^^^^^^
1010
| └── (y => x = y), // warn [ global-irrelevance4.scala:8 ]
1111
| ^^^^^^^^^^
12+
| The mutable state is created through:
13+
| ├── object A: [ global-irrelevance4.scala:1 ]
14+
| │ ^
15+
| └── val p: Pair = foo() [ global-irrelevance4.scala:3 ]
16+
| ^^^^^

tests/init-global/warn/mutable-array.check

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@
1010
|The mutable state is created through:
1111
|├── object A: [ mutable-array.scala:1 ]
1212
|│ ^
13-
|├── val box: Box = new Box(0) [ mutable-array.scala:3 ]
14-
|│ ^^^^^^^^^^
15-
|└── class Box(var value: Int) [ mutable-array.scala:2 ]
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
13+
|└── val box: Box = new Box(0) [ mutable-array.scala:3 ]
14+
| ^^^^^^^^^^

tests/init-global/warn/mutable-read1.check

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,5 @@
1010
|The mutable state is created through:
1111
|├── object A: [ mutable-read1.scala:3 ]
1212
|│ ^
13-
|├── val box: Box = new Box(4) [ mutable-read1.scala:4 ]
14-
|│ ^^^^^^^^^^
15-
|└── class Box(var value: Int) [ mutable-read1.scala:1 ]
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
13+
|└── val box: Box = new Box(4) [ mutable-read1.scala:4 ]
14+
| ^^^^^^^^^^

0 commit comments

Comments
 (0)