diff options
author | Hubert Plociniczak <hubert.plociniczak@gmail.com> | 2012-05-24 16:42:56 +0200 |
---|---|---|
committer | Hubert Plociniczak <hubert.plociniczak@gmail.com> | 2012-05-24 17:57:25 +0200 |
commit | ea78793c618968d8211c5eb353b057b7b5d1bfbb (patch) | |
tree | 7fa45adc9b987358c71e0c01b65c9623da8048b2 /src | |
parent | f406550146250f5a6036d3d778582efa6d68252a (diff) | |
download | scala-ea78793c618968d8211c5eb353b057b7b5d1bfbb.tar.gz scala-ea78793c618968d8211c5eb353b057b7b5d1bfbb.tar.bz2 scala-ea78793c618968d8211c5eb353b057b7b5d1bfbb.zip |
Closes SI-5821.
This was an interesting one. Basically an erroneous
import was creating an erroneous symbol for Array (similary
for other symbols that were 'found' in this import) which was
leading to all sorts of inconsistencies and spurious errors.
This wasn't a bug in ContextErrors but rather something that
existed for ages and was hidden from the general audience.
Review by @paulp.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 20 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 6 |
2 files changed, 16 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 2f2278251b..8952012d6c 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 e40a567f1d..fb970bc84a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2552,9 +2552,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 |