diff options
author | Hubert Plociniczak <hubert.plociniczak@gmail.com> | 2012-07-27 11:32:29 +0200 |
---|---|---|
committer | Hubert Plociniczak <hubert.plociniczak@gmail.com> | 2012-07-30 10:20:44 +0200 |
commit | 2a14dd2d23e78775301d38dd235873e5cddc6e23 (patch) | |
tree | 27cee1a5198408c002b5369b2cfe4f3f7a731521 /src/reflect | |
parent | 1ad6e501997d332e2bc0ccc8dd40e3909e728930 (diff) | |
download | scala-2a14dd2d23e78775301d38dd235873e5cddc6e23.tar.gz scala-2a14dd2d23e78775301d38dd235873e5cddc6e23.tar.bz2 scala-2a14dd2d23e78775301d38dd235873e5cddc6e23.zip |
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.
Diffstat (limited to 'src/reflect')
-rw-r--r-- | src/reflect/scala/reflect/internal/Symbols.scala | 6 |
1 files changed, 2 insertions, 4 deletions
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 }) { |