diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index f3035ee5c249..6a12b69474a2 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -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 diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 426f1487dcf8..12bab777218f 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -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) diff --git a/tests/neg/i8632.check b/tests/neg/i8632.check new file mode 100644 index 000000000000..bc369be871dd --- /dev/null +++ b/tests/neg/i8632.check @@ -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 diff --git a/tests/neg/i8632.scala b/tests/neg/i8632.scala new file mode 100644 index 000000000000..19615b489dd4 --- /dev/null +++ b/tests/neg/i8632.scala @@ -0,0 +1,3 @@ +object Test { + Nil.toString.foo(1) // error +} \ No newline at end of file