Skip to content

Commit d4e6cbd

Browse files
committed
Drop delegate match syntax
Drop `delegate match` and `given match`. They are replaced by `summonFrom`.
1 parent 2b8ba68 commit d4e6cbd

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ object Parsers {
203203
} && !in.isSoftModifierInModifierPosition
204204

205205
def isExprIntro: Boolean =
206-
if (in.token == IMPLIED || in.token == GIVEN) in.lookaheadIn(BitSet(MATCH))
207-
else (canStartExpressionTokens.contains(in.token) && !in.isSoftModifierInModifierPosition)
206+
if (in.token == GIVEN) false
207+
else canStartExpressionTokens.contains(in.token) && !in.isSoftModifierInModifierPosition
208208

209209
def isDefIntro(allowedMods: BitSet, excludedSoftModifiers: Set[TermName] = Set.empty): Boolean =
210210
in.token == AT ||
@@ -1646,15 +1646,6 @@ object Parsers {
16461646
if (in.token == MATCH) impliedMatch(start, imods)
16471647
else implicitClosure(start, location, imods)
16481648
}
1649-
else if (in.token == IMPLIED || in.token == GIVEN) {
1650-
in.nextToken()
1651-
if (in.token == MATCH)
1652-
impliedMatch(start, EmptyModifiers)
1653-
else {
1654-
syntaxError("`match` expected")
1655-
EmptyTree
1656-
}
1657-
}
16581649
else {
16591650
val saved = placeholderParams
16601651
placeholderParams = Nil
@@ -3316,10 +3307,17 @@ object Parsers {
33163307
Template(constr, parents, Nil, EmptyValDef, Nil)
33173308
}
33183309

3319-
/** GivenDef ::= [id] [DefTypeParamClause] GivenBody
3320-
* GivenBody ::= [‘as ConstrApp {‘,’ ConstrApp }] {GivenParamClause} [TemplateBody]
3321-
* | ‘as’ Type {GivenParamClause} ‘=’ Expr
3322-
* | ‘(’ DefParam ‘)’ TemplateBody
3310+
/** OLD:
3311+
* GivenDef ::= [id] [DefTypeParamClause] GivenBody
3312+
* GivenBody ::= [‘as ConstrApp {‘,’ ConstrApp }] {GivenParamClause} [TemplateBody]
3313+
* | ‘as’ Type {GivenParamClause} ‘=’ Expr
3314+
* | ‘(’ DefParam ‘)’ TemplateBody
3315+
* NEW:
3316+
* GivenDef ::= [GivenSig (‘:’ | <:)] Type ‘=’ Expr
3317+
* | [GivenSig ‘:’] [ConstrApp {‘,’ ConstrApp }] [TemplateBody]
3318+
* // | [id ‘:’] [ExtParamClause] TemplateBody (not yet implemented)
3319+
* ExtParamClause ::= [DefTypeParamClause] DefParamClause {GivenParamClause}
3320+
* GivenSig ::= [id] [DefTypeParamClause] {GivenParamClause}
33233321
*/
33243322
def instanceDef(newStyle: Boolean, start: Offset, mods: Modifiers, instanceMod: Mod) = atSpan(start, nameStart) {
33253323
var mods1 = addMod(mods, instanceMod)

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

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

223223
final val canStartExpressionTokens: TokenSet = atomicExprTokens | BitSet(
224-
LBRACE, LPAREN, INDENT, QUOTE, IF, DO, WHILE, FOR, NEW, TRY, THROW, IMPLIED, GIVEN)
224+
LBRACE, LPAREN, INDENT, QUOTE, IF, DO, WHILE, FOR, NEW, TRY, THROW, GIVEN)
225225

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

0 commit comments

Comments
 (0)