Skip to content

Commit a1ffafc

Browse files
committed
Rename internals to new terminologu
Token: INSTANCE -> IMPLIED Flag: Contextual -> Given
1 parent 53f00ae commit a1ffafc

14 files changed

+32
-32
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1086,8 +1086,8 @@ object desugar {
10861086
}
10871087

10881088
def makeContextualFunction(formals: List[Type], body: Tree)(implicit ctx: Context): Tree = {
1089-
val params = makeImplicitParameters(formals.map(TypeTree), Contextual)
1090-
new FunctionWithMods(params, body, Modifiers(Implicit | Contextual))
1089+
val params = makeImplicitParameters(formals.map(TypeTree), Given)
1090+
new FunctionWithMods(params, body, Modifiers(Implicit | Given))
10911091
}
10921092

10931093
/** Add annotation to tree:

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -331,13 +331,13 @@ trait UntypedTreeInfo extends TreeInfo[Untyped] { self: Trees.Instance[Untyped]
331331

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
234234

235235
def valueParam(name: TermName, origInfo: Type): TermSymbol = {
236236
val maybeImplicit =
237-
if (tp.isContextual) Implicit | Contextual
237+
if (tp.isContextual) Implicit | Given
238238
else if (tp.isImplicitMethod) Implicit
239239
else EmptyFlags
240240
val maybeErased = if (tp.isErasedMethod) Erased else EmptyFlags

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
132132

133133
case class Implicit()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.ImplicitCommon)
134134

135-
case class Given()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.ImplicitCommon | Flags.Contextual)
135+
case class Given()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.ImplicitCommon | Flags.Given)
136136

137137
case class Erased()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Erased)
138138

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ object Flags {
347347
/** An extension method */
348348
final val Extension = termFlag(28, "<extension>")
349349

350-
/** A contextual (with) parameter */
351-
final val Contextual = commonFlag(29, "<contextual>")
350+
/** An inferable (`given`) parameter */
351+
final val Given = commonFlag(29, "given")
352352

