@@ -17,7 +17,8 @@ import Trees.Literal
17
17
import Variances .Variance
18
18
import annotation .tailrec
19
19
import util .SimpleIdentityMap
20
- import util .Stats
20
+ import util .{SrcPos , SourcePosition , Stats }
21
+ import util .Spans .*
21
22
import java .util .WeakHashMap
22
23
import scala .util .control .NonFatal
23
24
import config .Config
@@ -39,7 +40,8 @@ object SymDenotations {
39
40
final val name : Name ,
40
41
initFlags : FlagSet ,
41
42
initInfo : Type ,
42
- initPrivateWithin : Symbol = NoSymbol ) extends SingleDenotation (symbol, initInfo, name.isTypeName) {
43
+ initPrivateWithin : Symbol = NoSymbol )
44
+ extends SingleDenotation (symbol, initInfo, name.isTypeName), ParamInfo , SrcPos {
43
45
44
46
// assert(symbol.id != 4940, name)
45
47
@@ -1744,6 +1746,31 @@ object SymDenotations {
1744
1746
/** Same as `sealedStrictDescendants` but prepends this symbol as well.
1745
1747
*/
1746
1748
final def sealedDescendants (using Context ): List [Symbol ] = this .symbol :: sealedStrictDescendants
1749
+
1750
+ // ---- ParamInfo bindings -------------------------------------
1751
+
1752
+ type ThisName <: Name
1753
+
1754
+ def isTypeParam (using Context ): Boolean = is(TypeParam )
1755
+ def paramName (using Context ): ThisName = name.asInstanceOf [ThisName ]
1756
+ def paramInfo (using Context ): Type = info
1757
+ def paramInfoAsSeenFrom (pre : Type )(using Context ): Type = pre.memberInfo(symbol)
1758
+ def paramInfoOrCompleter (using Context ): Type = infoOrCompleter
1759
+ def paramVariance (using Context ): Variance = variance
1760
+ def paramRef (using Context ): TypeRef = typeRef
1761
+
1762
+ // ---- SrcPos bindings -------------------------------------
1763
+
1764
+ /** The position of this symbol, or NoSpan if the symbol was not loaded
1765
+ * from source or from TASTY. This is always a zero-extent position.
1766
+ */
1767
+ final def span : Span = if symbol.coord.isSpan then symbol.coord.toSpan else NoSpan
1768
+
1769
+ final def sourcePos (using Context ): SourcePosition = {
1770
+ val src = symbol.source
1771
+ (if src.exists then src else ctx.source).atSpan(span)
1772
+ }
1773
+
1747
1774
}
1748
1775
1749
1776
/** The contents of a class definition during a period
@@ -1759,6 +1786,8 @@ object SymDenotations {
1759
1786
1760
1787
import util .EqHashMap
1761
1788
1789
+ type ThisName = TypeName
1790
+
1762
1791
// ----- caches -------------------------------------------------------
1763
1792
1764
1793
private var myTypeParams : List [TypeSymbol ] | Null = null
0 commit comments