Skip to content

Commit

Permalink
Suppress follow-on errors for erroneous import qualifiers (#16658)
Browse files Browse the repository at this point in the history
Fixes #16653
  • Loading branch information
bishabosha authored Jan 12, 2023
2 parents 769cf87 + 0681d33 commit 2127b89
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,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 = {
Expand Down Expand Up @@ -910,7 +910,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)
}

Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i16653.check
Original file line number Diff line number Diff line change
@@ -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`
3 changes: 3 additions & 0 deletions tests/neg/i16653.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demo.implicits._ // error
import demo._
object Demo {}
2 changes: 1 addition & 1 deletion tests/neg/i6056.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ object i0{
import i0.i0 // error // error
def i0={
import _ // error
import // error
import
} // error
}
2 changes: 1 addition & 1 deletion tests/neg/parser-stability-9.scala
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import // error
import
// error

0 comments on commit 2127b89

Please sign in to comment.