File tree 3 files changed +24
-0
lines changed
compiler/src/dotty/tools/dotc/tastyreflect
3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1205,6 +1205,9 @@ class ReflectionCompilerInterface(val rootContext: core.Contexts.Context) extend
1205
1205
def Type_baseClasses (self : Type )(using Context ): List [Symbol ] =
1206
1206
self.baseClasses
1207
1207
1208
+ def Type_baseType (self : Type )(cls : Symbol )(using Context ): Type =
1209
+ self.baseType(cls)
1210
+
1208
1211
def Type_derivesFrom (self : Type )(cls : Symbol )(using Context ): Boolean =
1209
1212
self.derivesFrom(cls)
1210
1213
Original file line number Diff line number Diff line change @@ -1812,6 +1812,17 @@ class Reflection(private[scala] val internal: CompilerInterface) { self =>
1812
1812
/** The base classes of this type with the class itself as first element. */
1813
1813
def baseClasses (using ctx : Context ): List [Symbol ] = internal.Type_baseClasses (self)
1814
1814
1815
+
1816
+ /** The least type instance of given class which is a super-type
1817
+ * of this type. Example:
1818
+ * {{{
1819
+ * class D[T]
1820
+ * class C extends p.D[Int]
1821
+ * ThisType(C).baseType(D) = p.D[Int]
1822
+ * }}}
1823
+ */
1824
+ def baseType (using ctx : Context )(cls : Symbol ): Type = internal.Type_baseType (self)(cls)
1825
+
1815
1826
/** Is this type an instance of a non-bottom subclass of the given class `cls`? */
1816
1827
def derivesFrom (cls : Symbol )(using ctx : Context ): Boolean =
1817
1828
internal.Type_derivesFrom (self)(cls)
Original file line number Diff line number Diff line change @@ -876,6 +876,16 @@ trait CompilerInterface {
876
876
/** The base classes of this type with the class itself as first element. */
877
877
def Type_baseClasses (self : Type )(using ctx : Context ): List [Symbol ]
878
878
879
+ /** The least type instance of given class which is a super-type
880
+ * of this type. Example:
881
+ * {{{
882
+ * class D[T]
883
+ * class C extends p.D[Int]
884
+ * ThisType(C).baseType(D) = p.D[Int]
885
+ * }}}
886
+ */
887
+ def Type_baseType (self : Type )(cls : Symbol )(using ctx : Context ): Type
888
+
879
889
/** Is this type an instance of a non-bottom subclass of the given class `cls`? */
880
890
def Type_derivesFrom (self : Type )(cls : Symbol )(using ctx : Context ): Boolean
881
891
You can’t perform that action at this time.
0 commit comments