File tree Expand file tree Collapse file tree 13 files changed +51
-43
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 13 files changed +51
-43
lines changed Original file line number Diff line number Diff line change @@ -1140,7 +1140,7 @@ object Semantic:
1140
1140
*/
1141
1141
def checkClasses (classes : List [ClassSymbol ])(using Context ): Unit =
1142
1142
given Cache .Data ()
1143
- for classSym <- classes if isConcreteClass(classSym) do
1143
+ for classSym <- classes if isConcreteClass(classSym) && ! classSym.isStaticObject do
1144
1144
checkClass(classSym)
1145
1145
1146
1146
// ----- Semantic definition --------------------------------
Original file line number Diff line number Diff line change
1
+ val a = b // error
2
+ val b = 1
Original file line number Diff line number Diff line change 1
- object O :
1
+ class O :
2
2
case class A (b : B ):
3
3
println(n)
4
4
Original file line number Diff line number Diff line change @@ -12,14 +12,14 @@ trait U {
12
12
val f2 : Int
13
13
}
14
14
15
- object Test0 extends U {
15
+ class Test0 extends U {
16
16
final val f1 = 1
17
17
final val f2 = 2
18
18
final val f3 = f1 + f2
19
19
val f4 : 3 = f3
20
20
}
21
21
22
- object Test1 extends U {
22
+ class Test1 extends U {
23
23
final val f1 = 1
24
24
final val f3 = f1 + f2
25
25
final val f2 = 2
@@ -28,7 +28,7 @@ object Test1 extends U {
28
28
29
29
}
30
30
31
- object Test extends T {
31
+ class Test extends T {
32
32
override final val f1 = /* super.f1*/ 1 + f2 // error
33
33
override final val f2 = 2 // error
34
34
override final val f3 = {println(3 ); 3 } // error
@@ -37,7 +37,7 @@ object Test extends T {
37
37
def g : 3 = { println(" g" ); 3 }
38
38
final val x = g + 1
39
39
def main (args : Array [String ]): Unit = {
40
- Test0
41
- Test1
40
+ new Test0
41
+ new Test1
42
42
}
43
43
}
Original file line number Diff line number Diff line change @@ -2,18 +2,23 @@ enum Enum:
2
2
case Case
3
3
case Case2 (x : Int )
4
4
5
- def g (b : Enum .B ): Int = b.foo()
5
+ class Outer :
6
+ val e = new Enum2
6
7
7
- object Enum :
8
- object nested :
9
- val a : Enum = Case
8
+ class Enum2 :
9
+ class nested :
10
+ val a : Enum = Enum . Case
10
11
11
- val b : Enum = f(nested.a)
12
+ val b : Enum = f(( new nested) .a)
12
13
13
- def f (e : Enum ): Enum = e
14
+ def f (e : Enum ): Enum = e
14
15
15
- class B () { def foo () = n + 1 }
16
- g(new B ()) // error
17
- val n : Int = 10
16
+ class B () { def foo () = n + 1 }
17
+ def g (b : B ): Int = b.foo()
18
+ g(new B ()) // error
19
+ val n : Int = 10
18
20
19
- @ main def main (): Unit = println(Enum .b)
21
+ @ main def main (): Unit = {
22
+ val o = new Outer
23
+ print(o.e.b)
24
+ }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- object App {
1
+ class App {
2
2
trait A { type L >: Any }
3
3
def upcast (a : A , x : Any ): a.L = x
4
4
val p : A { type L <: Nothing } = p // error
Original file line number Diff line number Diff line change 1
- object Scanners {
1
+ class Scanners {
2
2
enum IndentWidth {
3
3
case Run (ch : Char , n : Int )
4
4
case Conc (l : IndentWidth , r : Run )
Original file line number Diff line number Diff line change 1
- object Flags {
2
- class Inner {
3
- println(b)
4
- }
1
+ class Outer :
2
+ val flags = new Flags // error
5
3
6
- new Flags .Inner
4
+ class Flags {
5
+ class Inner {
6
+ println(b)
7
+ }
7
8
8
- val a = this .b + 3
9
- val b = 5 // error
10
- }
9
+ new flags.Inner
11
10
12
- object Flags2 {
13
- class Inner {
14
- println(b)
11
+ val a = this .b + 3
12
+ val b = 5 // error
15
13
}
16
14
15
+ class Flags2 {
16
+ class Inner {
17
+ println(b)
18
+ }
19
+
17
20
18
- lazy val a = 3
19
- val b = 5
20
- }
21
+ lazy val a = 3
22
+ val b = 5
23
+ }
Original file line number Diff line number Diff line change 2
2
19 | val l2 = l.map(_.m()) // error
3
3
| ^^^^^^^^^^^^
4
4
| Call method method map on an uninitialized (Cold) object. Calling trace:
5
- | ├── object leakWarm { [ leak-warm.scala:1 ]
5
+ | ├── class leakWarm { [ leak-warm.scala:1 ]
6
6
| │ ^
7
7
| └── val l2 = l.map(_.m()) // error [ leak-warm.scala:19 ]
8
8
| ^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments