@@ -318,4 +318,66 @@ object messages {
318
318
| $code2
319
319
| """ .stripMargin
320
320
}
321
+
322
+ case class TopLevelImplicitClass (cdef : untpd.TypeDef )(implicit ctx : Context )
323
+ extends Message (10 ) {
324
+ val kind = " Syntax"
325
+
326
+ val msg = hl """ |An ${" implicit class" } may not be top-level """
327
+
328
+ val explanation =
329
+ hl """ |implicit class are not allowed to be defined at the top-level.
330
+ |
331
+ |Declare ${cdef.name} inside of an ${" object" } or ${" package object" }
332
+ |then import the members of the object at the use site if needed, for example:
333
+ |
334
+ |package object Implicits {
335
+ | implicit class ${cdef.name}...
336
+ |}
337
+ |
338
+ |import Implicits. ${cdef.name}""" .stripMargin
339
+ }
340
+
341
+ case class ImplicitCaseClass (cdef : untpd.TypeDef )(implicit ctx : Context )
342
+ extends Message (11 ) {
343
+ val kind = " Syntax"
344
+
345
+ val msg = hl """ |A ${" case class" } may not be defined as ${" implicit" }"""
346
+
347
+ val explanation =
348
+ hl """ |implicit classes may not be case classes. Instead use a plain class:
349
+ |
350
+ |implicit class ${cdef.name}... """ .stripMargin
351
+ }
352
+
353
+ case class ObjectMayNotHaveSelfType (mdef : untpd.ModuleDef )(implicit ctx : Context )
354
+ extends Message (12 ) {
355
+ val kind = " Syntax"
356
+
357
+ val msg = hl """ |An ${" object" } must not have a ${" self type" }"""
358
+
359
+ val explanation =
360
+ hl """ |objects ${mdef.name} must not have a ${" self type" }:
361
+ |
362
+ |Consider these alternative solutions:
363
+ | Extend the object with the desired type
364
+ | Use a trait or a class instead of an object """ .stripMargin
365
+ }
366
+
367
+ case class TupleTooLong (ts : List [untpd.Tree ])(implicit ctx : Context )
368
+ extends Message (13 ) {
369
+ import Definitions .MaxTupleArity
370
+ val kind = " Syntax"
371
+
372
+ val msg = hl """ |A ${" tuple" } cannot have more than ${MaxTupleArity } members """
373
+
374
+ val explanation = {
375
+ val members = ts.map(_.showSummary).grouped(MaxTupleArity )
376
+ val nestedRepresentation = members.map(_.mkString(" , " )).mkString(" )(" )
377
+ hl """ |This restriction will be removed in the future.
378
+ |Currently it is possible to use nested tuples when more than ${MaxTupleArity } are needed, for example:
379
+ |
380
+ | (( ${nestedRepresentation})) """ .stripMargin
381
+ }
382
+ }
321
383
}
0 commit comments