File tree Expand file tree Collapse file tree 3 files changed +19
-21
lines changed
test/dotty/tools/dotc/reporting Expand file tree Collapse file tree 3 files changed +19
-21
lines changed Original file line number Diff line number Diff line change @@ -1371,27 +1371,25 @@ object messages {
13711371 | """
13721372 }
13731373
1374- case class MethodDoesNotTakeParameters (tree : tpd.Tree , methPartType : Types . Type )( err : typer. ErrorReporting . Errors )(implicit ctx : Context )
1374+ case class MethodDoesNotTakeParameters (tree : tpd.Tree )(implicit ctx : Context )
13751375 extends Message (MethodDoesNotTakeParametersId ) {
1376- private val more = tree match {
1377- case Apply (_, _) => " more"
1378- case _ => " "
1379- }
1376+ val kind = " Reference"
13801377
1381- val msg = hl " ${err.refStr(methPartType)} does not take $more parameters "
1378+ def methodSymbol = tpd.methPart(tree).symbol
13821379
1383- val kind = " Reference"
1380+ val msg = {
1381+ val more = if (tree.isInstanceOf [tpd.Apply ]) " more" else " "
1382+ hl " ${methodSymbol.showLocated} does not take $more parameters "
1383+ }
13841384
1385- private val noParameters = if (methPartType.widenSingleton.isInstanceOf [ExprType ])
1386- hl """ |As ${err.refStr(methPartType)} is defined without parenthesis, you may
1387- |not use any at call-site, either.
1388- | """
1389- else
1390- " "
1385+ val explanation = {
1386+ val isNullary = methodSymbol.info.isInstanceOf [ExprType ]
1387+ val addendum =
1388+ if (isNullary) " \n Nullary methods may not be called with parenthesis"
1389+ else " "
13911390
1392- val explanation =
1393- s """ |You have specified more parameter lists as defined in the method definition(s).
1394- | $noParameters""" .stripMargin
1391+ " You have specified more parameter lists as defined in the method definition(s)." + addendum
1392+ }
13951393
13961394 }
13971395
Original file line number Diff line number Diff line change @@ -2133,7 +2133,7 @@ class Typer extends Namer
21332133 else
21342134 tree
21352135 case _ => tryInsertApplyOrImplicit(tree, pt, locked) {
2136- errorTree(tree, MethodDoesNotTakeParameters (tree, methPart(tree).tpe)(err ))
2136+ errorTree(tree, MethodDoesNotTakeParameters (tree))
21372137 }
21382138 }
21392139
Original file line number Diff line number Diff line change @@ -347,10 +347,10 @@ class ErrorMessagesTests extends ErrorMessagesTest {
347347 implicit val ctx : Context = ictx
348348
349349 assertMessageCount(1 , messages)
350- val MethodDoesNotTakeParameters (tree, methodPart) :: Nil = messages
350+ val msg @ MethodDoesNotTakeParameters (tree) = messages.head
351351
352352 assertEquals(" Scope.foo" , tree.show)
353- assertEquals(" => Unit(Scope. foo) " , methodPart .show)
353+ assertEquals(" method foo" , msg.methodSymbol .show)
354354 }
355355
356356 @ Test def methodDoesNotTakeMorePrameters =
@@ -366,10 +366,10 @@ class ErrorMessagesTests extends ErrorMessagesTest {
366366 implicit val ctx : Context = ictx
367367
368368 assertMessageCount(1 , messages)
369- val MethodDoesNotTakeParameters (tree, methodPart) :: Nil = messages
369+ val msg @ MethodDoesNotTakeParameters (tree) = messages.head
370370
371371 assertEquals(" Scope.foo(1)" , tree.show)
372- assertEquals(" ((a: Int): Unit)(Scope. foo) " , methodPart .show)
372+ assertEquals(" method foo" , msg.methodSymbol .show)
373373 }
374374
375375 @ Test def ambiugousOverloadWithWildcard =
You can’t perform that action at this time.
0 commit comments