From 9830175e50cf6bb12f13580054c1340f2b9e45fa Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 18 Mar 2019 10:57:52 +0100 Subject: [PATCH] Fix #6056: Handle illegal input when determining import infos. --- compiler/src/dotty/tools/dotc/typer/ImportInfo.scala | 6 +++--- tests/neg/i6056.scala | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 tests/neg/i6056.scala 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