Skip to content

Commit 7ed8626

Browse files
committed
Massage the message
1 parent 7e1f68a commit 7ed8626

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Diff for: compiler/src/dotty/tools/dotc/reporting/messages.scala

+4-2
Original file line numberDiff line numberDiff line change
@@ -2520,8 +2520,10 @@ class ExtensionHasDefault(method: Symbol)(using Context)
25202520
def msg(using Context) =
25212521
i"""Extension method ${hl(method.name.toString)} should not have a default argument for its receiver."""
25222522
def explain(using Context) =
2523-
i"""Although extensions are ordinary methods, they must be invoked as a selection.
2524-
|Therefore, the receiver cannot be omitted. A default argument for that parameter would never be used."""
2523+
i"""Although extensions are ordinary methods, when they are invoked as a selection,
2524+
|the receiver cannot be omitted. A default argument for that parameter would never be used.
2525+
|An extension method can be invoked as a regular method, but if that is the intended usage,
2526+
|it should not be defined as an extension."""
25252527

25262528
class TraitCompanionWithMutableStatic()(using Context)
25272529
extends SyntaxMsg(TraitCompanionWithMutableStaticID) {

Diff for: tests/warn/i12460.check

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
|---------------------------------------------------------------------------------------------------------------------
66
| Explanation (enabled by `-explain`)
77
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
8-
| Although extensions are ordinary methods, they must be invoked as a selection.
9-
| Therefore, the receiver cannot be omitted. A default argument for that parameter would never be used.
8+
| Although extensions are ordinary methods, when they are invoked as a selection,
9+
| the receiver cannot be omitted. A default argument for that parameter would never be used.
10+
| An extension method can be invoked as a regular method, but if that is the intended usage,
11+
| it should not be defined as an extension.
1012
---------------------------------------------------------------------------------------------------------------------
1113
-- [E208] Potential Issue Warning: tests/warn/i12460.scala:5:37 --------------------------------------------------------
1214
5 |extension (using String)(s: String = "hello, world") def revert = s.reverse.toUpperCase // warn
@@ -15,6 +17,8 @@
1517
|---------------------------------------------------------------------------------------------------------------------
1618
| Explanation (enabled by `-explain`)
1719
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
18-
| Although extensions are ordinary methods, they must be invoked as a selection.
19-
| Therefore, the receiver cannot be omitted. A default argument for that parameter would never be used.
20+
| Although extensions are ordinary methods, when they are invoked as a selection,
21+
| the receiver cannot be omitted. A default argument for that parameter would never be used.
22+
| An extension method can be invoked as a regular method, but if that is the intended usage,
23+
| it should not be defined as an extension.
2024
---------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)