@@ -321,6 +321,9 @@ object SymDenotations {
321
321
final def isAnonymousClass (implicit ctx : Context ): Boolean =
322
322
initial.asSymDenotation.name startsWith tpnme.ANON_CLASS
323
323
324
+ final def isRefinementClass (implicit ctx : Context ): Boolean =
325
+ name.decode == tpnme.REFINE_CLASS
326
+
324
327
/** Is this symbol a package object or its module class? */
325
328
def isPackageObject (implicit ctx : Context ): Boolean = {
326
329
val poName = if (isType) nme.PACKAGE_CLS else nme.PACKAGE
@@ -701,6 +704,54 @@ object SymDenotations {
701
704
else
702
705
Iterator .empty
703
706
707
+ /** The symbol overriding this symbol in given subclass `ofclazz`.
708
+ *
709
+ * @param ofclazz is a subclass of this symbol's owner
710
+ */
711
+ final def overridingSymbol (inClass : ClassSymbol )(implicit ctx : Context ): Symbol =
712
+ if (canMatchInheritedSymbols) matchingSymbol(inClass, inClass.thisType)
713
+ else NoSymbol
714
+
715
+ /** If false, this symbol cannot possibly participate in an override,
716
+ * either as overrider or overridee. For internal use; you should consult
717
+ * with isOverridingSymbol. This is used by isOverridingSymbol to escape
718
+ * the recursive knot.
719
+ */
720
+ private def canMatchInheritedSymbols = (
721
+ owner.isClass
722
+ && ! this .isClass
723
+ && ! this .isConstructor
724
+ )
725
+
726
+ /** The symbol accessed by a super in the definition of this symbol when
727
+ * seen from class `base`. This symbol is always concrete.
728
+ * pre: `this.owner` is in the base class sequence of `base`.
729
+ */
730
+ final def superSymbolIn (base : Symbol )(implicit ctx : Context ): Symbol = {
731
+ def loop (bcs : List [ClassSymbol ]): Symbol = bcs match {
732
+ case bc :: bcs1 =>
733
+ val sym = matchingSymbol(bcs.head, base.thisType)
734
+ .suchThat(alt => ! (alt is Deferred )).symbol
735
+ if (sym.exists) sym else loop(bcs.tail)
736
+ case _ =>
737
+ NoSymbol
738
+ }
739
+ loop(base.info.baseClasses.dropWhile(owner != _).tail)
740
+ }
741
+
742
+
743
+ /** A a member of class `base` is incomplete if
744
+ * (1) it is declared deferred or
745
+ * (2) it is abstract override and its super symbol in `base` is
746
+ * nonexistent or incomplete.
747
+ */
748
+ final def isIncompleteIn (base : Symbol )(implicit ctx : Context ): Boolean =
749
+ (this is Deferred ) ||
750
+ (this is AbsOverride ) && {
751
+ val supersym = superSymbolIn(base)
752
+ supersym == NoSymbol || supersym.isIncompleteIn(base)
753
+ }
754
+
704
755
/** The class or term symbol up to which this symbol is accessible,
705
756
* or RootClass if it is public. As java protected statics are
706
757
* otherwise completely inaccessible in scala, they are treated
0 commit comments