@@ -15,7 +15,7 @@ import Comments.CommentsContext
15
15
import Comments .Comment
16
16
import util .Spans .NoSpan
17
17
import Symbols .requiredModuleRef
18
- import cc .{CapturingType , CaptureSet }
18
+ import cc .{CapturingType , CaptureSet , CapturingKind , EventuallyCapturingType }
19
19
20
20
import scala .annotation .tailrec
21
21
@@ -118,9 +118,9 @@ class Definitions {
118
118
*
119
119
* ErasedFunctionN and ErasedContextFunctionN erase to Function0.
120
120
*
121
- * EffXYZFunctionN afollow this template:
121
+ * ImpureXYZFunctionN follow this template:
122
122
*
123
- * type EffXYZFunctionN [-T0,...,-T{N-1}, +R] = {*} XYZFunctionN[T0,...,T{N-1}, R]
123
+ * type ImpureXYZFunctionN [-T0,...,-T{N-1}, +R] = {*} XYZFunctionN[T0,...,T{N-1}, R]
124
124
*/
125
125
private def newFunctionNType (name : TypeName ): Symbol = {
126
126
val impure = name.startsWith(" Impure" )
@@ -136,7 +136,7 @@ class Definitions {
136
136
HKTypeLambda (argParamNames :+ " R" .toTypeName, argVariances :+ Covariant )(
137
137
tl => List .fill(arity + 1 )(TypeBounds .empty),
138
138
tl => CapturingType (underlyingClass.typeRef.appliedTo(tl.paramRefs),
139
- CaptureSet .universal, boxed = false )
139
+ CaptureSet .universal, CapturingKind . Regular )
140
140
))
141
141
else
142
142
val cls = denot.asClass.classSymbol
@@ -1016,6 +1016,7 @@ class Definitions {
1016
1016
@ tu lazy val VarargsAnnot : ClassSymbol = requiredClass(" scala.annotation.varargs" )
1017
1017
@ tu lazy val SinceAnnot : ClassSymbol = requiredClass(" scala.annotation.since" )
1018
1018
@ tu lazy val RetainsAnnot : ClassSymbol = requiredClass(" scala.retains" )
1019
+ @ tu lazy val RetainsByNameAnnot : ClassSymbol = requiredClass(" scala.retainsByName" )
1019
1020
1020
1021
@ tu lazy val JavaRepeatableAnnot : ClassSymbol = requiredClass(" java.lang.annotation.Repeatable" )
1021
1022
@@ -1149,9 +1150,16 @@ class Definitions {
1149
1150
}
1150
1151
}
1151
1152
1153
+ /** Extractor for function types representing by-name parameters, of the form
1154
+ * `() ?=> T`.
1155
+ * Under -Ycc, this becomes `() ?-> T` or `{r1, ..., rN} () ?-> T`.
1156
+ */
1152
1157
object ByNameFunction :
1153
- def apply (tp : Type )(using Context ): Type =
1154
- defn.ContextFunction0 .typeRef.appliedTo(tp :: Nil )
1158
+ def apply (tp : Type )(using Context ): Type = tp match
1159
+ case EventuallyCapturingType (tp1, refs, CapturingKind .ByName ) =>
1160
+ CapturingType (apply(tp1), refs, CapturingKind .Regular )
1161
+ case _ =>
1162
+ defn.ContextFunction0 .typeRef.appliedTo(tp :: Nil )
1155
1163
def unapply (tp : Type )(using Context ): Option [Type ] = tp match
1156
1164
case tp @ AppliedType (tycon, arg :: Nil ) if defn.isByNameFunctionClass(tycon.typeSymbol) =>
1157
1165
Some (arg)
0 commit comments