Skip to content

Commit e5d8ed5

Browse files
committed
Separate object init tests from class init tests
1 parent 4973bfa commit e5d8ed5

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
@@ -274,6 +274,14 @@ class CompilationTests {
274274
compileFilesInDir("tests/explicit-nulls/run", explicitNullsOptions)
275275
}.checkRuns()
276276

277+
// initialization tests
278+
@Test def checkInitGlobal: Unit = {
279+
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
280+
val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings")
281+
compileFilesInDir("tests/init-global/neg", options).checkExpectedErrors()
282+
compileFilesInDir("tests/init-global/pos", options).checkCompile()
283+
}
284+
277285
// initialization tests
278286
@Test def checkInit: Unit = {
279287
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)