Skip to content

Commit b6e1090

Browse files
author
Jendrik Wenke
committed
remove Signature.NoMatch from cases because it should not happen
1 parent 4df133e commit b6e1090

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,9 +2086,9 @@ object messages {
20862086
val details = if (decl.isRealMethod && previousDecl.isRealMethod) {
20872087
// compare the signatures when both symbols represent methods
20882088
decl.asTerm.signature.matchDegree(previousDecl.asTerm.signature) match {
2089-
case Signature.NoMatch => ""
2089+
/* case Signature.NoMatch => // can't happen because decl.matches(previousDecl) is checked before reporting this error */
20902090
case Signature.ParamMatch => "\nOverloads with equal parameter types but different return types are not allowed."
2091-
case Signature.FullMatch => "\nThe definitions have the same signature after erasure."
2091+
case _ /* Signature.FullMatch */ => "\nThe definitions have the same signature after erasure."
20922092
}
20932093
} else ""
20942094
hl"${decl.showLocated} is already defined as ${previousDecl.showDcl} in line ${previousDecl.pos.line + 1}." + details

tests/neg/doubleDefinition.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,10 @@ class Test17 {
124124
val foo = ""
125125
}
126126
}
127+
128+
// no error when overloading
129+
130+
class Test18 {
131+
def foo(a: A) = 1
132+
def foo(b: B) = 1
133+
}

0 commit comments

Comments
 (0)