diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 07c6753892ab..8ad6cee9e2af 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -14,7 +14,7 @@ import util.Positions._ import Decorators._ import config.Printers.typr import Symbols._, TypeUtils._, SymUtils._ -import reporting.diagnostic.messages.SuperCallsNotAllowedInline +import reporting.diagnostic.messages.{NotAMember, SuperCallsNotAllowedInline} /** A macro transform that runs immediately after typer and that performs the following functions: * @@ -272,7 +272,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase def checkIdent(ident: untpd.Ident): Unit = { val name = ident.name.asTermName if (name != nme.WILDCARD && !exprTpe.member(name).exists && !exprTpe.member(name.toTypeName).exists) - ctx.error(s"${ident.name} is not a member of ${expr.show}", ident.pos) + ctx.error(NotAMember(exprTpe, name, "value"), ident.pos) } selectors.foreach { case ident: untpd.Ident => checkIdent(ident) diff --git a/compiler/test-resources/repl/importFromObj b/compiler/test-resources/repl/importFromObj index ca59758ab53d..2bc88abd7693 100644 --- a/compiler/test-resources/repl/importFromObj +++ b/compiler/test-resources/repl/importFromObj @@ -15,7 +15,7 @@ val res0: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3) scala> import util.foo 1 | import util.foo | ^^^ - | foo is not a member of util + | value `foo` is not a member of util - did you mean `util.Left`? scala> import util.foo.bar 1 | import util.foo.bar | ^^^^^^^^