@@ -852,13 +852,17 @@ 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 class, return itself, if this is a module, the corresponding class,
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" )
859
861
NoSymbol
860
862
}
861
- if (this is ModuleVal )
863
+ if (this is ModuleClass )
864
+ symbol
865
+ else if (this is ModuleVal )
862
866
myInfo match {
863
867
case info : TypeRef => info.symbol
864
868
case ExprType (info : TypeRef ) => info.symbol // needed after uncurry, when module terms might be accessor defs
@@ -873,20 +877,26 @@ object SymDenotations {
873
877
else NoSymbol
874
878
}
875
879
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)
880
+ /** If this a module, return itself, if this is a module class, the corresponding module,
881
+ * otherwise NoSymbol
882
+ */
883
+ final def sourceModule (implicit ctx : Context ): Symbol =
884
+ if (this is ModuleVal )
885
+ symbol
886
+ else
887
+ myInfo match {
888
+ case ClassInfo (_, _, _, _, selfType) if this is ModuleClass =>
889
+ def sourceOfSelf (tp : TypeOrSymbol ): Symbol = tp match {
890
+ case tp : TermRef => tp.symbol
891
+ case tp : Symbol => sourceOfSelf(tp.info)
892
+ case tp : RefinedType => sourceOfSelf(tp.parent)
893
+ }
894
+ sourceOfSelf(selfType)
895
+ case info : LazyType =>
896
+ info.sourceModule
897
+ case _ =>
898
+ NoSymbol
883
899
}
884
- sourceOfSelf(selfType)
885
- case info : LazyType =>
886
- info.sourceModule
887
- case _ =>
888
- NoSymbol
889
- }
890
900
891
901
/** The field accessed by this getter or setter, or if it does not exist, the getter */
892
902
def accessedFieldOrGetter (implicit ctx : Context ): Symbol = {
0 commit comments