summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorGilles Dubochet <gilles.dubochet@epfl.ch>2010-01-15 14:41:19 +0000
committerGilles Dubochet <gilles.dubochet@epfl.ch>2010-01-15 14:41:19 +0000
commita40276ad9a846248d9bd76ebc58b836522f7c36e (patch)
treebad61f2c6de767118e9c92a2f75f0dd2386cee4b /src/compiler
parent135ec1392770b301925e2e9c660f7a67e4615ee9 (diff)
downloadscala-a40276ad9a846248d9bd76ebc58b836522f7c36e.tar.gz
scala-a40276ad9a846248d9bd76ebc58b836522f7c36e.tar.bz2
scala-a40276ad9a846248d9bd76ebc58b836522f7c36e.zip
Fixed issue when searching for companion of cla...
Fixed issue when searching for companion of class using "linkedSym" when value of same name is overloaded (for example companion of the Value class in an Enumeration). No review, already checked by odersky.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Symbols.scala17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Symbols.scala b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
index 85ed3a786f..5ee7409cc7 100644
--- a/src/compiler/scala/tools/nsc/symtab/Symbols.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Symbols.scala
@@ -1254,21 +1254,28 @@ trait Symbols {
else NoSymbol
}
+ /** A helper method that factors the common code used the discover a companion module of a class. If a companion
+ * module exists, its symbol is returned, otherwise, `NoSymbol` is returned. The method assumes that `this`
+ * symbol has already been checked to be a class (using `isClass`). */
+ private final def linkedModuleOfClass0: Symbol =
+ flatOwnerInfo.decl(name.toTermName).suchThat(
+ sym => (sym hasFlag MODULE) && (sym isCoDefinedWith this))
+
/** The module or case class factory with the same name in the same
* package as this class. A better name would be companionModuleOfClass.
*/
final def linkedModuleOfClass: Symbol =
- if (this.isClass && !this.isAnonymousClass && !this.isRefinementClass) {
- flatOwnerInfo.decl(name.toTermName).suchThat(
- sym => (sym hasFlag MODULE) && (sym isCoDefinedWith this))
- } else NoSymbol
+ if (this.isClass && !this.isAnonymousClass && !this.isRefinementClass)
+ linkedModuleOfClass0
+ else NoSymbol
/** For a module its linked class, for a class its linked module or case
* factory otherwise.
*/
final def linkedSym: Symbol =
if (isTerm) linkedClassOfModule
- else if (isClass) flatOwnerInfo.decl(name.toTermName).suchThat(_ isCoDefinedWith this)
+ else if (isClass)
+ linkedModuleOfClass0
else NoSymbol
/** For a module class its linked class, for a plain class