@@ -852,7 +852,9 @@ object SymDenotations {
852852 * During completion, references to moduleClass and sourceModules are stored in
853853 * the completers.
854854 */
855- /** The class implementing this module, NoSymbol if not applicable. */
855+ /** If this a module, return the corresponding class, if this is a module, return itself,
856+ * otherwise NoSymbol
857+ */
856858 final def moduleClass (implicit ctx : Context ): Symbol = {
857859 def notFound = {
858860 if (Config .showCompletions) println(s " missing module class for $name: $myInfo" )
@@ -870,23 +872,34 @@ object SymDenotations {
870872 }
871873 case _ => notFound
872874 }
873- else NoSymbol
875+ else if (this is ModuleClass )
876+ symbol
877+ else
878+ NoSymbol
874879 }
875880
876- /** The module implemented by this module class, NoSymbol if not applicable. */
877- final def sourceModule (implicit ctx : Context ): Symbol = myInfo match {
878- case ClassInfo (_, _, _, _, selfType) if this is ModuleClass =>
879- def sourceOfSelf (tp : TypeOrSymbol ): Symbol = tp match {
880- case tp : TermRef => tp.symbol
881- case tp : Symbol => sourceOfSelf(tp.info)
882- case tp : RefinedType => sourceOfSelf(tp.parent)
881+ /** If this a module class, return the corresponding module, if this is a module, return itself,
882+ * otherwise NoSymbol
883+ */
884+ final def sourceModule (implicit ctx : Context ): Symbol =
885+ if (this is ModuleClass )
886+ myInfo match {
887+ case ClassInfo (_, _, _, _, selfType) =>
888+ def sourceOfSelf (tp : TypeOrSymbol ): Symbol = tp match {
889+ case tp : TermRef => tp.symbol
890+ case tp : Symbol => sourceOfSelf(tp.info)
891+ case tp : RefinedType => sourceOfSelf(tp.parent)
892+ }
893+ sourceOfSelf(selfType)
894+ case info : LazyType =>
895+ info.sourceModule
896+ case _ =>
897+ NoSymbol
883898 }
884- sourceOfSelf(selfType)
885- case info : LazyType =>
886- info.sourceModule
887- case _ =>
899+ else if (this is ModuleVal )
900+ symbol
901+ else
888902 NoSymbol
889- }
890903
891904 /** The field accessed by this getter or setter, or if it does not exist, the getter */
892905 def accessedFieldOrGetter (implicit ctx : Context ): Symbol = {
0 commit comments