From 2a14dd2d23e78775301d38dd235873e5cddc6e23 Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Fri, 27 Jul 2012 11:32:29 +0200 Subject: Fixed SI-5031. Only consider classes when looking for companion class. sym.effectiveOwner revealed this piece of inconsistency. companionModule is fine because similar check is there already. Review by @paulp. --- src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala | 1 - src/reflect/scala/reflect/internal/Symbols.scala | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala index f4c96505a7..9d141efe0a 100755 --- a/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala +++ b/src/compiler/scala/tools/nsc/doc/model/IndexModelFactory.scala @@ -8,7 +8,6 @@ package doc package model import scala.collection._ -import language.reflectiveCalls object IndexModelFactory { diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index b14306282b..5c9999b3bd 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -2035,7 +2035,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** Is this symbol defined in the same scope and compilation unit as `that` symbol? */ def isCoDefinedWith(that: Symbol) = { - import language.reflectiveCalls (this.rawInfo ne NoType) && (this.effectiveOwner == that.effectiveOwner) && { !this.effectiveOwner.isPackageClass || @@ -2706,7 +2705,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => override def moduleClass = referenced override def companionClass = - flatOwnerInfo.decl(name.toTypeName).suchThat(_ isCoDefinedWith this) + flatOwnerInfo.decl(name.toTypeName).suchThat(sym => sym.isClass && (sym isCoDefinedWith this)) override def owner = { Statistics.incCounter(ownerCount) @@ -3071,7 +3070,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => */ protected final def companionModule0: Symbol = flatOwnerInfo.decl(name.toTermName).suchThat( - sym => sym.hasFlag(MODULE) && (sym isCoDefinedWith this) && !sym.isMethod) + sym => sym.isModule && (sym isCoDefinedWith this) && !sym.isMethod) override def companionModule = companionModule0 override def companionSymbol = companionModule0 @@ -3394,7 +3393,6 @@ trait Symbols extends api.Symbols { self: SymbolTable => } case class InvalidCompanions(sym1: Symbol, sym2: Symbol) extends Throwable({ - import language.reflectiveCalls "Companions '" + sym1 + "' and '" + sym2 + "' must be defined in same file:\n" + " Found in " + sym1.sourceFile.canonicalPath + " and " + sym2.sourceFile.canonicalPath }) { -- cgit v1.2.3