File tree 3 files changed +43
-0
lines changed
src/dotty/tools/dotc/transform
3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -275,6 +275,23 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
275
275
case tpe => tpe
276
276
}
277
277
)
278
+ case Import (expr, selectors) =>
279
+ val exprTpe = expr.tpe
280
+ def checkIdent (ident : Ident ): Unit = {
281
+ val name = ident.name.asTermName.encode
282
+ def isDottyLanguageFeature = { // TODO Add new language features to scala.language
283
+ exprTpe =:= defn.LanguageModuleClass .typeRef &&
284
+ name == nme.noAutoTupling // or any other new feature
285
+ }
286
+ if (name != nme.WILDCARD && ! exprTpe.member(name).exists && ! exprTpe.member(name.toTypeName).exists && ! isDottyLanguageFeature)
287
+ ctx.error(s " ${ident.name} is not a member of ${expr.show}" , ident.pos)
288
+ }
289
+ selectors.foreach {
290
+ case ident : Ident => checkIdent(ident)
291
+ case Thicket ((ident : Ident ) :: _) => checkIdent(ident)
292
+ case _ =>
293
+ }
294
+ super .transform(tree)
278
295
case tree =>
279
296
super .transform(tree)
280
297
}
Original file line number Diff line number Diff line change
1
+ import scala .idontexist // error
2
+ import scala .io .Idontexist // error
3
+
4
+ import scala .io
5
+ import io .Idontexist2 // error
6
+
7
+ import scala .io .{ AnsiColor , Idontexist3 } // error
8
+
9
+ import scala .io .{ Idontexist4 => Foo } // error
10
+ import scala .io .{ Idontexist5 => _ } // error
11
+
12
+ import scala .language .dynamics
13
+ import scala .language .noAutoTupling
14
+ import scala .language .idontexist // error
15
+
16
+ object Test
Original file line number Diff line number Diff line change @@ -15,4 +15,14 @@ scala> buf += xs
15
15
|
16
16
scala> buf ++= xs
17
17
res1: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3)
18
+ scala> import util.foo
19
+ -- Error: <console> ----------------------------------------------------------------------------------------------------
20
+ 8 |import util.foo
21
+ | ^^^
22
+ | foo is not a member of util
23
+ scala> import util.foo.bar
24
+ -- [E008] Member Not Found Error: <console> ----------------------------------------------------------------------------
25
+ 8 |import util.foo.bar
26
+ | ^^^^^^^^
27
+ | value `foo` is not a member of util.type - did you mean `util.Left`?
18
28
scala> :quit
You can’t perform that action at this time.
0 commit comments