Skip to content

Commit 74f8597

Browse files
committed
Fix #8632: Reveal "not found" message more often
If a creator expression is tried, we want to make sure we see a "not found" message, so that we fall back in this case to reporting the original select failure. To this purpose - we check for stable path prefixes after doing the selection proper - we recognize leading not found messages also if they are following by other messages
1 parent 3eafc18 commit 74f8597

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,13 +1060,14 @@ trait Applications extends Compatibility {
10601060
tree
10611061
}
10621062

1063-
/** Does `state` contain a single "NotAMember" or "MissingIdent" message as
1064-
* pending error message that says `$memberName is not a member of ...` or
1065-
* `Not found: $memberName`? If memberName is empty, any name will do.
1063+
/** Does `state` contain a "NotAMember" or "MissingIdent" message as
1064+
* first pending error message? That message would be
1065+
* `$memberName is not a member of ...` or `Not found: $memberName`.
1066+
* If memberName is empty, any name will do.
10661067
*/
10671068
def saysNotFound(state: TyperState, memberName: Name)(using Context): Boolean =
10681069
state.reporter.pendingMessages match
1069-
case dia :: Nil =>
1070+
case dia :: _ =>
10701071
dia.msg match
10711072
case msg: NotFoundMsg => memberName.isEmpty || msg.name == memberName
10721073
case _ => false

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,11 +490,11 @@ class Typer extends Namer
490490
case _ => app
491491
}
492492
case qual =>
493-
if (tree.name.isTypeName) checkStable(qual.tpe, qual.sourcePos, "type prefix")
494493
val select = assignType(cpy.Select(tree)(qual, tree.name), qual)
495-
496494
val select1 = toNotNullTermRef(select, pt)
497495

496+
if (tree.name.isTypeName) checkStable(qual.tpe, qual.sourcePos, "type prefix")
497+
498498
if (select1.tpe ne TryDynamicCallType) ConstFold(checkStableIdentPattern(select1, pt))
499499
else if (pt.isInstanceOf[FunOrPolyProto] || pt == AssignProto) select1
500500
else typedDynamicSelect(tree, Nil, pt)

tests/neg/i8632.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
Nil.toString.foo(1)
3+
}

0 commit comments

Comments
 (0)