Skip to content

Commit 92c2215

Browse files
committed
Improve error message
1 parent dc5a68f commit 92c2215

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

compiler/src/dotty/tools/dotc/core/Flags.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ object Flags {
134134
}
135135

136136
/** The list of non-empty names of flags that are set in the given flag set */
137-
def flagStrings(privateWithin: String): Seq[String] = {
137+
def flagStrings(privateWithin: String = ""): Seq[String] = {
138138
var rawStrings = (2 to MaxFlag).flatMap(x.flagString(_)) // DOTTY problem: cannot drop with (_)
139139
if (!privateWithin.isEmpty && !x.is(Protected))
140140
rawStrings = rawStrings :+ "private"

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3847,7 +3847,7 @@ object Parsers {
38473847
def checkLegal(tree: Tree): List[Tree] =
38483848
val problem = tree match
38493849
case tree: MemberDef if !(tree.mods.flags & ModifierFlags).isEmpty =>
3850-
i"refinement cannot be ${(tree.mods.flags & ModifierFlags).flagsString}"
3850+
i"refinement cannot be ${(tree.mods.flags & ModifierFlags).flagStrings().mkString("`", "`, `", "`")}"
38513851
case tree: ValOrDefDef =>
38523852
if tree.rhs.isEmpty then ""
38533853
else "refinement in cannot have a right-hand side"

tests/neg/i8150.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
trait A
22
trait B
3-
type T = {given(given a: A) as B}
3+
type T = {given(given a: A) as B} // error: refinement cannot be `given`

0 commit comments

Comments
 (0)