aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-12-16 12:29:25 +0100
committerMartin Odersky <odersky@gmail.com>2013-12-16 12:29:25 +0100
commitf4dab01c5e85897349830210df1b4e074e0b24ee (patch)
tree7f03ab29a888f376420497c7d0c85bc068125cc6 /src
parentf3d428e6957501578c9516de2d179adf713ca95f (diff)
downloaddotty-f4dab01c5e85897349830210df1b4e074e0b24ee.tar.gz
dotty-f4dab01c5e85897349830210df1b4e074e0b24ee.tar.bz2
dotty-f4dab01c5e85897349830210df1b4e074e0b24ee.zip
Check for no double defs
Added check for double def if owner of scope is not a class. For class members we will need a more refined check. One way to do it is to immediately rule out doubly defined members with same signature.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 9eefec624..4ea87bb7b 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -185,11 +185,14 @@ class Namer { typer: Typer =>
def enterSymbol(sym: Symbol)(implicit ctx: Context) = {
if (sym.exists) {
println(s"entered: $sym in ${ctx.owner} and ${ctx.effectiveScope}")
+ def preExisting = ctx.effectiveScope.lookup(sym.name)
if (sym.owner is PackageClass) {
- val preExisting = sym.owner.decls.lookup(sym.name)
if (preExisting.isDefinedInCurrentRun)
ctx.error(s"${sym.showLocated} is compiled twice", sym.pos)
}
+ else if (!sym.owner.isClass && preExisting.exists) {
+ ctx.error(i"${sym.name} is already defined as $preExisting")
+ }
ctx.enter(sym)
}
sym