Skip to content

Commit 2fa37be

Browse files
noti0na1tgodzik
authored andcommitted
Add REPL test
1 parent 0126484 commit 2fa37be

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

compiler/test/dotty/tools/repl/ReplCompilerTests.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,34 @@ class ReplCompilerTests extends ReplTest:
372372
assertTrue(last, last.startsWith("val res0: tpolecat.type = null"))
373373
assertTrue(last, last.endsWith("""// result of "res0.toString" is null"""))
374374

375+
@Test def `i9879`: Unit = initially:
376+
run {
377+
"""|opaque type A = Int; def getA: A = 0
378+
|object Wrapper { opaque type A = Int; def getA: A = 1 }
379+
|val x = getA
380+
|val y = Wrapper.getA""".stripMargin
381+
}
382+
val expected = List(
383+
"def getA: A",
384+
"// defined object Wrapper",
385+
"val x: A = 0",
386+
"val y: Wrapper.A = 1"
387+
)
388+
assertEquals(expected, lines())
389+
390+
@Test def `i9879b`: Unit = initially:
391+
run {
392+
"""|def test =
393+
| type A = Int
394+
| opaque type B = String
395+
| object Wrapper { opaque type C = Int }
396+
| ()""".stripMargin
397+
}
398+
val all = lines()
399+
assertEquals(6, all.length)
400+
assertTrue(all.head.startsWith("-- [E103] Syntax Error"))
401+
assertTrue(all.exists(_.trim().startsWith("| Illegal start of statement: this modifier is not allowed here")))
402+
375403
object ReplCompilerTests:
376404

377405
private val pattern = Pattern.compile("\\r[\\n]?|\\n");

0 commit comments

Comments
 (0)