diff --git a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala index 488d68ce5449..0cbed69905b5 100644 --- a/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala +++ b/compiler/src/dotty/tools/dotc/typer/ImportInfo.scala @@ -47,9 +47,9 @@ class ImportInfo(symf: Context => Symbol, val selectors: List[untpd.Tree], private[this] var mySym: Symbol = _ /** The (TermRef) type of the qualifier of the import clause */ - def site(implicit ctx: Context): Type = { - val ImportType(expr) = sym.info - expr.tpe + def site(implicit ctx: Context): Type = sym.info match { + case ImportType(expr) => expr.tpe + case _ => NoType } /** The names that are excluded from any wildcard import */ diff --git a/tests/neg/i6056.scala b/tests/neg/i6056.scala new file mode 100644 index 000000000000..23682eb5c371 --- /dev/null +++ b/tests/neg/i6056.scala @@ -0,0 +1,7 @@ +object i0{ + import i0.i0 // error + def i0={ + import _ // error // error + import // error + } // error +} \ No newline at end of file