@@ -852,7 +852,9 @@ object SymDenotations {
852
852
* During completion, references to moduleClass and sourceModules are stored in
853
853
* the completers.
854
854
*/
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
+ */
856
858
final def moduleClass (implicit ctx : Context ): Symbol = {
857
859
def notFound = {
858
860
if (Config .showCompletions) println(s " missing module class for $name: $myInfo" )
@@ -870,23 +872,32 @@ object SymDenotations {
870
872
}
871
873
case _ => notFound
872
874
}
873
- else NoSymbol
875
+ else if (this is ModuleClass )
876
+ symbol
877
+ else
878
+ NoSymbol
874
879
}
875
880
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
883
896
}
884
- sourceOfSelf(selfType)
885
- case info : LazyType =>
886
- info.sourceModule
887
- case _ =>
897
+ else if (this is ModuleVal )
898
+ symbol
899
+ else
888
900
NoSymbol
889
- }
890
901
891
902
/** The field accessed by this getter or setter, or if it does not exist, the getter */
892
903
def accessedFieldOrGetter (implicit ctx : Context ): Symbol = {
0 commit comments