@@ -550,23 +550,18 @@ trait ContextErrors {
550
550
def ModuleUsingCompanionClassDefaultArgsErrror (tree : Tree ) =
551
551
NormalTypeError (tree, " module extending its companion class cannot use default constructor arguments" )
552
552
553
- def NotEnoughArgsError (tree : Tree , fun0 : Tree , missing0 : List [Symbol ]) = {
554
- def notEnoughArgumentsMsg (fun : Tree , missing : List [Symbol ]) = {
555
- val suffix = {
556
- if (missing.isEmpty) " "
557
- else {
558
- val keep = missing take 3 map (_.name)
559
- " .\n Unspecified value parameter%s %s" .format(
560
- if (missing.tail.isEmpty) " " else " s" ,
561
- if ((missing drop 3 ).nonEmpty) (keep :+ " ..." ).mkString(" , " )
562
- else keep.mkString(" " , " , " , " ." )
563
- )
564
- }
553
+ def NotEnoughArgsError (tree : Tree , fun : Tree , missing : List [Symbol ]) = {
554
+ val notEnoughArgumentsMsg = {
555
+ val suffix = if (missing.isEmpty) " " else {
556
+ val keep = missing take 3 map (_.name)
557
+ val ess = if (missing.tail.isEmpty) " " else " s"
558
+ f " .%nUnspecified value parameter $ess ${
559
+ keep.mkString(" " , " , " , if ((missing drop 3 ).nonEmpty) " ..." else " ." )
560
+ }"
565
561
}
566
-
567
- " not enough arguments for " + treeSymTypeMsg(fun) + suffix
562
+ s " not enough arguments for ${ treeSymTypeMsg(fun) }$suffix"
568
563
}
569
- NormalTypeError (tree, notEnoughArgumentsMsg(fun0, missing0) )
564
+ NormalTypeError (tree, notEnoughArgumentsMsg)
570
565
}
571
566
572
567
// doTypedApply - patternMode
@@ -632,12 +627,16 @@ trait ContextErrors {
632
627
633
628
// adapt
634
629
def MissingArgsForMethodTpeError (tree : Tree , meth : Symbol ) = {
630
+ val f = meth.name
631
+ val paf = s " $f( ${ meth.asMethod.paramLists map (_ map (_ => " _" ) mkString " ," ) mkString " )(" }) "
632
+ val advice = s """
633
+ |Unapplied methods are only converted to functions when a function type is expected.
634
+ |You can make this conversion explicit by writing ` $f _` or ` $paf` instead of ` $f`. """ .stripMargin
635
635
val message =
636
636
if (meth.isMacro) MacroTooFewArgumentListsMessage
637
- else " missing arguments for " + meth.fullLocationString + (
638
- if (meth.isConstructor) " "
639
- else " ;\n follow this method with `_' if you want to treat it as a partially applied function"
640
- )
637
+ else s """ missing argument list for ${meth.fullLocationString}${
638
+ if (! meth.isConstructor) advice else " "
639
+ }"""
641
640
issueNormalTypeError(tree, message)
642
641
setError(tree)
643
642
}
0 commit comments