diff options
author | Nicolas Stucki <nicolas.stucki@gmail.com> | 2016-08-26 10:07:19 +0200 |
---|---|---|
committer | Nicolas Stucki <nicolas.stucki@gmail.com> | 2016-10-21 09:16:32 +0200 |
commit | a8136fff2cc2f7c75f0a6253db79c3e339f56c98 (patch) | |
tree | 8c99fb1e84d06585891bcd9444242a0fcff3aa86 /src/dotty/tools/dotc/transform/PostTyper.scala | |
parent | 6070cce6a7887b6b3c65421bf0c37c92aec3182e (diff) | |
download | dotty-a8136fff2cc2f7c75f0a6253db79c3e339f56c98.tar.gz dotty-a8136fff2cc2f7c75f0a6253db79c3e339f56c98.tar.bz2 dotty-a8136fff2cc2f7c75f0a6253db79c3e339f56c98.zip |
Fix #1286: Error on inexistent imports that are not used.
This commit also fixes #1583.
Diffstat (limited to 'src/dotty/tools/dotc/transform/PostTyper.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/PostTyper.scala | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/transform/PostTyper.scala b/src/dotty/tools/dotc/transform/PostTyper.scala index 51851a589..12d48d98e 100644 --- a/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/src/dotty/tools/dotc/transform/PostTyper.scala @@ -275,6 +275,19 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran case tpe => tpe } ) + case Import(expr, selectors) => + val exprTpe = expr.tpe + def checkIdent(ident: Ident): Unit = { + val name = ident.name.asTermName.encode + if (name != nme.WILDCARD && !exprTpe.member(name).exists && !exprTpe.member(name.toTypeName).exists) + ctx.error(s"${ident.name} is not a member of ${expr.show}", ident.pos) + } + selectors.foreach { + case ident: Ident => checkIdent(ident) + case Thicket((ident: Ident) :: _) => checkIdent(ident) + case _ => + } + super.transform(tree) case tree => super.transform(tree) } |