Skip to content

Commit 79705ca

Browse files
committed
Use ctx.kindString
1 parent b97ac37 commit 79705ca

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -552,22 +552,13 @@ trait Checking {
552552

553553
/** Check that inline is only used on valid trees */
554554
def checkInlineKeyword(tree: tpd.Tree)(implicit ctx: Context) = {
555-
def errorOn(what: String) =
556-
ctx.error("inlined keyword cannot be used on " + what, tree.pos)
557555
val sym = tree.symbol
556+
def error() = ctx.error("inlined keyword cannot be used on " + ctx.kindString(sym), tree.pos)
558557
if (sym is Inline) {
559558
tree match {
560-
case _: TypeDef =>
561-
if (!sym.isClass) errorOn("type")
562-
else if (sym.is(Trait)) errorOn("trait")
563-
else if (sym.is(Abstract)) errorOn("abstract class")
564-
else errorOn("class") // Remove this to allow inline classes
565-
case _: ValDef =>
566-
if (sym.is(Module)) errorOn("object")
567-
else if (sym.is(Mutable)) errorOn("var")
568-
else if (sym.is(Lazy)) errorOn("lazy val")
559+
case _: TypeDef => error()
560+
case _: ValDef if sym.is(Module) || sym.is(Mutable) || sym.is(Lazy) => error()
569561
case _ =>
570-
571562
}
572563
}
573564
}

0 commit comments

Comments
 (0)