Skip to content

Commit 9644cf5

Browse files
committed
Separate object init tests from class init tests
1 parent 74b629f commit 9644cf5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+21
-1
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,14 @@ class CompilationTests {
266266
compileFilesInDir("tests/explicit-nulls/run", explicitNullsOptions)
267267
}.checkRuns()
268268

269+
// initialization tests
270+
@Test def checkInitGlobal: Unit = {
271+
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
272+
val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings")
273+
compileFilesInDir("tests/init-global/neg", options).checkExpectedErrors()
274+
compileFilesInDir("tests/init-global/pos", options).checkCompile()
275+
}
276+
269277
// initialization tests
270278
@Test def checkInit: Unit = {
271279
implicit val testGroup: TestGroup = TestGroup("checkInit")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/init/neg/i12544.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ enum Enum:
55
def g(b: Enum.B): Int = b.foo()
66

77
object Enum:
8-
object nested: // error
8+
object nested:
99
val a: Enum = Case
1010

1111
val b: Enum = f(nested.a)

tests/init/pos/i12544.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
enum Enum:
2+
case Case
3+
4+
object Enum:
5+
object nested:
6+
val a: Enum = Case
7+
8+
val b: Enum = f(nested.a)
9+
10+
def f(e: Enum): Enum = e
11+
12+
@main def main(): Unit = println(Enum.b)

0 commit comments

Comments
 (0)