diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index a1ee2c539622..6ad2fca0cfd1 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -808,7 +808,7 @@ trait Checking { /** Check that type `tp` is stable. */ def checkStable(tp: Type, pos: SrcPos, kind: String)(using Context): Unit = - if !tp.isStable then report.error(NotAPath(tp, kind), pos) + if !tp.isStable && !tp.isErroneous then report.error(NotAPath(tp, kind), pos) /** Check that all type members of `tp` have realizable bounds */ def checkRealizableBounds(cls: Symbol, pos: SrcPos)(using Context): Unit = { @@ -904,7 +904,7 @@ trait Checking { private def checkLegalImportOrExportPath(path: Tree, kind: String)(using Context): Unit = { checkStable(path.tpe, path.srcPos, kind) if (!ctx.isAfterTyper) Checking.checkRealizable(path.tpe, path.srcPos) - if !isIdempotentExpr(path) then + if !isIdempotentExpr(path) && !path.tpe.isErroneous then report.error(em"import prefix is not a pure expression", path.srcPos) } diff --git a/tests/neg/i16653.check b/tests/neg/i16653.check new file mode 100644 index 000000000000..dd5c756f6f79 --- /dev/null +++ b/tests/neg/i16653.check @@ -0,0 +1,6 @@ +-- [E006] Not Found Error: tests/neg/i16653.scala:1:7 ------------------------------------------------------------------ +1 |import demo.implicits._ // error + | ^^^^ + | Not found: demo + | + | longer explanation available when compiling with `-explain` diff --git a/tests/neg/i16653.scala b/tests/neg/i16653.scala new file mode 100644 index 000000000000..3be14d1bc6bf --- /dev/null +++ b/tests/neg/i16653.scala @@ -0,0 +1,3 @@ +import demo.implicits._ // error +import demo._ +object Demo {} \ No newline at end of file diff --git a/tests/neg/i6056.scala b/tests/neg/i6056.scala index ad68616eecc2..8e39b0e4631c 100644 --- a/tests/neg/i6056.scala +++ b/tests/neg/i6056.scala @@ -2,6 +2,6 @@ object i0{ import i0.i0 // error // error def i0={ import _ // error - import // error + import } // error } \ No newline at end of file diff --git a/tests/neg/parser-stability-9.scala b/tests/neg/parser-stability-9.scala index aaa77f216f37..932f6a15ad52 100644 --- a/tests/neg/parser-stability-9.scala +++ b/tests/neg/parser-stability-9.scala @@ -1,2 +1,2 @@ -import // error +import // error \ No newline at end of file