File tree 3 files changed +19
-21
lines changed
test/dotty/tools/dotc/reporting
3 files changed +19
-21
lines changed Original file line number Diff line number Diff line change @@ -1371,27 +1371,25 @@ object messages {
1371
1371
| """
1372
1372
}
1373
1373
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 )
1375
1375
extends Message (MethodDoesNotTakeParametersId ) {
1376
- private val more = tree match {
1377
- case Apply (_, _) => " more"
1378
- case _ => " "
1379
- }
1376
+ val kind = " Reference"
1380
1377
1381
- val msg = hl " ${err.refStr(methPartType)} does not take $more parameters "
1378
+ def methodSymbol = tpd.methPart(tree).symbol
1382
1379
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
+ }
1384
1384
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 " "
1391
1390
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
+ }
1395
1393
1396
1394
}
1397
1395
Original file line number Diff line number Diff line change @@ -2133,7 +2133,7 @@ class Typer extends Namer
2133
2133
else
2134
2134
tree
2135
2135
case _ => tryInsertApplyOrImplicit(tree, pt, locked) {
2136
- errorTree(tree, MethodDoesNotTakeParameters (tree, methPart(tree).tpe)(err ))
2136
+ errorTree(tree, MethodDoesNotTakeParameters (tree))
2137
2137
}
2138
2138
}
2139
2139
Original file line number Diff line number Diff line change @@ -347,10 +347,10 @@ class ErrorMessagesTests extends ErrorMessagesTest {
347
347
implicit val ctx : Context = ictx
348
348
349
349
assertMessageCount(1 , messages)
350
- val MethodDoesNotTakeParameters (tree, methodPart) :: Nil = messages
350
+ val msg @ MethodDoesNotTakeParameters (tree) = messages.head
351
351
352
352
assertEquals(" Scope.foo" , tree.show)
353
- assertEquals(" => Unit(Scope. foo) " , methodPart .show)
353
+ assertEquals(" method foo" , msg.methodSymbol .show)
354
354
}
355
355
356
356
@ Test def methodDoesNotTakeMorePrameters =
@@ -366,10 +366,10 @@ class ErrorMessagesTests extends ErrorMessagesTest {
366
366
implicit val ctx : Context = ictx
367
367
368
368
assertMessageCount(1 , messages)
369
- val MethodDoesNotTakeParameters (tree, methodPart) :: Nil = messages
369
+ val msg @ MethodDoesNotTakeParameters (tree) = messages.head
370
370
371
371
assertEquals(" Scope.foo(1)" , tree.show)
372
- assertEquals(" ((a: Int): Unit)(Scope. foo) " , methodPart .show)
372
+ assertEquals(" method foo" , msg.methodSymbol .show)
373
373
}
374
374
375
375
@ Test def ambiugousOverloadWithWildcard =
You can’t perform that action at this time.
0 commit comments