Skip to content

Commit cb45ba9

Browse files
committed
Make Annotation#deferred take IFT arguments
1 parent f70fdd1 commit cb45ba9

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

compiler/src/dotty/tools/dotc/core/Annotations.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,32 @@ object Annotations {
124124
}
125125

126126
/** Create an annotation where the tree is computed lazily. */
127-
def deferred(sym: Symbol, treeFn: Context => Tree)(implicit ctx: Context): Annotation =
127+
def deferred(sym: Symbol)(treeFn: given Context => Tree)(implicit ctx: Context): Annotation =
128128
new LazyAnnotation {
129129
override def symbol(implicit ctx: Context): Symbol = sym
130-
def complete(implicit ctx: Context) = treeFn(ctx)
130+
def complete(implicit ctx: Context) = treeFn given ctx
131131
}
132132

133133
/** Create an annotation where the symbol and the tree are computed lazily. */
134-
def deferredSymAndTree(symf: Context => Symbol, treeFn: Context => Tree)(implicit ctx: Context): Annotation =
134+
def deferredSymAndTree(symf: given Context => Symbol)(treeFn: given Context => Tree)(implicit ctx: Context): Annotation =
135135
new LazyAnnotation {
136136
private[this] var mySym: Symbol = _
137137

138138
override def symbol(implicit ctx: Context): Symbol = {
139139
if (mySym == null || mySym.defRunId != ctx.runId) {
140-
mySym = symf(ctx)
140+
mySym = symf given ctx
141141
assert(mySym != null)
142142
}
143143
mySym
144144
}
145-
def complete(implicit ctx: Context) = treeFn(ctx)
145+
def complete(implicit ctx: Context) = treeFn given ctx
146146
}
147147

148148
def deferred(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation =
149-
deferred(atp.classSymbol, implicit ctx => New(atp, args))
149+
deferred(atp.classSymbol)(New(atp, args))
150150

151151
def deferredResolve(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation =
152-
deferred(atp.classSymbol, implicit ctx => resolveConstructor(atp, args))
152+
deferred(atp.classSymbol)(resolveConstructor(atp, args))
153153

154154
def makeAlias(sym: TermSymbol)(implicit ctx: Context): Annotation =
155155
apply(defn.AliasAnnot, List(
@@ -165,7 +165,7 @@ object Annotations {
165165
New(defn.ChildAnnotType.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil)
166166
.withSpan(span)
167167
}
168-
deferred(defn.ChildAnnot, implicit ctx => makeChildLater(ctx))
168+
deferred(defn.ChildAnnot)(makeChildLater(ctx))
169169
}
170170

171171
/** A regular, non-deferred Child annotation */

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,7 @@ class TreeUnpickler(reader: TastyReader,
658658
val lazyAnnotTree = readLaterWithOwner(end, rdr => ctx => rdr.readTerm()(ctx))
659659

660660
owner =>
661-
Annotation.deferredSymAndTree(
662-
implicit ctx => tp.typeSymbol,
663-
implicit ctx => lazyAnnotTree(owner).complete)
661+
Annotation.deferredSymAndTree(tp.typeSymbol)(lazyAnnotTree(owner).complete)
664662
}
665663

666664
/** Create symbols for the definitions in the statement sequence between

0 commit comments

Comments
 (0)