File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed
compiler/src/dotty/tools/dotc/reporting Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -1861,11 +1861,15 @@ import transform.SymUtils._
18611861 i " in ${conflicting.associatedFile}"
18621862 else if conflicting.owner == owner then " "
18631863 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 " "
18641868 def msg =
18651869 if conflicting.isTerm != name.isTermName then
18661870 em " $name clashes with $conflicting$where; the two must be defined together "
18671871 else
1868- em " $name is already defined as $conflicting$where"
1872+ em " $name is already defined as $conflicting$where$note "
18691873 def explain = " "
18701874
18711875 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