diff options
author | Martin Odersky <odersky@gmail.com> | 2003-03-18 17:33:59 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2003-03-18 17:33:59 +0000 |
commit | 58cad3d1ce9c65ace3ba12b3e54dcf64876155dc (patch) | |
tree | 813b54a539fb68562e932ef1f43d5efd3cb7fc8e | |
parent | 374fe5428200c92a0636a0266d112b60af16e9cf (diff) | |
download | scala-58cad3d1ce9c65ace3ba12b3e54dcf64876155dc.tar.gz scala-58cad3d1ce9c65ace3ba12b3e54dcf64876155dc.tar.bz2 scala-58cad3d1ce9c65ace3ba12b3e54dcf64876155dc.zip |
*** empty log message ***
-rw-r--r-- | sources/scalac/typechecker/Analyzer.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java index 5e2be22796..b9e4bdd87b 100644 --- a/sources/scalac/typechecker/Analyzer.java +++ b/sources/scalac/typechecker/Analyzer.java @@ -19,7 +19,7 @@ import scalac.ast.printer.*; import scalac.symtab.*; import Tree.*; import java.util.HashMap; -import java.util.Vector; +import java.util.HashSet; public class Analyzer extends Transformer implements Modifiers, Kinds { @@ -42,9 +42,10 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { private Context context; private Type pt; private int mode; + private HashSet compiledNow = new HashSet(); public void apply() { - int errors = global.reporter.errors(); + compiledNow.clear(); for (int i = 0; i < global.units.length; i++) { enterUnit(global.units[i]); } @@ -788,6 +789,7 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { */ private Symbol enterInScope(Symbol sym) { // handle double and overloaded definitions + Symbol result = sym; Scope.Entry e = context.scope.lookupEntry(sym.name); if (e.owner == context.scope) { Symbol other = e.sym; @@ -806,7 +808,13 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { Symbol.EMPTY_ARRAY, other.moduleClass().typeConstructor())); } - return other; + result = other; + } else if (sym.owner().isPackage()) { + if (compiledNow.contains(other)) { + error(sym.pos, sym + " is compiled twice"); + } + context.scope.unlink(e); + context.scope.enter(sym); } else if (sym.kind == VAL && other.kind == VAL) { // it's an overloaded definition if (((sym.flags ^ other.flags) & SOURCEFLAGS) != 0) { @@ -826,7 +834,8 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { } else { context.scope.enter(sym); } - return sym; + if (result.owner().isPackage()) compiledNow.add(result); + return result; } /** Enter all symbols in statement list |