Skip to content

Commit 5b8cb0e

Browse files
committed
Add test for #620
The issue in #6642 shows that errors may be latent in seemingly simple fixes if not tested, which can backlash us at critical moment.
1 parent ed8c6ee commit 5b8cb0e

File tree

2 files changed

+144
-0
lines changed

2 files changed

+144
-0
lines changed

tests/neg/i620.check

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:8:30 ---------------------------------------------------------------
2+
8 | protected[D] def a: Int = "" // error
3+
| ^^
4+
| Found: String("")
5+
| Required: Int
6+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:9:30 ---------------------------------------------------------------
7+
9 | private[D] def b: Int = "" // error
8+
| ^^
9+
| Found: String("")
10+
| Required: Int
11+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:10:30 --------------------------------------------------------------
12+
10 | private def c: Int = "" // error
13+
| ^^
14+
| Found: String("")
15+
| Required: Int
16+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:11:30 --------------------------------------------------------------
17+
11 | protected def d: Int = "" // error
18+
| ^^
19+
| Found: String("")
20+
| Required: Int
21+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:12:30 --------------------------------------------------------------
22+
12 | private[A] def e: Int = "" // error
23+
| ^^
24+
| Found: String("")
25+
| Required: Int
26+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:13:30 --------------------------------------------------------------
27+
13 | protected[A] def f: Int = "" // error
28+
| ^^
29+
| Found: String("")
30+
| Required: Int
31+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:14:30 --------------------------------------------------------------
32+
14 | def g: Int = "" // error
33+
| ^^
34+
| Found: String("")
35+
| Required: Int
36+
-- [E112] Syntax Error: tests/neg/i620.scala:17:24 ---------------------------------------------------------------------
37+
17 | private[D] class E extends Option[Int] // error
38+
| ^
39+
| Cannot extend sealed class Option in a different source file
40+
41+
longer explanation available when compiling with `-explain`
42+
-- [E112] Syntax Error: tests/neg/i620.scala:18:24 ---------------------------------------------------------------------
43+
18 | private class F extends Option[Int] // error
44+
| ^
45+
| Cannot extend sealed class Option in a different source file
46+
47+
longer explanation available when compiling with `-explain`
48+
-- [E112] Syntax Error: tests/neg/i620.scala:19:24 ---------------------------------------------------------------------
49+
19 | private[A] class G extends Option[Int] // error
50+
| ^
51+
| Cannot extend sealed class Option in a different source file
52+
53+
longer explanation available when compiling with `-explain`
54+
-- [E112] Syntax Error: tests/neg/i620.scala:20:24 ---------------------------------------------------------------------
55+
20 | protected[D] class H extends Option[Int] // error
56+
| ^
57+
| Cannot extend sealed class Option in a different source file
58+
59+
longer explanation available when compiling with `-explain`
60+
-- [E112] Syntax Error: tests/neg/i620.scala:21:24 ---------------------------------------------------------------------
61+
21 | protected class I extends Option[Int] // error
62+
| ^
63+
| Cannot extend sealed class Option in a different source file
64+
65+
longer explanation available when compiling with `-explain`
66+
-- [E112] Syntax Error: tests/neg/i620.scala:22:24 ---------------------------------------------------------------------
67+
22 | protected[A] class J extends Option[Int] // error
68+
| ^
69+
| Cannot extend sealed class Option in a different source file
70+
71+
longer explanation available when compiling with `-explain`
72+
-- [E112] Syntax Error: tests/neg/i620.scala:23:24 ---------------------------------------------------------------------
73+
23 | class K extends Option[Int] // error
74+
| ^
75+
| Cannot extend sealed class Option in a different source file
76+
77+
longer explanation available when compiling with `-explain`
78+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:25:28 --------------------------------------------------------------
79+
25 | protected[D] val a: Int = "" // error
80+
| ^^
81+
| Found: String("")
82+
| Required: Int
83+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:26:28 --------------------------------------------------------------
84+
26 | private[D] val b: Int = "" // error
85+
| ^^
86+
| Found: String("")
87+
| Required: Int
88+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:27:28 --------------------------------------------------------------
89+
27 | private val c: Int = "" // error
90+
| ^^
91+
| Found: String("")
92+
| Required: Int
93+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:28:28 --------------------------------------------------------------
94+
28 | protected val d: Int = "" // error
95+
| ^^
96+
| Found: String("")
97+
| Required: Int
98+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:29:28 --------------------------------------------------------------
99+
29 | private[A] val e: Int = "" // error
100+
| ^^
101+
| Found: String("")
102+
| Required: Int
103+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:30:28 --------------------------------------------------------------
104+
30 | protected[A] val f: Int = "" // error
105+
| ^^
106+
| Found: String("")
107+
| Required: Int
108+
-- [E007] Type Mismatch Error: tests/neg/i620.scala:31:28 --------------------------------------------------------------
109+
31 | val g: Int = "" // error
110+
| ^^
111+
| Found: String("")
112+
| Required: Int

tests/neg/i620.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// test printing of private[D] and protected[D]
2+
3+
package O
4+
package A
5+
6+
class D {
7+
class C {
8+
protected[D] def a: Int = "" // error
9+
private[D] def b: Int = "" // error
10+
private def c: Int = "" // error
11+
protected def d: Int = "" // error
12+
private[A] def e: Int = "" // error
13+
protected[A] def f: Int = "" // error
14+
def g: Int = "" // error
15+
}
16+
17+
private[D] class E extends Option[Int] // error
18+
private class F extends Option[Int] // error
19+
private[A] class G extends Option[Int] // error
20+
protected[D] class H extends Option[Int] // error
21+
protected class I extends Option[Int] // error
22+
protected[A] class J extends Option[Int] // error
23+
class K extends Option[Int] // error
24+
25+
protected[D] val a: Int = "" // error
26+
private[D] val b: Int = "" // error
27+
private val c: Int = "" // error
28+
protected val d: Int = "" // error
29+
private[A] val e: Int = "" // error
30+
protected[A] val f: Int = "" // error
31+
val g: Int = "" // error
32+
}

0 commit comments

Comments
 (0)