Skip to content

Commit 1b9d69f

Browse files
committed
Rename implicit match to implied match
1 parent 9465001 commit 1b9d69f

30 files changed

+93
-90
lines changed

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ object Parsers {
198198
!in.isSoftModifierInModifierPosition
199199

200200
def isExprIntro: Boolean =
201+
// if (in.token == IMPLIED) in.lookaheadIn(BitSet(MATCH))
202+
// else
201203
canStartExpressionTokens.contains(in.token) &&
202204
!in.isSoftModifierInModifierPosition
203205

@@ -1265,7 +1267,7 @@ object Parsers {
12651267
* | SimpleExpr1 ArgumentExprs `=' Expr
12661268
* | Expr2
12671269
* | [‘inline’] Expr2 `match' `{' CaseClauses `}'
1268-
* | `implicit' `match' `{' ImplicitCaseClauses `}'
1270+
* | `implied' `match' `{' ImplicitCaseClauses `}'
12691271
* Bindings ::= `(' [Binding {`,' Binding}] `)'
12701272
* Binding ::= (id | `_') [`:' Type]
12711273
* Expr2 ::= PostfixExpr [Ascription]
@@ -1280,8 +1282,8 @@ object Parsers {
12801282
def expr(location: Location.Value): Tree = {
12811283
val start = in.offset
12821284
if (closureMods.contains(in.token)) {
1283-
val imods = modifiers(closureMods)
1284-
if (in.token == MATCH) implicitMatch(start, imods)
1285+
val imods = modifiers(closureMods + IMPLIED)
1286+
if (in.token == MATCH) impliedMatch(start, imods)
12851287
else implicitClosure(start, location, imods)
12861288
} else {
12871289
val saved = placeholderParams
@@ -1457,13 +1459,13 @@ object Parsers {
14571459

14581460
/** `match' { ImplicitCaseClauses }
14591461
*/
1460-
def implicitMatch(start: Int, imods: Modifiers) = {
1462+
def impliedMatch(start: Int, imods: Modifiers) = {
14611463
def markFirstIllegal(mods: List[Mod]) = mods match {
1462-
case mod :: _ => syntaxError(em"illegal modifier for implicit match", mod.span)
1464+
case mod :: _ => syntaxError(em"illegal modifier for implied match", mod.span)
14631465
case _ =>
14641466
}
14651467
imods.mods match {
1466-
case Mod.Implicit() :: mods => markFirstIllegal(mods)
1468+
case Mod.Instance() :: mods => markFirstIllegal(mods)
14671469
case mods => markFirstIllegal(mods)
14681470
}
14691471
val result @ Match(t, cases) =
@@ -1474,7 +1476,7 @@ object Parsers {
14741476
case pat => isVarPattern(pat)
14751477
}
14761478
if (!isImplicitPattern(pat))
1477-
syntaxError(em"not a legal pattern for an implicit match", pat.span)
1479+
syntaxError(em"not a legal pattern for an implied match", pat.span)
14781480
}
14791481
result
14801482
}
@@ -1999,6 +2001,7 @@ object Parsers {
19992001
case ABSTRACT => Mod.Abstract()
20002002
case FINAL => Mod.Final()
20012003
case IMPLICIT => Mod.Implicit()
2004+
case IMPLIED => Mod.Instance()
20022005
case GIVEN => Mod.Given()
20032006
case ERASED => Mod.Erased()
20042007
case LAZY => Mod.Lazy()
@@ -3084,11 +3087,11 @@ object Parsers {
30843087
else if (isDefIntro(localModifierTokens))
30853088
if (closureMods.contains(in.token)) {
30863089
val start = in.offset
3087-
var imods = modifiers(closureMods)
3090+
var imods = modifiers(closureMods + IMPLIED)
30883091
if (isBindingIntro)
30893092
stats += implicitClosure(start, Location.InBlock, imods)
30903093
else if (in.token == MATCH)
3091-
stats += implicitMatch(start, imods)
3094+
stats += impliedMatch(start, imods)
30923095
else
30933096
stats +++= localDef(start, imods)
30943097
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ object Tokens extends TokensCommon {
216216
USCORE, NULL, THIS, SUPER, TRUE, FALSE, RETURN, QUOTEID, XMLSTART)
217217

218218
final val canStartExpressionTokens: TokenSet = atomicExprTokens | BitSet(
219-
LBRACE, LPAREN, QUOTE, IF, DO, WHILE, FOR, NEW, TRY, THROW)
219+
LBRACE, LPAREN, QUOTE, IF, DO, WHILE, FOR, NEW, TRY, THROW, IMPLIED)
220220

221221
final val canStartTypeTokens: TokenSet = literalTokens | identifierTokens | BitSet(
222222
THIS, SUPER, USCORE, LPAREN, AT)

compiler/src/dotty/tools/dotc/transform/FirstTransform.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
111111
.appliedTo(Literal(Constant(s"native method stub"))))
112112

113113
}
114-
else ddef
114+
ddef
115115
}
116116

117117
override def transformStats(trees: List[Tree])(implicit ctx: Context): List[Tree] =

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

Lines changed: 3 additions & 3 deletions
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 implicit match
723+
* EmptyTree for an implied match
724724
* @param scrutType its fully defined type, or
725-
* ImplicitScrutineeTypeRef for an implicit match
725+
* ImplicitScrutineeTypeRef for an implied 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,7 +1036,7 @@ 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 implicit match with
1039+
em"""cannot reduce implied match with
10401040
| patterns : ${tree.cases.map(patStr).mkString("\n ")}"""
10411041
else
10421042
em"""cannot reduce inline match with

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ class Typer extends Namer
10211021
tree.selector match {
10221022
case EmptyTree =>
10231023
if (tree.isInline) {
1024-
checkInInlineContext("implicit match", tree.posd)
1024+
checkInInlineContext("implied match", tree.posd)
10251025
val cases1 = tree.cases.mapconserve {
10261026
case cdef @ CaseDef(pat @ Typed(Ident(nme.WILDCARD), _), _, _) =>
10271027
// case _ : T --> case evidence$n : T

library/src/scala/tasty/reflect/Core.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ trait Core {
209209
/** Tree representing a pattern match `x match { ... }` in the source code */
210210
type Match = kernel.Match
211211

212-
/** Tree representing a pattern match `implicit match { ... }` in the source code */
212+
/** Tree representing a pattern match `implied match { ... }` in the source code */
213213
type ImplicitMatch = kernel.ImplicitMatch
214214

215215
/** Tree representing a try catch `try x catch { ... } finally { ... }` in the source code */

library/src/scala/tasty/reflect/Kernel.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ trait Kernel {
475475
def Match_apply(selector: Term, cases: List[CaseDef])(implicit ctx: Context): Match
476476
def Match_copy(original: Tree)(selector: Term, cases: List[CaseDef])(implicit ctx: Context): Match
477477

478-
/** Tree representing a pattern match `implicit match { ... }` in the source code */
478+
/** Tree representing a pattern match `implied match { ... }` in the source code */
479479
type ImplicitMatch <: Term
480480

481481
def matchImplicitMatch(tree: Tree)(implicit ctx: Context): Option[ImplicitMatch]

library/src/scala/tasty/reflect/Printers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ trait Printers
910910
inBlock(printCases(cases, lineBreak()))
911911

912912
case ImplicitMatch(cases) =>
913-
this += highlightKeyword("implicit match", color)
913+
this += highlightKeyword("implied match", color)
914914
inBlock(printCases(cases, lineBreak()))
915915

916916
case Try(body, cases, finallyOpt) =>

library/src/scala/tasty/reflect/TreeOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,14 +594,14 @@ trait TreeOps extends Core {
594594
/** Scala implicit `match` term */
595595
object ImplicitMatch {
596596

597-
/** Creates a pattern match `implicit match { <cases: List[CaseDef]> }` */
597+
/** Creates a pattern match `implied match { <cases: List[CaseDef]> }` */
598598
def apply(cases: List[CaseDef])(implicit ctx: Context): ImplicitMatch =
599599
kernel.ImplicitMatch_apply(cases)
600600

601601
def copy(original: Tree)(cases: List[CaseDef])(implicit ctx: Context): ImplicitMatch =
602602
kernel.ImplicitMatch_copy(original)(cases)
603603

604-
/** Matches a pattern match `implicit match { <cases: List[CaseDef]> }` */
604+
/** Matches a pattern match `implied match { <cases: List[CaseDef]> }` */
605605
def unapply(tree: Tree)(implicit ctx: Context): Option[List[CaseDef]] =
606606
kernel.matchImplicitMatch(tree).map(_.cases)
607607

tests/invalid/neg/implicitMatch-ambiguous.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ object Test {
44
implicit val a1: A = new A
55
implicit val a2: A = new A
66

7-
inline def f: Any = implicit match {
7+
inline def f: Any = implied match {
88
case _: A => ??? // error: ambiguous implicits
99
}
1010

0 commit comments

Comments
 (0)