353353
/** Symbol is defined by a Java class */
354354
final val JavaDefined: FlagSet = commonFlag(30, "<java>")

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ Standard-Section: "ASTs" TopLevelStat*
203203
DEFAULTparameterized // Method with default parameters
204204
STABLE // Method that is assumed to be stable
205205
EXTENSION // An extension method
206-
CONTEXTUAL // new style implicit parameters, introduced with `with`
206+
GIVEN // new style implicit parameters, introduced with `given`
207207
PARAMsetter // A setter without a body named `x_=` where `x` is pickled as a PARAM
208208
Annotation
209209
@@ -323,7 +323,7 @@ object TastyFormat {
323323
final val ERASED = 34
324324
final val OPAQUE = 35
325325
final val EXTENSION = 36
326-
final val CONTEXTUAL = 37
326+
final val GIVEN = 37
327327
final val PARAMsetter = 38
328328

329329
// Cat. 2: tag Nat
@@ -497,7 +497,7 @@ object TastyFormat {
497497
| DEFAULTparameterized
498498
| STABLE
499499
| EXTENSION
500-
| CONTEXTUAL
500+
| GIVEN
501501
| PARAMsetter
502502
| ANNOTATION
503503
| PRIVATEqualified
@@ -558,7 +558,7 @@ object TastyFormat {
558558
case DEFAULTparameterized => "DEFAULTparameterized"
559559
case STABLE => "STABLE"
560560
case EXTENSION => "EXTENSION"
561-
case CONTEXTUAL => "CONTEXTUAL"
561+
case GIVEN => "GIVEN"
562562
case PARAMsetter => "PARAMsetter"
563563

564564
case SHAREDterm => "SHAREDterm"

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ class TreePickler(pickler: TastyPickler) {
655655
if (flags is DefaultParameterized) writeByte(DEFAULTparameterized)
656656
if (flags is StableRealizable) writeByte(STABLE)
657657
if (flags is Extension) writeByte(EXTENSION)
658-
if (flags is Contextual) writeByte(CONTEXTUAL)
658+
if (flags is Given) writeByte(GIVEN)
659659
if (flags is ParamAccessor) writeByte(PARAMsetter)
660660
assert(!(flags is Label))
661661
} else {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ class TreeUnpickler(reader: TastyReader,
632632
case DEFAULTparameterized => addFlag(DefaultParameterized)
633633
case STABLE => addFlag(StableRealizable)
634634
case EXTENSION => addFlag(Extension)
635-
case CONTEXTUAL => addFlag(Contextual)
635+
case GIVEN => addFlag(Given)
636636
case PARAMsetter =>
637637
addFlag(ParamAccessor)
638638
case PRIVATEqualified =>

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ object Parsers {
783783
def functionRest(params: List[Tree]): Tree =
784784
atSpan(start, accept(ARROW)) {
785785
val t = typ()
786-
if (imods.is(Implicit | Contextual | Erased)) new FunctionWithMods(params, t, imods)
786+
if (imods.is(Implicit | Given | Erased)) new FunctionWithMods(params, t, imods)
787787
else Function(params, t)
788788
}
789789
def funArgTypesRest(first: Tree, following: () => Tree) = {
@@ -2090,7 +2090,7 @@ object Parsers {
20902090

20912091
// begin paramClause
20922092
inParens {
2093-
val isContextual = impliedMods.is(Contextual)
2093+
val isContextual = impliedMods.is(Given)
20942094
if (in.token == RPAREN && !prefix && !isContextual) Nil
20952095
else {
20962096
def funArgMods(mods: Modifiers): Modifiers =
@@ -2123,10 +2123,10 @@ object Parsers {
21232123
val initialMods =
21242124
if (in.token == GIVEN) {
21252125
in.nextToken()
2126-
Modifiers(Contextual | Implicit)
2126+
Modifiers(Given | Implicit)
21272127
}
21282128
else EmptyModifiers
2129-
val isContextual = initialMods.is(Contextual)
2129+
val isContextual = initialMods.is(Given)
21302130
newLineOptWhenFollowedBy(LPAREN)
21312131
if (in.token == LPAREN) {
21322132
if (ofInstance && !isContextual)
@@ -2137,14 +2137,14 @@ object Parsers {
21372137
firstClause = firstClause,
21382138
initialMods = initialMods)
21392139
val lastClause =
2140-
params.nonEmpty && params.head.mods.flags.is(Implicit, butNot = Contextual)
2140+
params.nonEmpty && params.head.mods.flags.is(Implicit, butNot = Given)
21412141
params :: (if (lastClause) Nil else recur(firstClause = false, nparams + params.length))
21422142
}
21432143
else if (isContextual) {
21442144
val tps = commaSeparated(refinedType)
21452145
var counter = nparams
21462146
def nextIdx = { counter += 1; counter }
2147-
val params = tps.map(makeSyntheticParameter(nextIdx, _, Contextual | Implicit))
2147+
val params = tps.map(makeSyntheticParameter(nextIdx, _, Given | Implicit))
21482148
params :: recur(firstClause = false, nparams + params.length)
21492149
}
21502150
else Nil
@@ -2438,7 +2438,7 @@ object Parsers {
24382438
objectDef(start, posMods(start, mods | Case | Module))
24392439
case ENUM =>
24402440
enumDef(start, mods, atSpan(in.skipToken()) { Mod.Enum() })
2441-
case INSTANCE =>
2441+
case IMPLIED =>
24422442
instanceDef(start, mods, atSpan(in.skipToken()) { Mod.Instance() })
24432443
case _ =>
24442444
syntaxErrorOrIncomplete(ExpectedStartOfTopLevelDefinition())

compiler/src/dotty/tools/dotc/parsing/Tokens.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ object Tokens extends TokensCommon {
178178
final val FORSOME = 61; enter(FORSOME, "forSome") // TODO: deprecate
179179
final val ENUM = 62; enter(ENUM, "enum")
180180
final val ERASED = 63; enter(ERASED, "erased")
181-
final val INSTANCE = 64; enter(INSTANCE, "implied")
181+
final val IMPLIED = 64; enter(IMPLIED, "implied")
182182
final val GIVEN = 65; enter(GIVEN, "given")
183183

184184
/** special symbols */
@@ -223,7 +223,7 @@ object Tokens extends TokensCommon {
223223

224224
final val templateIntroTokens: TokenSet = BitSet(CLASS, TRAIT, OBJECT, ENUM, CASECLASS, CASEOBJECT)
225225

226-
final val dclIntroTokens: TokenSet = BitSet(DEF, VAL, VAR, TYPE, INSTANCE)
226+
final val dclIntroTokens: TokenSet = BitSet(DEF, VAL, VAR, TYPE, IMPLIED)
227227

228228
final val defIntroTokens: TokenSet = templateIntroTokens | dclIntroTokens
229229

@@ -251,7 +251,7 @@ object Tokens extends TokensCommon {
251251

252252
final val numericLitTokens: TokenSet = BitSet(INTLIT, LONGLIT, FLOATLIT, DOUBLELIT)
253253

254-
final val scala3keywords = BitSet(ENUM, ERASED, GIVEN, INSTANCE)
254+
final val scala3keywords = BitSet(ENUM, ERASED, GIVEN, IMPLIED)
255255

256256
final val softModifierNames = Set(nme.inline, nme.opaque)
257257
}

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
520520
def argToText(arg: Tree) = arg match {
521521
case arg @ ValDef(name, tpt, _) =>
522522
val implicitText =
523-
if ((arg.mods is Contextual)) { contextual = true; "" }
523+
if ((arg.mods is Given)) { contextual = true; "" }
524524
else if ((arg.mods is Implicit) && !implicitSeen) { implicitSeen = true; keywordStr("implicit ") }
525525
else ""
526526
implicitText ~ toText(name) ~ optAscription(tpt)

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ object EtaExpansion extends LiftImpure {
210210
if (isLastApplication && mt.paramInfos.length == xarity) mt.paramInfos map (_ => TypeTree())
211211
else mt.paramInfos map TypeTree
212212
var paramFlag = Synthetic | Param
213-
if (mt.isContextual) paramFlag |= Contextual
213+
if (mt.isContextual) paramFlag |= Given
214214
if (mt.isImplicitMethod) paramFlag |= Implicit
215215
val params = (mt.paramNames, paramTypes).zipped.map((name, tpe) =>
216216
ValDef(name, tpe, EmptyTree).withFlags(paramFlag).withSpan(tree.span.startPos))
@@ -221,7 +221,7 @@ object EtaExpansion extends LiftImpure {
221221
if (mt.isContextual) body.pushAttachment(WithApply, ())
222222
if (!isLastApplication) body = PostfixOp(body, Ident(nme.WILDCARD))
223223
val fn =
224-
if (mt.isContextual) new untpd.FunctionWithMods(params, body, Modifiers(Implicit | Contextual))
224+
if (mt.isContextual) new untpd.FunctionWithMods(params, body, Modifiers(Implicit | Given))
225225
else if (mt.isImplicitMethod) new untpd.FunctionWithMods(params, body, Modifiers(Implicit))
226226
else untpd.Function(params, body)
227227
if (defs.nonEmpty) untpd.Block(defs.toList map (untpd.TypedSplice(_)), fn) else fn

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ trait NamerContextOps { this: Context =>
136136
(valueParamss :\ resultType) { (params, resultType) =>
137137
val (isImplicit, isErased, isContextual) =
138138
if (params.isEmpty) (false, false, false)
139-
else (params.head is Implicit, params.head is Erased, params.head.is(Contextual))
139+
else (params.head is Implicit, params.head is Erased, params.head.is(Given))
140140
val make = MethodType.maker(isJava = isJava, isImplicit = isImplicit, isErased = isErased, isContextual = isContextual)
141141
if (isJava)
142142
for (param <- params)

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ class Typer extends Namer
791791
}
792792

793793
val funCls = defn.FunctionClass(args.length,
794-
isContextual = funFlags.is(Contextual), isErased = funFlags.is(Erased))
794+
isContextual = funFlags.is(Given), isErased = funFlags.is(Erased))
795795

796796
/** Typechecks dependent function type with given parameters `params` */
797797
def typedDependent(params: List[ValDef])(implicit ctx: Context): Tree = {
@@ -801,7 +801,7 @@ class Typer extends Namer
801801
params1.foreach(_.symbol.setFlag(funFlags))
802802
val resultTpt = typed(body)
803803
val companion = MethodType.maker(
804-
isContextual = funFlags.is(Contextual), isErased = funFlags.is(Erased))
804+
isContextual = funFlags.is(Given), isErased = funFlags.is(Erased))
805805
val mt = companion.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
806806
if (mt.isParamDependent)
807807
ctx.error(i"$mt is an illegal function type because it has inter-parameter dependencies", tree.sourcePos)
@@ -829,7 +829,7 @@ class Typer extends Namer
829829
val untpd.Function(params: List[untpd.ValDef] @unchecked, body) = tree
830830

831831
val isContextual = tree match {
832-
case tree: untpd.FunctionWithMods => tree.mods.is(Contextual)
832+
case tree: untpd.FunctionWithMods => tree.mods.is(Given)
833833
case _ => false
834834
}
835835

0 commit comments

Comments
 (0)