@@ -550,23 +550,18 @@ trait ContextErrors {
550550 def ModuleUsingCompanionClassDefaultArgsErrror (tree : Tree ) =
551551 NormalTypeError (tree, " module extending its companion class cannot use default constructor arguments" )
552552
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+ }"
565561 }
566-
567- " not enough arguments for " + treeSymTypeMsg(fun) + suffix
562+ s " not enough arguments for ${ treeSymTypeMsg(fun) }$suffix"
568563 }
569- NormalTypeError (tree, notEnoughArgumentsMsg(fun0, missing0) )
564+ NormalTypeError (tree, notEnoughArgumentsMsg)
570565 }
571566
572567 // doTypedApply - patternMode
@@ -632,12 +627,16 @@ trait ContextErrors {
632627
633628 // adapt
634629 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
635635 val message =
636636 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+ }"""
641640 issueNormalTypeError(tree, message)
642641 setError(tree)
643642 }
0 commit comments