Skip to content

Commit 3f1b92c

Browse files
committed
Error message for none of the overloaded...
This error message allows us to keep track of all the possible alternatives.
1 parent 1bafe31 commit 3f1b92c

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ public enum ErrorMessageID {
140140
TraitCompanionWithMutableStaticID,
141141
LazyStaticFieldID,
142142
StaticOverridingNonStaticMembersID,
143-
OverloadInRefinementID
143+
OverloadInRefinementID,
144+
NoMatchingOverloadID
144145
;
145146

146147
public int errorNumber() {

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import dotty.tools.dotc.ast.Trees
2323
import dotty.tools.dotc.config.ScalaVersion
2424
import dotty.tools.dotc.core.Flags._
2525
import dotty.tools.dotc.core.SymDenotations.SymDenotation
26+
import dotty.tools.dotc.typer.ErrorReporting.Errors
2627
import scala.util.control.NonFatal
2728

2829
object messages {
@@ -1382,7 +1383,7 @@ object messages {
13821383
}
13831384

13841385
case class AmbiguousOverload(tree: tpd.Tree, alts: List[SingleDenotation], pt: Type)(
1385-
err: typer.ErrorReporting.Errors)(
1386+
err: Errors)(
13861387
implicit ctx: Context)
13871388
extends Message(AmbiguousOverloadID) {
13881389

@@ -1463,7 +1464,7 @@ object messages {
14631464
}
14641465

14651466
case class DoesNotConformToBound(tpe: Type, which: String, bound: Type)(
1466-
err: typer.ErrorReporting.Errors)(implicit ctx: Context)
1467+
err: Errors)(implicit ctx: Context)
14671468
extends Message(DoesNotConformToBoundID) {
14681469
val msg: String = hl"Type argument ${tpe} does not conform to $which bound $bound ${err.whyNoMatchStr(tpe, bound)}"
14691470
val kind: String = "Type Mismatch"
@@ -2179,4 +2180,14 @@ object messages {
21792180
hl"""The refinement `$rsym` introduces an overloaded definition.
21802181
|Refinements cannot contain overloaded definitions.""".stripMargin
21812182
}
2183+
2184+
case class NoMatchingOverload(alternatives: List[SingleDenotation], pt: Type)(
2185+
err: Errors)(implicit val ctx: Context)
2186+
extends Message(NoMatchingOverloadID) {
2187+
val msg: String =
2188+
hl"""None of the ${err.overloadedAltsStr(alternatives)}
2189+
|match ${err.expectedTypeStr(pt)}"""
2190+
val kind: String = "Type Mismatch"
2191+
val explanation: String = ""
2192+
}
21822193
}

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,9 +2228,7 @@ class Typer extends Namer
22282228
readaptSimplified(tree.withType(alt))
22292229
case Nil =>
22302230
def noMatches =
2231-
errorTree(tree,
2232-
em"""none of the ${err.overloadedAltsStr(altDenots)}
2233-
|match ${err.expectedTypeStr(pt)}""")
2231+
errorTree(tree, NoMatchingOverload(altDenots, pt)(err))
22342232
def hasEmptyParams(denot: SingleDenotation) = denot.info.paramInfoss == ListOfNil
22352233
pt match {
22362234
case pt: FunProto =>

0 commit comments

Comments
 (0)