Skip to content

Commit 3849709

Browse files
committed
Fix #10082: show friendly error message related to type inference
The type `site` might be an uninitialized type variable, but is initialized when we display the error message. It results in confusing error message as in #10082. We take a string representation of the type `site` when the error object is created and use that in the message message. Now the error message is more sensible: -- [E008] Not Found Error: tests/neg/i10082.scala:7:30 ------------------------- 7 |def Test = List(1).map(fun(it + 1)) | ^^^^ | value + is not a member of T | | where: T is a type variable with constraint >: Int | , but could be made available as an extension method.
1 parent a5f8e2b commit 3849709

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ import transform.SymUtils._
286286
extends NotFoundMsg(NotAMemberID) {
287287
//println(i"site = $site, decls = ${site.decls}, source = ${site.typeSymbol.sourceFile}") //DEBUG
288288

289+
val widenedName: String = ex"${site.widen}"
290+
289291
def msg = {
290292
import core.Flags._
291293
val maxDist = 3 // maximal number of differences to be considered for a hint
@@ -348,7 +350,7 @@ import transform.SymUtils._
348350
s" - did you mean $siteName.$n?$enumClause"
349351
case Nil => prefixEnumClause("")
350352

351-
ex"$selected $name is not a member of ${site.widen}$finalAddendum"
353+
ex"$selected $name is not a member of $widenedName$finalAddendum"
352354
}
353355

354356
def explain = ""

0 commit comments

Comments
 (0)