Skip to content

Commit 34d7748

Browse files
committed
Rename more usages of Contextual
1 parent 1799bf6 commit 34d7748

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ object desugar {
11211121
Block(
11221122
DefDef(nme.ANON_FUN, Nil, params :: Nil, if (tpt == null) TypeTree() else tpt, body)
11231123
.withMods(synthetic | Artifact),
1124-
Closure(Nil, Ident(nme.ANON_FUN), if (isGiven) ContextualEmptyTree else EmptyTree))
1124+
Closure(Nil, Ident(nme.ANON_FUN), if (isGiven) GivenClosureEmptyTree else EmptyTree))
11251125

11261126
/** If `nparams` == 1, expand partial function
11271127
*
@@ -1174,7 +1174,7 @@ object desugar {
11741174
Function(param :: Nil, Block(vdefs, body))
11751175
}
11761176

1177-
def makeContextualFunction(formals: List[Type], body: Tree, isErased: Boolean)(implicit ctx: Context): Tree = {
1177+
def makeGivenFunction(formals: List[Type], body: Tree, isErased: Boolean)(implicit ctx: Context): Tree = {
11781178
val mods = if (isErased) Given | Erased else Given
11791179
val params = makeImplicitParameters(formals.map(TypeTree), mods)
11801180
new FunctionWithMods(params, body, Modifiers(mods))

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,15 +327,15 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
327327
functionWithUnknownParamType(tree).isDefined
328328

329329
/** Is `tree` an implicit function or closure, possibly nested in a block? */
330-
def isContextualClosure(tree: Tree)(implicit ctx: Context): Boolean = unsplice(tree) match {
330+
def isGivenClosure(tree: Tree)(implicit ctx: Context): Boolean = unsplice(tree) match {
331331
case tree: FunctionWithMods => tree.mods.is(Given)
332332
case Function((param: untpd.ValDef) :: _, _) => param.mods.is(Given)
333333
case Closure(_, meth, _) => true
334-
case Block(Nil, expr) => isContextualClosure(expr)
334+
case Block(Nil, expr) => isGivenClosure(expr)
335335
case Block(DefDef(nme.ANON_FUN, _, params :: _, _, _) :: Nil, cl: Closure) =>
336336
params match {
337337
case param :: _ => param.mods.is(Given)
338-
case Nil => cl.tpt.eq(untpd.ContextualEmptyTree) || defn.isImplicitFunctionType(cl.tpt.typeOpt)
338+
case Nil => cl.tpt.eq(untpd.GivenClosureEmptyTree) || defn.isImplicitFunctionType(cl.tpt.typeOpt)
339339
}
340340
case _ => false
341341
}

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ object Trees {
992992

993993
@sharable val EmptyTree: Thicket = genericEmptyTree
994994
@sharable val EmptyValDef: ValDef = genericEmptyValDef
995-
@sharable val ContextualEmptyTree: Thicket = new EmptyTree // an empty tree marking a contextual closure
995+
@sharable val GivenClosureEmptyTree: Thicket = new EmptyTree // an empty tree marking a contextual closure
996996

997997
// ----- Auxiliary creation methods ------------------
998998

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ object Types {
7171
* +- GroundType -+- AndType
7272
* +- OrType
7373
* +- MethodOrPoly ---+-- PolyType
74-
* +-- MethodType ---+- ImplicitMethodType
75-
* +- ContextualMethodType
74+
* | +-- MethodType ---+- ImplicitMethodType
75+
* | +- GivenMethodType
76+
* | +- ErasedMethodType
7677
* | +- JavaMethodType
7778
* +- ClassInfo
7879
* |
@@ -3189,10 +3190,10 @@ object Types {
31893190
final override def isErasedMethod: Boolean =
31903191
companion.eq(ErasedMethodType) ||
31913192
companion.eq(ErasedImplicitMethodType) ||
3192-
companion.eq(ErasedContextualMethodType)
3193+
companion.eq(ErasedGivenMethodType)
31933194
final override def isGivenMethod: Boolean =
3194-
companion.eq(ContextualMethodType) ||
3195-
companion.eq(ErasedContextualMethodType)
3195+
companion.eq(GivenMethodType) ||
3196+
companion.eq(ErasedGivenMethodType)
31963197

31973198
def computeSignature(implicit ctx: Context): Signature = {
31983199
val params = if (isErasedMethod) Nil else paramInfos
@@ -3293,7 +3294,7 @@ object Types {
32933294
JavaMethodType
32943295
}
32953296
else if (isGiven)
3296-
if (isErased) ErasedContextualMethodType else ContextualMethodType
3297+
if (isErased) ErasedGivenMethodType else GivenMethodType
32973298
else if (isOldImplicit)
32983299
if (isErased) ErasedImplicitMethodType else ImplicitMethodType
32993300
else
@@ -3302,8 +3303,8 @@ object Types {
33023303
}
33033304
object JavaMethodType extends MethodTypeCompanion("JavaMethodType")
33043305
object ErasedMethodType extends MethodTypeCompanion("ErasedMethodType")
3305-
object ContextualMethodType extends MethodTypeCompanion("ContextualMethodType")
3306-
object ErasedContextualMethodType extends MethodTypeCompanion("ErasedContextualMethodType")
3306+
object GivenMethodType extends MethodTypeCompanion("GivenMethodType")
3307+
object ErasedGivenMethodType extends MethodTypeCompanion("ErasedGivenMethodType")
33073308
object ImplicitMethodType extends MethodTypeCompanion("ImplicitMethodType")
33083309
object ErasedImplicitMethodType extends MethodTypeCompanion("ErasedImplicitMethodType")
33093310

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,9 @@ class TreeUnpickler(reader: TastyReader,
352352
case ERASEDMETHODtype =>
353353
readMethodic(ErasedMethodType, _.toTermName)
354354
case GIVENMETHODtype =>
355-
readMethodic(ContextualMethodType, _.toTermName)
355+
readMethodic(GivenMethodType, _.toTermName)
356356
case ERASEDGIVENMETHODtype =>
357-
readMethodic(ErasedContextualMethodType, _.toTermName)
357+
readMethodic(ErasedGivenMethodType, _.toTermName)
358358
case IMPLICITMETHODtype =>
359359
readMethodic(ImplicitMethodType, _.toTermName)
360360
case TYPELAMBDAtype =>

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ class Typer extends Namer
10001000
|because it has internal parameter dependencies,
10011001
|position = ${tree.span}, raw type = ${mt.toString}""") // !!! DEBUG. Eventually, convert to an error?
10021002
}
1003-
else if ((tree.tpt `eq` untpd.ContextualEmptyTree) && mt.paramNames.isEmpty)
1003+
else if ((tree.tpt `eq` untpd.GivenClosureEmptyTree) && mt.paramNames.isEmpty)
10041004
// Note implicitness of function in target type since there are no method parameters that indicate it.
10051005
TypeTree(defn.FunctionOf(Nil, mt.resType, isGiven = true, isErased = false))
10061006
else
@@ -2179,10 +2179,10 @@ class Typer extends Namer
21792179
val ifpt = defn.asImplicitFunctionType(pt)
21802180
val result = if (ifpt.exists &&
21812181
xtree.isTerm &&
2182-
!untpd.isContextualClosure(xtree) &&
2182+
!untpd.isGivenClosure(xtree) &&
21832183
!ctx.mode.is(Mode.Pattern) &&
21842184
!ctx.isAfterTyper)
2185-
makeContextualFunction(xtree, ifpt)
2185+
makeGivenFunction(xtree, ifpt)
21862186
else xtree match {
21872187
case xtree: untpd.NameTree => typedNamed(xtree, pt)
21882188
case xtree => typedUnnamed(xtree)
@@ -2203,9 +2203,9 @@ class Typer extends Namer
22032203
tree
22042204
}
22052205

2206-
protected def makeContextualFunction(tree: untpd.Tree, pt: Type)(implicit ctx: Context): Tree = {
2206+
protected def makeGivenFunction(tree: untpd.Tree, pt: Type)(implicit ctx: Context): Tree = {
22072207
val defn.FunctionOf(formals, _, true, _) = pt.dropDependentRefinement
2208-
val ifun = desugar.makeContextualFunction(formals, tree, defn.isErasedFunctionType(pt))
2208+
val ifun = desugar.makeGivenFunction(formals, tree, defn.isErasedFunctionType(pt))
22092209
typr.println(i"make contextual function $tree / $pt ---> $ifun")
22102210
typed(ifun, pt)
22112211
}
@@ -2779,7 +2779,7 @@ class Typer extends Namer
27792779
def adaptNoArgsOther(wtp: Type): Tree = {
27802780
ctx.typeComparer.GADTused = false
27812781
if (isImplicitFunctionRef(wtp) &&
2782-
!untpd.isContextualClosure(tree) &&
2782+
!untpd.isGivenClosure(tree) &&
27832783
!isApplyProto(pt) &&
27842784
!ctx.mode.is(Mode.Pattern) &&
27852785
!ctx.isAfterTyper) {

0 commit comments

Comments
 (0)