File tree 3 files changed +38
-1
lines changed
compiler/src/dotty/tools/dotc/reporting
3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -1861,11 +1861,15 @@ import transform.SymUtils._
1861
1861
i " in ${conflicting.associatedFile}"
1862
1862
else if conflicting.owner == owner then " "
1863
1863
else i " in ${conflicting.owner}"
1864
+ private def note =
1865
+ if owner.is(Method ) || conflicting.is(Method ) then
1866
+ " \n\n Note that overloaded methods must all be defined in the same group of toplevel definitions"
1867
+ else " "
1864
1868
def msg =
1865
1869
if conflicting.isTerm != name.isTermName then
1866
1870
em " $name clashes with $conflicting$where; the two must be defined together "
1867
1871
else
1868
- em " $name is already defined as $conflicting$where"
1872
+ em " $name is already defined as $conflicting$where$note "
1869
1873
def explain = " "
1870
1874
1871
1875
class PackageNameAlreadyDefined (pkg : Symbol )(using Context ) extends NamingMsg (PackageNameAlreadyDefinedID ) {
Original file line number Diff line number Diff line change
1
+ -- [E161] Naming Error: tests/neg/i13089.scala:6:8 ---------------------------------------------------------------------
2
+ 6 | def fails : Unit = {} // error
3
+ | ^^^^^^^^^^^^^^^^^^^^^
4
+ | fails is already defined as method fails in tests/neg/i13089.scala
5
+ |
6
+ | Note that overloaded methods must all be defined in the same group of toplevel definitions
7
+ -- [E161] Naming Error: tests/neg/i13089.scala:8:6 ---------------------------------------------------------------------
8
+ 8 | def baz(x: String): Boolean = true // error
9
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10
+ | baz is already defined as method baz in tests/neg/i13089.scala
11
+ |
12
+ | Note that overloaded methods must all be defined in the same group of toplevel definitions
Original file line number Diff line number Diff line change
1
+ package pkg:
2
+
3
+ trait Bar
4
+
5
+ extension (bar : Bar )
6
+ def fails : Unit = {} // error
7
+
8
+ def baz (x : String ): Boolean = true // error
9
+
10
+ package pkg:
11
+
12
+ trait Foo
13
+ extension (foo : Foo )
14
+ def fails : Unit = {}
15
+ def works : Unit = {}
16
+
17
+ extension (bar : Bar )
18
+ def works : Unit = {}
19
+
20
+ def baz (x : Int ): Boolean = true
21
+
You can’t perform that action at this time.
0 commit comments