Skip to content

Commit 950d874

Browse files
committed
Rename implied to delegate
1 parent ed8c6ee commit 950d874

File tree

118 files changed

+678
-672
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+678
-672
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ object Flags {
392392
/** Symbol is a Java default method */
393393
final val DefaultMethod: FlagSet = termFlag(38, "<defaultmethod>")
394394

395-
final val Implied: FlagSet = commonFlag(39, "implied")
395+
final val Implied: FlagSet = commonFlag(39, "delegate")
396396

397397
/** Symbol is an enum class or enum case (if used with case) */
398398
final val Enum: FlagSet = commonFlag(40, "<enum>")

compiler/src/dotty/tools/dotc/interactive/Completion.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ object Completion {
121121
if (buffer.mode != Mode.None) {
122122
path match {
123123
case Select(qual, _) :: _ => buffer.addMemberCompletions(qual)
124-
case Import(_, expr, _) :: _ => buffer.addMemberCompletions(expr) // TODO: distinguish implied from non-implied
124+
case Import(_, expr, _) :: _ => buffer.addMemberCompletions(expr) // TODO: distinguish delegate from non-delegate
125125
case (_: Thicket) :: Import(_, expr, _) :: _ => buffer.addMemberCompletions(expr)
126126
case _ => buffer.addScopeCompletions
127127
}

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ object Parsers {
12661266
* | SimpleExpr1 ArgumentExprs `=' Expr
12671267
* | Expr2
12681268
* | [‘inline’] Expr2 `match' `{' CaseClauses `}'
1269-
* | `implied' `match' `{' ImplicitCaseClauses `}'
1269+
* | `delegate' `match' `{' ImplicitCaseClauses `}'
12701270
* Bindings ::= `(' [Binding {`,' Binding}] `)'
12711271
* Binding ::= (id | `_') [`:' Type]
12721272
* Expr2 ::= PostfixExpr [Ascription]
@@ -1470,7 +1470,7 @@ object Parsers {
14701470
*/
14711471
def impliedMatch(start: Int, imods: Modifiers) = {
14721472
def markFirstIllegal(mods: List[Mod]) = mods match {
1473-
case mod :: _ => syntaxError(em"illegal modifier for implied match", mod.span)
1473+
case mod :: _ => syntaxError(em"illegal modifier for delegate match", mod.span)
14741474
case _ =>
14751475
}
14761476
imods.mods match {
@@ -1485,7 +1485,7 @@ object Parsers {
14851485
case pat => isVarPattern(pat)
14861486
}
14871487
if (!isImplicitPattern(pat))
1488-
syntaxError(em"not a legal pattern for an implied match", pat.span)
1488+
syntaxError(em"not a legal pattern for a delegate match", pat.span)
14891489
}
14901490
result
14911491
}
@@ -2351,8 +2351,8 @@ object Parsers {
23512351

23522352
type ImportConstr = (Boolean, Tree, List[Tree]) => Tree
23532353

2354-
/** Import ::= import [implied] [ImportExpr {`,' ImportExpr}
2355-
* Export ::= export [implied] [ImportExpr {`,' ImportExpr}
2354+
/** Import ::= import [delegate] [ImportExpr {`,' ImportExpr}
2355+
* Export ::= export [delegate] [ImportExpr {`,' ImportExpr}
23562356
*/
23572357
def importClause(leading: Token, mkTree: ImportConstr): List[Tree] = {
23582358
val offset = accept(leading)
@@ -2383,7 +2383,7 @@ object Parsers {
23832383
wildcardIdent() :: Nil
23842384
case FOR =>
23852385
if (!importImplied)
2386-
syntaxError(em"`for` qualifier only allowed in `import implied`")
2386+
syntaxError(em"`for` qualifier only allowed in `import delegate`")
23872387
atSpan(in.skipToken()) {
23882388
var t = infixType()
23892389
while (in.token == COMMA) {

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

+1-1
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 IMPLIED = 64; enter(IMPLIED, "implied")
181+
final val IMPLIED = 64; enter(IMPLIED, "delegate")
182182
final val GIVEN = 65; enter(GIVEN, "given")
183183
final val EXPORT = 66; enter(EXPORT, "export")
184184
final val MACRO = 67; enter(MACRO, "macro") // TODO: remove

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
509509
case id :: Nil => toText(id)
510510
case _ => "{" ~ Text(selectors map selectorText, ", ") ~ "}"
511511
}
512-
keywordText("import ") ~ (keywordText("implied ") provided importImplied) ~
512+
keywordText("import ") ~ (keywordText("delegate ") provided importImplied) ~
513513
toTextLocal(expr) ~ "." ~ selectorsText
514514
case packageDef: PackageDef =>
515515
packageDefText(packageDef)
@@ -815,7 +815,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
815815
if (ctx.settings.YdebugFlags.value) AnyFlags
816816
else if (suppressKw) PrintableFlags(isType) &~ Private
817817
else PrintableFlags(isType)
818-
if (homogenizedView && mods.flags.isTypeFlags) flagMask &~= ImplicitOrImplied // drop implicit/implied from classes
818+
if (homogenizedView && mods.flags.isTypeFlags) flagMask &~= ImplicitOrImplied // drop implicit/delegate from classes
819819
val rawFlags = if (sym.exists) sym.flags else mods.flags
820820
if (rawFlags.is(Param)) flagMask = flagMask &~ Given
821821
val flags = rawFlags & flagMask

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
13171317
*
13181318
* T => R <:s U => R
13191319
*
1320-
* Also: If a compared type refers to an implied object or its module class, use
1320+
* Also: If a compared type refers to an delegate or its module class, use
13211321
* the intersection of its parent classes instead.
13221322
*/
13231323
def isAsSpecificValueType(tp1: Type, tp2: Type)(implicit ctx: Context) =
@@ -1342,22 +1342,22 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
13421342
(prepare(tp1) relaxed_<:< prepare(tp2)) || viewExists(tp1, tp2)
13431343
}
13441344

1345-
/** Widen the result type of synthetic implied methods from the implementation class to the
1345+
/** Widen the result type of synthetic delegate methods from the implementation class to the
13461346
* type that's implemented. Example
13471347
*
1348-
* implied I[X] for T { ... }
1348+
* delegate I[X] for T { ... }
13491349
*
13501350
* This desugars to
13511351
*
13521352
* class I[X] extends T { ... }
1353-
* implied def I[X]: I[X] = new I[X]
1353+
* implicit def I[X]: I[X] = new I[X]
13541354
*
13551355
* To compare specificity we should compare with `T`, not with its implementation `I[X]`.
1356-
* No such widening is performed for implied aliases, which are not synthetic. E.g.
1356+
* No such widening is performed for delegate aliases, which are not synthetic. E.g.
13571357
*
1358-
* implied J[X] for T = rhs
1358+
* delegate J[X] for T = rhs
13591359
*
1360-
* already has the right result type `T`. Neither is widening performed for implied
1360+
* already has the right result type `T`. Neither is widening performed for delegate
13611361
* objects, since these are anyway taken to be more specific than methods
13621362
* (by condition 3a above).
13631363
*/

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ trait Implicits { self: Typer =>
11581158
case fail: SearchFailureType =>
11591159

11601160
def hiddenImplicitNote(s: SearchSuccess) =
1161-
em"\n\nNote: implied instance ${s.ref.symbol.showLocated} was not considered because it was not imported with an `import implied`."
1161+
em"\n\nNote: delegate ${s.ref.symbol.showLocated} was not considered because it was not imported with `import delegate`."
11621162

11631163
def FindHiddenImplicitsCtx(ctx: Context): Context =
11641164
if (ctx == NoContext) ctx

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object ImportInfo {
2828
* @param selectors The selector clauses
2929
* @param symNameOpt Optionally, the name of the import symbol. None for root imports.
3030
* Defined for all explicit imports from ident or select nodes.
31-
* @param importImplied true if this is an implied import
31+
* @param importImplied true if this is a delegate import
3232
* @param isRootImport true if this is one of the implicit imports of scala, java.lang,
3333
* scala.Predef or dotty.DottyPredef in the start context, false otherwise.
3434
*/

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
720720
/** Reduce an inline match
721721
* @param mtch the match tree
722722
* @param scrutinee the scrutinee expression, assumed to be pure, or
723-
* EmptyTree for an implied match
723+
* EmptyTree for a delegate match
724724
* @param scrutType its fully defined type, or
725-
* ImplicitScrutineeTypeRef for an implied match
725+
* ImplicitScrutineeTypeRef for a delegate match
726726
* @param typer The current inline typer
727727
* @return optionally, if match can be reduced to a matching case: A pair of
728728
* bindings for all pattern-bound variables and the RHS of the case.
@@ -1036,10 +1036,10 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
10361036
def patStr(cdef: untpd.CaseDef) = i"case ${cdef.pat}${guardStr(cdef.guard)}"
10371037
val msg =
10381038
if (tree.selector.isEmpty)
1039-
em"""cannot reduce implied match with
1039+
em"""cannot reduce delegate match with
10401040
| patterns : ${tree.cases.map(patStr).mkString("\n ")}"""
10411041
else
1042-
em"""cannot reduce inline match with
1042+
em"""cannot reduce delegate match with
10431043
| scrutinee: $sel : ${selType}
10441044
| patterns : ${tree.cases.map(patStr).mkString("\n ")}"""
10451045
errorTree(tree, msg)

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ class Namer { typer: Typer =>
940940

941941
def whyNoForwarder(mbr: SingleDenotation): String = {
942942
val sym = mbr.symbol
943-
if (sym.is(ImplicitOrImpliedOrGiven) != exp.impliedOnly) s"is ${if (exp.impliedOnly) "not " else ""}implied"
943+
if (sym.is(ImplicitOrImpliedOrGiven) != exp.impliedOnly) s"is ${if (exp.impliedOnly) "not " else ""}a delegate"
944944
else if (!sym.isAccessibleFrom(path.tpe)) "is not accessible"
945945
else if (sym.isConstructor || sym.is(ModuleClass) || sym.is(Bridge)) SKIP
946946
else if (cls.derivesFrom(sym.owner) &&

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,7 @@ class Typer extends Namer
10291029
tree.selector match {
10301030
case EmptyTree =>
10311031
if (tree.isInline) {
1032-
checkInInlineContext("implied match", tree.posd)
1032+
checkInInlineContext("delegate match", tree.posd)
10331033
val cases1 = tree.cases.mapconserve {
10341034
case cdef @ CaseDef(pat @ Typed(Ident(nme.WILDCARD), _), _, _) =>
10351035
// case _ : T --> case evidence$n : T

compiler/src/dotty/tools/io/ZipArchive.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ final class FileZipArchive(jpath: JPath) extends ZipArchive(jpath) {
126126
override def input: InputStream = {
127127
val zipFile = openZipFile()
128128
val entry = zipFile.getEntry(name)
129-
val delegate = zipFile.getInputStream(entry)
130-
new FilterInputStream(delegate) {
129+
val `delegate` = zipFile.getInputStream(entry)
130+
new FilterInputStream(`delegate`) {
131131
override def close(): Unit = { zipFile.close() }
132132
}
133133
}

compiler/test/dotty/tools/repl/ReplCompilerTests.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class ReplCompilerTests extends ReplTest {
129129
}
130130

131131
@Test def i5897 =
132-
fromInitialState { implicit state => run("implied for Int = 10") }
132+
fromInitialState { implicit state => run("delegate for Int = 10") }
133133
.andThen { implicit state =>
134134
assertEquals(
135135
"def Int_instance: Int",
@@ -151,7 +151,7 @@ class ReplCompilerTests extends ReplTest {
151151
| def (x: T) > (y: T) = compare(x, y) > 0
152152
|}
153153
|
154-
|implied IntOrd for Ord[Int] {
154+
|delegate IntOrd for Ord[Int] {
155155
| def compare(x: Int, y: Int) =
156156
| if (x < y) -1 else if (x > y) +1 else 0
157157
|}

docs/docs/internals/syntax.md

+14-16
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ semi ::= ‘;’ | nl {nl}
9292
### Regular keywords
9393

9494
```
95-
abstract case catch class def do else enum
96-
erased extends false final finally for given if
97-
implicit implied import lazy match new null object
95+
abstract case catch class def delegate do else
96+
enum export extends false final finally for given
97+
if implicit import lazy match new null object
9898
package private protected override return super sealed then
9999
throw trait true try type val var while
100100
with yield
@@ -143,7 +143,7 @@ Type ::= FunType
143143
| HkTypeParamClause ‘=>>’ Type TypeLambda(ps, t)
144144
| MatchType
145145
| InfixType
146-
FunType ::= { 'erased' | 'given' } (MonoFunType | PolyFunType)
146+
FunType ::= ['given'] (MonoFunType | PolyFunType)
147147
MonoFunType ::= FunArgTypes ‘=>’ Type Function(ts, t)
148148
PolyFunType :: = HKTypeParamClause '=>' Type PolyFunction(ps, t)
149149
FunArgTypes ::= InfixType
@@ -298,8 +298,8 @@ HkTypeParam ::= {Annotation} [‘+’ | ‘-’] (Id[HkTypeParamClause] |
298298
299299
ClsParamClauses ::= {ClsParamClause} [[nl] ‘(’ [‘implicit’] ClsParams ‘)’]
300300
| {ClsParamClause} {GivenClsParamClause}
301-
ClsParamClause ::= [‘erased’] (‘(’ ClsParams ‘)’
302-
GivenClsParamClause::= ‘given’ [‘erased’] (‘(’ ClsParams ‘)’ | GivenTypes)
301+
ClsParamClause ::= ‘(’ ClsParams ‘)’
302+
GivenClsParamClause::= ‘given’ (‘(’ ClsParams ‘)’ | GivenTypes)
303303
ClsParams ::= ClsParam {‘,’ ClsParam}
304304
ClsParam ::= {Annotation} ValDef(mods, id, tpe, expr) -- point of mods on val/var
305305
[{Modifier} (‘val’ | ‘var’) | ‘inline’] Param
@@ -308,12 +308,12 @@ Param ::= id ‘:’ ParamType [‘=’ Expr]
308308
309309
DefParamClauses ::= {DefParamClause} [[nl] ‘(’ [‘implicit’] DefParams ‘)’]
310310
| {DefParamClause} {GivenParamClause}
311-
DefParamClause ::= [‘erased’] (‘(’ DefParams ‘)’
312-
GivenParamClause ::= ‘given’ [‘erased’] (‘(’ DefParams ‘)’ | GivenTypes)
311+
DefParamClause ::= ‘(’ DefParams ‘)’
312+
GivenParamClause ::= ‘given’ (‘(’ DefParams ‘)’ | GivenTypes)
313313
DefParams ::= DefParam {‘,’ DefParam}
314314
DefParam ::= {Annotation} [‘inline’] Param ValDef(mods, id, tpe, expr) -- point of mods at id.
315315
GivenTypes ::= AnnotType {‘,’ AnnotType}
316-
ClosureMods ::= { ‘implicit’ | ‘erased’ | ‘given’}
316+
ClosureMods ::= { ‘implicit’ | ‘given’}
317317
```
318318

319319
### Bindings and Imports
@@ -331,20 +331,19 @@ LocalModifier ::= ‘abstract’
331331
| ‘implicit’
332332
| ‘lazy’
333333
| ‘inline’
334-
| ‘erased’
335334
AccessModifier ::= (‘private’ | ‘protected’) [AccessQualifier]
336335
AccessQualifier ::= ‘[’ (id | ‘this’) ‘]’
337336
338337
Annotation ::= ‘@’ SimpleType {ParArgumentExprs} Apply(tpe, args)
339338
340-
Import ::= ‘import’ [‘implied’] ImportExpr {‘,’ ImportExpr}
339+
Import ::= ‘import’ [‘delegate’] ImportExpr {‘,’ ImportExpr}
341340
ImportExpr ::= StableId ‘.’ (id | ‘_’ | ImportSelectors) Import(expr, sels)
342341
ImportSelectors ::= ‘{’ {ImportSelector ‘,’} FinalSelector ‘}’
343342
FinalSelector ::= ImportSelector Ident(name)
344343
| ‘_’ Pair(id, id)
345344
| ‘for’ InfixType {‘,’ InfixType} TypeBoundsTree(EmptyTree, tpt)
346345
ImportSelector ::= id [‘=>’ id | ‘=>’ ‘_’]
347-
Export ::= ‘export’ [‘implied’] ImportExpr {‘,’ ImportExpr}
346+
Export ::= ‘export’ [‘delegate’] ImportExpr {‘,’ ImportExpr}
348347
```
349348

350349
### Declarations and Definitions
@@ -380,16 +379,15 @@ DefDef ::= DefSig [(‘:’ | ‘<:’) Type] ‘=’ Expr
380379
TmplDef ::= ([‘case’] ‘class’ | ‘trait’) ClassDef
381380
| [‘case’] ‘object’ ObjectDef
382381
| ‘enum’ EnumDef
383-
| ‘implied’ InstanceDef
382+
| ‘delegate’ DelegateDef
384383
| Export
385384
ClassDef ::= id ClassConstr [Template] ClassDef(mods, name, tparams, templ)
386385
ClassConstr ::= [ClsTypeParamClause] [ConstrMods] ClsParamClauses with DefDef(_, <init>, Nil, vparamss, EmptyTree, EmptyTree) as first stat
387386
ConstrMods ::= {Annotation} [AccessModifier]
388387
ObjectDef ::= id [Template] ModuleDef(mods, name, template) // no constructor
389388
EnumDef ::= id ClassConstr InheritClauses EnumBody EnumDef(mods, name, tparams, template)
390-
InstanceDef ::= [id] [DefTypeParamClause] InstanceBody
391-
InstanceParams ::= [DefTypeParamClause] {GivenParamClause}
392-
InstanceBody ::= [‘for’ ConstrApp {‘,’ ConstrApp }] {GivenParamClause} [TemplateBody]
389+
DelegateDef ::= [id] [DefTypeParamClause] DelegateBody
390+
DelegateBody ::= [‘for’ ConstrApp {‘,’ ConstrApp }] {GivenParamClause} [TemplateBody]
393391
| ‘for’ Type {GivenParamClause} ‘=’ Expr
394392
Template ::= InheritClauses [TemplateBody] Template(constr, parents, self, stats)
395393
InheritClauses ::= [‘extends’ ConstrApps] [‘derives’ QualId {‘,’ QualId}]

docs/docs/reference/changed-features/implicit-resolution.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ affect implicits on the language level.
4343
Example:
4444

4545
package p
46-
implied a for A
46+
delegate a for A
4747

4848
object o {
49-
implied b for B
49+
delegate b for B
5050
type C
5151
}
5252

docs/docs/reference/contextual/context-bounds.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ title: "Context Bounds"
55

66
## Context Bounds
77

8-
A context bound is a shorthand for expressing a common pattern of a context parameter that depends on a type parameter. Using a context bound, the `maximum` function of the last section can be written like this:
8+
A context bound is a shorthand for expressing the common pattern of an implicit parameter that depends on a type parameter. Using a context bound, the `maximum` function of the last section can be written like this:
99
```scala
1010
def maximum[T: Ord](xs: List[T]): T = xs.reduceLeft(max)
1111
```
12-
A bound like `: Ord` on a type parameter `T` of a method or class indicates a context parameter `given Ord[T]`. The context parameter(s) generated from context bounds come last in the definition of the containing method or class. E.g.,
12+
A bound like `: Ord` on a type parameter `T` of a method or class indicates an implicit parameter `given Ord[T]`. The implicit parameter(s) generated from context bounds come last in the definition of the containing method or class. E.g.,
1313
```scala
1414
def f[T: C1 : C2, U: C3](x: T) given (y: U, z: V): R
1515
```

0 commit comments

Comments
 (0)