Skip to content

Commit 57d5b21

Browse files
committed
Drop delegate
1 parent 8dbd8d4 commit 57d5b21

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,7 +2518,6 @@ object Parsers {
25182518
case ABSTRACT => Mod.Abstract()
25192519
case FINAL => Mod.Final()
25202520
case IMPLICIT => Mod.Implicit()
2521-
case IMPLIED => Mod.Given()
25222521
case GIVEN => Mod.Given()
25232522
case ERASED => Mod.Erased()
25242523
case LAZY => Mod.Lazy()
@@ -2622,10 +2621,10 @@ object Parsers {
26222621
* FunTypeMods ::= { ‘erased’ | ‘given’}
26232622
*/
26242623
val closureMods: BitSet =
2625-
if allowOldGiven then BitSet(GIVEN, IMPLIED, IMPLICIT, ERASED)
2624+
if allowOldGiven then BitSet(GIVEN, IMPLICIT, ERASED)
26262625
else BitSet(IMPLICIT, ERASED)
26272626

2628-
val funTypeMods: BitSet = BitSet(IMPLIED, ERASED)
2627+
val funTypeMods: BitSet = BitSet(ERASED)
26292628

26302629
val funTypeArgMods: BitSet = BitSet(GIVEN, ERASED)
26312630

@@ -2923,7 +2922,7 @@ object Parsers {
29232922
*/
29242923
def importClause(leading: Token, mkTree: ImportConstr): List[Tree] = {
29252924
val offset = accept(leading)
2926-
val importGiven = allowOldGiven && in.token == IMPLIED || in.token == GIVEN
2925+
val importGiven = allowOldGiven && in.token == GIVEN
29272926
if (importGiven) in.nextToken()
29282927
commaSeparated(importExpr(importGiven, mkTree)) match {
29292928
case t :: rest =>
@@ -3267,8 +3266,8 @@ object Parsers {
32673266
objectDef(start, posMods(start, mods | Case | Module))
32683267
case ENUM =>
32693268
enumDef(start, posMods(start, mods | Enum))
3270-
case IMPLIED | GIVEN =>
3271-
instanceDef(in.token == GIVEN, start, mods, atSpan(in.skipToken()) { Mod.Given() })
3269+
case GIVEN =>
3270+
instanceDef(start, mods, atSpan(in.skipToken()) { Mod.Given() })
32723271
case _ =>
32733272
syntaxErrorOrIncomplete(ExpectedStartOfTopLevelDefinition())
32743273
EmptyTree
@@ -3384,7 +3383,7 @@ object Parsers {
33843383
* GivenSig ::= [id] [DefTypeParamClause] {GivenParamClause}
33853384
* ExtParamClause ::= [DefTypeParamClause] DefParamClause {GivenParamClause}
33863385
*/
3387-
def instanceDef(newStyle: Boolean, start: Offset, mods: Modifiers, instanceMod: Mod) = atSpan(start, nameStart) {
3386+
def instanceDef(start: Offset, mods: Modifiers, instanceMod: Mod) = atSpan(start, nameStart) {
33883387
var mods1 = addMod(mods, instanceMod)
33893388
val hasGivenSig = followingIsGivenSig()
33903389
val name = if isIdent && hasGivenSig then ident() else EmptyTermName
@@ -3409,7 +3408,7 @@ object Parsers {
34093408
parseParams(isExtension = !hasGivenSig)
34103409
var oldSyntax = false
34113410
val parents =
3412-
if allowOldGiven && (!newStyle && in.token == FOR || isIdent(nme.as)) then
3411+
if allowOldGiven && isIdent(nme.as) then
34133412
oldSyntax = true
34143413
// for the moment, accept both `delegate for` and `given as`
34153414
in.nextToken()
@@ -3734,12 +3733,12 @@ object Parsers {
37343733
setLastStatOffset()
37353734
if (in.token == IMPORT)
37363735
stats ++= importClause(IMPORT, Import)
3737-
else if (in.token == IMPLIED || in.token == GIVEN) {
3736+
else if (in.token == GIVEN) {
37383737
val start = in.offset
37393738
val mods = modifiers(closureMods)
37403739
mods.mods match {
37413740
case givenMod :: Nil if !isBindingIntro =>
3742-
stats += instanceDef(true, start, EmptyModifiers, Mod.Given().withSpan(givenMod.span))
3741+
stats += instanceDef(start, EmptyModifiers, Mod.Given().withSpan(givenMod.span))
37433742
case _ =>
37443743
stats += implicitClosure(in.offset, Location.InBlock, mods)
37453744
}

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,9 @@ object Tokens extends TokensCommon {
182182
final val FORSOME = 61; enter(FORSOME, "forSome") // TODO: deprecate
183183
final val ENUM = 62; enter(ENUM, "enum")
184184
final val ERASED = 63; enter(ERASED, "erased")
185-
final val IMPLIED = 64; enter(IMPLIED, "delegate")
186-
final val GIVEN = 65; enter(GIVEN, "given")
187-
final val EXPORT = 66; enter(EXPORT, "export")
188-
final val MACRO = 67; enter(MACRO, "macro") // TODO: remove
185+
final val GIVEN = 64; enter(GIVEN, "given")
186+
final val EXPORT = 65; enter(EXPORT, "export")
187+
final val MACRO = 66; enter(MACRO, "macro") // TODO: remove
189188

190189
/** special symbols */
191190
final val NEWLINE = 78; enter(NEWLINE, "end of statement", "new line")
@@ -221,14 +220,14 @@ object Tokens extends TokensCommon {
221220
USCORE, NULL, THIS, SUPER, TRUE, FALSE, RETURN, QUOTEID, XMLSTART)
222221

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

226225
final val canStartTypeTokens: TokenSet = literalTokens | identifierTokens | BitSet(
227226
THIS, SUPER, USCORE, LPAREN, AT)
228227

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

231-
final val dclIntroTokens: TokenSet = BitSet(DEF, VAL, VAR, TYPE, IMPLIED, GIVEN)
230+
final val dclIntroTokens: TokenSet = BitSet(DEF, VAL, VAR, TYPE, GIVEN)
232231

233232
final val defIntroTokens: TokenSet = templateIntroTokens | dclIntroTokens
234233

@@ -245,8 +244,6 @@ object Tokens extends TokensCommon {
245244

246245
final val modifierFollowers = modifierTokens | defIntroTokens
247246

248-
final val paramIntroTokens: TokenSet = modifierTokens | identifierTokens | BitSet(AT, VAL, VAR, IMPLICIT)
249-
250247
/** Is token only legal as start of statement (eof also included)? */
251248
final val mustStartStatTokens: TokenSet = defIntroTokens | modifierTokens | BitSet(IMPORT, EXPORT, PACKAGE)
252249

@@ -268,7 +265,7 @@ object Tokens extends TokensCommon {
268265

269266
final val canStartIndentTokens: BitSet =
270267
statCtdTokens | BitSet(COLONEOL, EQUALS, ARROW, LARROW, WHILE, TRY, FOR)
271-
// `if` is excluded because it often comes after `else` which makes for awkward indentation rules
268+
// `if` is excluded because it often comes after `else` which makes for awkward indentation rules TODO: try to do without the exception
272269

273270
/** Faced with the choice between a type and a formal parameter, the following
274271
* tokens determine it's a formal parameter.
@@ -285,7 +282,7 @@ object Tokens extends TokensCommon {
285282
final val noIndentAfterConditionTokens = BitSet(THEN, DO)
286283
final val noIndentAfterEnumeratorTokens = BitSet(YIELD, DO)
287284

288-
final val scala3keywords = BitSet(ENUM, ERASED, GIVEN, IMPLIED)
285+
final val scala3keywords = BitSet(ENUM, ERASED, GIVEN)
289286

290287
final val softModifierNames = Set(nme.inline, nme.opaque)
291288
}

tests/new/test.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ trait T {
44
type U = (given Int) => Int
55
type V = (given Int) => Int
66

7-
val u = delegate (x: Int) => x
87
val v = given (x: Int) => x
98
val w = (given x: Int) => x
109
val w2: V = (given x) => x

tests/pos/i6997b.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package playground
22

3-
import scala.quoted._, scala.quoted.matching._
4-
import delegate scala.quoted._
3+
import scala.quoted.{_, given}, scala.quoted.matching._
54

65
inline def mcr(x: => Any): Any = ${mcrImpl('x)}
76

0 commit comments

Comments
 (0)