From 626a6597f7c373ff1d4bc793a7d874045900df93 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 28 Mar 2006 09:56:18 +0000 Subject: fixed bugs 555, 432 --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 5 ++++- src/compiler/scala/tools/nsc/typechecker/Namers.scala | 15 +++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index f6731cf37e..1cff3732f9 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1838,7 +1838,10 @@ trait Parsers requires SyntaxAnalyzer { if (in.token != RBRACE && in.token != CASE) acceptStatSep(); } else if (isDefIntro) { stats ++= defOrDcl(NoMods); - acceptStatSep(); + if (in.token == RBRACE || in.token == CASE) + syntaxError("block must end in result expression, not in definition", false) + else + acceptStatSep(); if (in.token == RBRACE || in.token == CASE) { stats += Literal(()).setPos(in.currentPos) } diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index bf5f278467..6c42012d18 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -85,9 +85,10 @@ trait Namers requires Analyzer { def enterInScope(sym: Symbol): Symbol = { // allow for overloaded methods - if (!(sym.isSourceMethod && sym.owner.isClass)) { + if (!(sym.isSourceMethod && sym.owner.isClass && !sym.owner.isPackageClass)) { val prev = context.scope.lookupEntry(sym.name); - if (prev != null && prev.owner == context.scope && !prev.sym.isSourceMethod) { + if (prev != null && prev.owner == context.scope && + (!prev.sym.isSourceMethod || sym.owner.isPackageClass)) { /* if (sym.sourceFile == null && prev.sym.sourceFile == null) {} @@ -134,12 +135,10 @@ trait Namers requires Analyzer { if (c.owner.isPackageClass) { val file = context.unit.source.getFile(); val clazz = c.asInstanceOf[ClassSymbol]; - if (c.owner.isPackageClass) { - if (settings.debug.value && clazz.sourceFile != null && !clazz.sourceFile.equals(file)) { - System.err.println("SOURCE MISMATCH: " + clazz.sourceFile + " vs. " + file + " SYM=" + c); - } - clazz.sourceFile = file; - } + if (settings.debug.value && clazz.sourceFile != null && !clazz.sourceFile.equals(file)) { + System.err.println("SOURCE MISMATCH: " + clazz.sourceFile + " vs. " + file + " SYM=" + c); + } + clazz.sourceFile = file; if (clazz.sourceFile != null) { assert(!currentRun.compiles(clazz) || clazz.sourceFile == currentRun.symSource(c)); currentRun.symSource(c) = clazz.sourceFile -- cgit v1.2.3