summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2010-01-20 18:29:13 +0000
committerMartin Odersky <odersky@gmail.com>2010-01-20 18:29:13 +0000
commit0ad899b34e9f36e4e0113a4e31b50b926d9a9c4f (patch)
tree506a68170b1b397dfeed07a7e94012e3701ca28c
parent164fa5151c1f2fdb59350c1051d20c95014bc231 (diff)
downloadscala-0ad899b34e9f36e4e0113a4e31b50b926d9a9c4f.tar.gz
scala-0ad899b34e9f36e4e0113a4e31b50b926d9a9c4f.tar.bz2
scala-0ad899b34e9f36e4e0113a4e31b50b926d9a9c4f.zip
Attempt to fix #2926 (companion object of case ...
Attempt to fix #2926 (companion object of case class problem in Eclipse)
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala1
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala13
2 files changed, 13 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index ae8fd3a956..abeab40991 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -290,6 +290,7 @@ trait Namers { self: Analyzer =>
if (m.isModule && inCurrentScope(m) && currentRun.compiles(m)) m
else enterSyntheticSym(creator)
}
+
private def enterSymFinishWith(tree: Tree, tparams: List[TypeDef]) {
val sym = tree.symbol
if (settings.debug.value) log("entered " + sym + " in " + context.owner + ", scope-id = " + context.scope.hashCode());
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 3fd1c2f36b..3ef6f3165e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -2076,6 +2076,17 @@ trait Typers { self: Analyzer =>
def includesTargetPos(tree: Tree) =
tree.pos.isRange && context.unit != null && (tree.pos includes context.unit.targetPos)
val localTarget = stats exists includesTargetPos
+ val companionOfTarget: Option[Tree] =
+ if (localTarget) {
+ stats span (!includesTargetPos(_)) match {
+ case (pre, (cd: ClassDef) :: _) if cd.symbol hasFlag CASE =>
+ pre find {
+ case md: ModuleDef => md.symbol.name == cd.symbol.name
+ case _ => false
+ }
+ case _ => None
+ }
+ } else None
def typedStat(stat: Tree): Tree = {
if (context.owner.isRefinementClass && !treeInfo.isDeclaration(stat))
errorTree(stat, "only declarations allowed here")
@@ -2090,7 +2101,7 @@ trait Typers { self: Analyzer =>
} else
EmptyTree
case _ =>
- if (localTarget && !includesTargetPos(stat)) {
+ if (localTarget && !includesTargetPos(stat) && companionOfTarget != Some(stat)) {
stat
} else {
val localTyper = if (inBlock || (stat.isDef && !stat.isInstanceOf[LabelDef])) this