Skip to content

Commit 003c6c2

Browse files
committed
Separate object init tests from class init tests
1 parent d317f0a commit 003c6c2

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
@@ -269,6 +269,14 @@ class CompilationTests {
269269
compileFilesInDir("tests/explicit-nulls/run", explicitNullsOptions)
270270
}.checkRuns()
271271

272+
// initialization tests
273+
@Test def checkInitGlobal: Unit = {
274+
implicit val testGroup: TestGroup = TestGroup("checkInitGlobal")
275+
val options = defaultOptions.and("-Ysafe-init-global", "-Xfatal-warnings")
276+
compileFilesInDir("tests/init-global/neg", options).checkExpectedErrors()
277+
compileFilesInDir("tests/init-global/pos", options).checkCompile()
278+
}
279+
272280
// initialization tests
273281
@Test def checkInit: Unit = {
274282
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)