diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 20 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 6 | ||||
-rw-r--r-- | test/files/buildmanager/t2792/t2792.check | 3 | ||||
-rw-r--r-- | test/files/neg/t5821.check | 4 | ||||
-rw-r--r-- | test/files/neg/t5821.scala | 8 | ||||
-rw-r--r-- | test/files/neg/t639.check | 5 |
6 files changed, 35 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index b4f42a5033..5c0873a7c5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -1306,14 +1306,18 @@ trait Namers extends MethodSynthesis { if (expr1.symbol != null && expr1.symbol.isRootPackage) RootImportError(tree) - val newImport = treeCopy.Import(tree, expr1, selectors).asInstanceOf[Import] - checkSelectors(newImport) - transformed(tree) = newImport - // copy symbol and type attributes back into old expression - // so that the structure builder will find it. - expr.symbol = expr1.symbol - expr.tpe = expr1.tpe - ImportType(expr1) + if (expr1.isErrorTyped) + ErrorType + else { + val newImport = treeCopy.Import(tree, expr1, selectors).asInstanceOf[Import] + checkSelectors(newImport) + transformed(tree) = newImport + // copy symbol and type attributes back into old expression + // so that the structure builder will find it. + expr.symbol = expr1.symbol + expr.tpe = expr1.tpe + ImportType(expr1) + } } val result = diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 349bd1912b..69d3c9b2e1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2549,9 +2549,11 @@ trait Typers extends Modes with Adaptations with Taggings { else stat match { case imp @ Import(_, _) => - context = context.makeNewImport(imp) imp.symbol.initialize - typedImport(imp) + if (!imp.symbol.isError) { + context = context.makeNewImport(imp) + typedImport(imp) + } else EmptyTree case _ => if (localTarget && !includesTargetPos(stat)) { // skip typechecking of statements in a sequence where some other statement includes diff --git a/test/files/buildmanager/t2792/t2792.check b/test/files/buildmanager/t2792/t2792.check index 68e14c6386..00a2b83469 100644 --- a/test/files/buildmanager/t2792/t2792.check +++ b/test/files/buildmanager/t2792/t2792.check @@ -9,3 +9,6 @@ compiling Set(A2.scala) A2.scala:2: error: stable identifier required, but A.x found. import A.x.y ^ +A2.scala:3: error: not found: value y + val z = y + ^ diff --git a/test/files/neg/t5821.check b/test/files/neg/t5821.check new file mode 100644 index 0000000000..f9c00604bc --- /dev/null +++ b/test/files/neg/t5821.check @@ -0,0 +1,4 @@ +t5821.scala:1: error: not found: object SthImportant +import SthImportant._ + ^ +one error found diff --git a/test/files/neg/t5821.scala b/test/files/neg/t5821.scala new file mode 100644 index 0000000000..4af0a2bf7f --- /dev/null +++ b/test/files/neg/t5821.scala @@ -0,0 +1,8 @@ +import SthImportant._ + +class Bar + +class Foo2 { + type Sth = Array[Bar] + def foo(xs: Sth): Bar = if ((xs eq null) || (xs.length == 0)) null else xs(0) +} diff --git a/test/files/neg/t639.check b/test/files/neg/t639.check index 3b53da0515..6d41d872de 100644 --- a/test/files/neg/t639.check +++ b/test/files/neg/t639.check @@ -1,4 +1,7 @@ t639.scala:3: error: not found: object a import a._ ^ -one error found +t639.scala:5: error: not found: type B +@B + ^ +two errors found |