Skip to content

Commit 2127b89

Browse files
authored
Suppress follow-on errors for erroneous import qualifiers (#16658)
Fixes #16653
2 parents 769cf87 + 0681d33 commit 2127b89

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ trait Checking {
810810

811811
/** Check that type `tp` is stable. */
812812
def checkStable(tp: Type, pos: SrcPos, kind: String)(using Context): Unit =
813-
if !tp.isStable then report.error(NotAPath(tp, kind), pos)
813+
if !tp.isStable && !tp.isErroneous then report.error(NotAPath(tp, kind), pos)
814814

815815
/** Check that all type members of `tp` have realizable bounds */
816816
def checkRealizableBounds(cls: Symbol, pos: SrcPos)(using Context): Unit = {
@@ -910,7 +910,7 @@ trait Checking {
910910
private def checkLegalImportOrExportPath(path: Tree, kind: String)(using Context): Unit = {
911911
checkStable(path.tpe, path.srcPos, kind)
912912
if (!ctx.isAfterTyper) Checking.checkRealizable(path.tpe, path.srcPos)
913-
if !isIdempotentExpr(path) then
913+
if !isIdempotentExpr(path) && !path.tpe.isErroneous then
914914
report.error(em"import prefix is not a pure expression", path.srcPos)
915915
}
916916

tests/neg/i16653.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- [E006] Not Found Error: tests/neg/i16653.scala:1:7 ------------------------------------------------------------------
2+
1 |import demo.implicits._ // error
3+
| ^^^^
4+
| Not found: demo
5+
|
6+
| longer explanation available when compiling with `-explain`

tests/neg/i16653.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import demo.implicits._ // error
2+
import demo._
3+
object Demo {}

tests/neg/i6056.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ object i0{
22
import i0.i0 // error // error
33
def i0={
44
import _ // error
5-
import // error
5+
import
66
} // error
77
}

tests/neg/parser-stability-9.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
import // error
1+
import
22
// error

0 commit comments

Comments
 (0)