Skip to content

Fix #8632: Reveal "not found" message more often #8638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1060,13 +1060,14 @@ trait Applications extends Compatibility {
tree
}

/** Does `state` contain a single "NotAMember" or "MissingIdent" message as
* pending error message that says `$memberName is not a member of ...` or
* `Not found: $memberName`? If memberName is empty, any name will do.
/** Does `state` contain a "NotAMember" or "MissingIdent" message as
* first pending error message? That message would be
* `$memberName is not a member of ...` or `Not found: $memberName`.
* If memberName is empty, any name will do.
*/
def saysNotFound(state: TyperState, memberName: Name)(using Context): Boolean =
state.reporter.pendingMessages match
case dia :: Nil =>
case dia :: _ =>
dia.msg match
case msg: NotFoundMsg => memberName.isEmpty || msg.name == memberName
case _ => false
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -490,11 +490,11 @@ class Typer extends Namer
case _ => app
}
case qual =>
if (tree.name.isTypeName) checkStable(qual.tpe, qual.sourcePos, "type prefix")
val select = assignType(cpy.Select(tree)(qual, tree.name), qual)

val select1 = toNotNullTermRef(select, pt)

if (tree.name.isTypeName) checkStable(qual.tpe, qual.sourcePos, "type prefix")

if (select1.tpe ne TryDynamicCallType) ConstFold(checkStableIdentPattern(select1, pt))
else if (pt.isInstanceOf[FunOrPolyProto] || pt == AssignProto) select1
else typedDynamicSelect(tree, Nil, pt)
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i8632.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- [E008] Not Found Error: tests/neg/i8632.scala:2:15 ------------------------------------------------------------------
2 | Nil.toString.foo(1) // error
| ^^^^^^^^^^^^^^^^
| value foo is not a member of String
3 changes: 3 additions & 0 deletions tests/neg/i8632.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Test {
Nil.toString.foo(1) // error
}