File tree Expand file tree Collapse file tree 2 files changed +7
-11
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -254,14 +254,6 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
254254 ctx.compilationUnit.source.exists &&
255255 sym != defn.SourceFileAnnot )
256256 sym.addAnnotation(Annotation .makeSourceFile(ctx.compilationUnit.source.file.path))
257- if (sym.is(Case )) {
258- tree.rhs match {
259- case rhs : Template =>
260- for (param <- rhs.constr.vparamss.head if param.symbol.is(Unused ))
261- ctx.error(" First parameter list of case classes may not contain `unused` parameters" , param.pos)
262- case _ =>
263- }
264- }
265257 tree
266258 }
267259 super .transform(tree)
@@ -322,8 +314,12 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
322314 }
323315
324316 private def checkNotUnused (tree : RefTree )(implicit ctx : Context ): Unit = {
325- if (tree.symbol.is(Unused ) && ! ctx.mode.is(Mode .Type ))
326- ctx.error(i " `unused` value $tree can only be used as unused arguments " , tree.pos)
317+ if (tree.symbol.is(Unused ) && ! ctx.mode.is(Mode .Type )) {
318+ val msg =
319+ if (tree.symbol.is(CaseAccessor )) " First parameter list of case class may not contain `unused` parameters"
320+ else i " `unused` value $tree can only be used as unused arguments "
321+ ctx.error(msg, tree.pos)
322+ }
327323 }
328324 }
329325}
Original file line number Diff line number Diff line change 1- case class Foo1 (unused x : Int ) // error TODO add custom error message
1+ case class Foo1 (unused x : Int ) // error
You can’t perform that action at this time.
0 commit comments