Skip to content

Commit 870c44a

Browse files
committed
Add mapInfo method to Denotations
1 parent 324044e commit 870c44a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ object Denotations {
146146
/** Is this denotation different from NoDenotation or an ErrorDenotation? */
147147
def exists: Boolean = true
148148

149+
/** A denotation with the info of this denotation transformed using `f` */
150+
def mapInfo(f: Type => Type)(implicit ctx: Context): Denotation
151+
149152
/** If this denotation does not exist, fallback to alternative */
150153
final def orElse(that: => Denotation) = if (this.exists) this else that
151154

@@ -242,7 +245,7 @@ object Denotations {
242245
}
243246
else if (exists && !qualifies(symbol)) NoDenotation
244247
else asSingleDenotation
245-
}
248+
}
246249

247250
/** Form a denotation by conjoining with denotation `that`.
248251
*
@@ -456,6 +459,8 @@ object Denotations {
456459
else if (!d2.exists) d1
457460
else derivedMultiDenotation(d1, d2)
458461
}
462+
def mapInfo(f: Type => Type)(implicit ctx: Context): Denotation =
463+
derivedMultiDenotation(denot1.mapInfo(f), denot2.mapInfo(f))
459464
def derivedMultiDenotation(d1: Denotation, d2: Denotation) =
460465
if ((d1 eq denot1) && (d2 eq denot2)) this else MultiDenotation(d1, d2)
461466
override def toString = alternatives.mkString(" <and> ")
@@ -488,6 +493,9 @@ object Denotations {
488493
if ((symbol eq this.symbol) && (info eq this.info)) this
489494
else newLikeThis(symbol, info)
490495

496+
def mapInfo(f: Type => Type)(implicit ctx: Context): SingleDenotation =
497+
derivedSingleDenotation(symbol, f(info))
498+
491499
def orElse(that: => SingleDenotation) = if (this.exists) this else that
492500

493501
def altsWith(p: Symbol => Boolean): List[SingleDenotation] =

0 commit comments

Comments
 (0)