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
254
254
ctx.compilationUnit.source.exists &&
255
255
sym != defn.SourceFileAnnot )
256
256
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
- }
265
257
tree
266
258
}
267
259
super .transform(tree)
@@ -322,8 +314,12 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
322
314
}
323
315
324
316
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
+ }
327
323
}
328
324
}
329
325
}
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