Skip to content

Commit cf8fead

Browse files
Merge pull request #6649 from dotty-staging/add-contextual-delegate
Rename `implied` to `delegate`
2 parents db709ac + 2f85acb commit cf8fead

File tree

119 files changed

+679
-673
lines changed

Some content is hidden

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

119 files changed

+679
-673
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 6 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 7 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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
*/

0 commit comments

Comments
 (0)