aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/SymDenotations.scala
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-28 20:39:09 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-28 20:39:09 +0100
commitf9910eba54741dc127577010b5728a70622a8c08 (patch)
tree7e6c32ba5fb57e09b0f5030045798804a7a52d6e /src/dotty/tools/dotc/core/SymDenotations.scala
parent595c3f6c50da97be3169fe59261ff999e1a70759 (diff)
downloaddotty-f9910eba54741dc127577010b5728a70622a8c08.tar.gz
dotty-f9910eba54741dc127577010b5728a70622a8c08.tar.bz2
dotty-f9910eba54741dc127577010b5728a70622a8c08.zip
Use methods to find companion modules
Diffstat (limited to 'src/dotty/tools/dotc/core/SymDenotations.scala')
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 658af4a4e..0a978f8c3 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -239,7 +239,7 @@ object SymDenotations {
final def ensureCompleted()(implicit ctx: Context): Unit = info
/** The symbols defined in this class or object.
- * Careful! This coes not force the type, so is compilation order dependent.
+ * Careful! This does not force the type, so is compilation order dependent.
* This method should be used only in the following circumstances:
*
* 1. When accessing type parameters or type parameter accessors (both are entered before
@@ -766,11 +766,15 @@ object SymDenotations {
* and which is also defined in the same scope and compilation unit.
* NoSymbol if this module does not exist.
*/
- final def companionModule(implicit ctx: Context): Symbol =
- if (name == tpnme.ANON_CLASS)
- NoSymbol // avoid forcing anon classes, this might cause cyclic reference errors
+ final def companionModule(implicit ctx: Context): Symbol = {
+ val companionMethod = info.decls.denotsNamed(nme.COMPANION_MODULE_METHOD, selectPrivate).first
+
+ if (companionMethod.exists)
+ companionMethod.info.resultType.classSymbol.sourceModule
else
- companionNamed(effectiveName.moduleClassName).sourceModule
+ NoSymbol
+ }
+
/** The class with the same (type-) name as this module or module class,
* and which is also defined in the same scope and compilation unit.
@@ -781,21 +785,13 @@ object SymDenotations {
if (companionMethod.exists)
companionMethod.info.resultType.classSymbol
- else {
- /*
- val scalac = companionNamed(effectiveName.toTypeName)
-
- if (scalac.exists) {
- println(s"scalac returned companion class for $this to be $scalac")
- }
- */
+ else
NoSymbol
- }
}
final def scalacLinkedClass(implicit ctx: Context): Symbol =
if (this is ModuleClass) companionNamed(effectiveName.toTypeName)
- else if (this.isClass) companionModule.moduleClass
+ else if (this.isClass) companionNamed(effectiveName.moduleClassName).sourceModule.moduleClass
else NoSymbol