Skip to content

Commit d03f9a4

Browse files
committed
Merge Delegate and Given flags
Do the same for IMPLIED and GIVEN Tasty tags.
1 parent 8095c23 commit d03f9a4

28 files changed

+55
-69
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ object desugar {
750750
// synthetic implicit C[Ts](p11: T11, ..., p1N: T1N) ... (pM1: TM1, ..., pMN: TMN): C[Ts] =
751751
// new C[Ts](p11, ..., p1N) ... (pM1, ..., pMN) =
752752
val implicitWrappers =
753-
if (!mods.isOneOf(DelegateOrImplicit))
753+
if (!mods.isOneOf(GivenOrImplicit))
754754
Nil
755755
else if (ctx.owner.is(Package)) {
756756
ctx.error(TopLevelImplicitClass(cdef), cdef.sourcePos)
@@ -764,7 +764,7 @@ object desugar {
764764
ctx.error(ImplicitCaseClass(cdef), cdef.sourcePos)
765765
Nil
766766
}
767-
else if (arity != 1 && !mods.is(Delegate)) {
767+
else if (arity != 1 && !mods.is(Given)) {
768768
ctx.error(ImplicitClassPrimaryConstructorArity(), cdef.sourcePos)
769769
Nil
770770
}
@@ -778,7 +778,7 @@ object desugar {
778778
// implicit wrapper is typechecked in same scope as constructor, so
779779
// we can reuse the constructor parameters; no derived params are needed.
780780
DefDef(className.toTermName, constrTparams, defParamss, classTypeRef, creatorExpr)
781-
.withMods(companionMods | mods.flags.toTermFlags & DelegateOrImplicit | Synthetic | Final)
781+
.withMods(companionMods | mods.flags.toTermFlags & GivenOrImplicit | Synthetic | Final)
782782
.withSpan(cdef.span) :: Nil
783783
}
784784

@@ -1177,14 +1177,14 @@ object desugar {
11771177
*/
11781178
def packageDef(pdef: PackageDef)(implicit ctx: Context): PackageDef = {
11791179
def isWrappedType(stat: TypeDef): Boolean =
1180-
!stat.isClassDef || stat.mods.isOneOf(DelegateOrImplicit)
1180+
!stat.isClassDef || stat.mods.isOneOf(GivenOrImplicit)
11811181
val wrappedTypeNames = pdef.stats.collect {
11821182
case stat: TypeDef if isWrappedType(stat) => stat.name
11831183
}
11841184
def needsObject(stat: Tree) = stat match {
11851185
case _: ValDef | _: PatDef | _: DefDef | _: Export => true
11861186
case stat: ModuleDef =>
1187-
stat.mods.isOneOf(DelegateOrImplicit) ||
1187+
stat.mods.isOneOf(GivenOrImplicit) ||
11881188
wrappedTypeNames.contains(stat.name.stripModuleClassSuffix.toTypeName)
11891189
case stat: TypeDef => isWrappedType(stat)
11901190
case _ => false

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ object Trees {
754754
def unforced: LazyTree[T] = preRhs
755755
protected def force(x: Tree[T @uncheckedVariance]): Unit = preRhs = x
756756

757-
override def disableOverlapChecks = rawMods.is(Delegate)
757+
override def disableOverlapChecks = rawMods.is(Given)
758758
// disable order checks for implicit aliases since their given clause follows
759759
// their for clause, but the two appear swapped in the DefDef.
760760
}

compiler/src/dotty/tools/dotc/ast/untpd.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo {
165165
case class Lazy()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Lazy)
166166

167167
case class Inline()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Inline)
168-
169-
case class Delegate()(implicit @constructorOnly src: SourceFile) extends Mod(Flags.Delegate)
170168
}
171169

172170
/** Modifiers and annotations for definitions

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import Scopes._
1313
import Uniques._
1414
import ast.Trees._
1515
import ast.untpd
16-
import Flags.DelegateOrGivenOrImplicit
16+
import Flags.GivenOrImplicit
1717
import util.{FreshNameCreator, NoSource, SimpleIdentityMap, SourceFile}
1818
import typer.{Implicits, ImportInfo, Inliner, NamerContextOps, SearchHistory, SearchRoot, TypeAssigner, Typer}
1919
import Implicits.ContextualImplicits
@@ -214,7 +214,7 @@ object Contexts {
214214
implicitsCache = {
215215
val implicitRefs: List[ImplicitRef] =
216216
if (isClassDefContext)
217-
try owner.thisType.implicitMembers(DelegateOrGivenOrImplicit)
217+
try owner.thisType.implicitMembers(GivenOrImplicit)
218218
catch {
219219
case ex: CyclicReference => Nil
220220
}

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

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ object Flags {
338338
/** Symbol is a Java default method */
339339
val (_, DefaultMethod @ _, _) = newFlags(38, "<defaultmethod>")
340340

341-
val (Delegate @ _, _, _) = newFlags(39, "delegate")
342-
343341
/** Symbol is an enum class or enum case (if used with case) */
344342
val (Enum @ _, _, _) = newFlags(40, "<enum>")
345343

@@ -421,7 +419,7 @@ object Flags {
421419

422420
/** Flags representing source modifiers */
423421
private val CommonSourceModifierFlags: FlagSet =
424-
commonFlags(Private, Protected, Final, Case, Implicit, Delegate, Given, Override, JavaStatic)
422+
commonFlags(Private, Protected, Final, Case, Implicit, Given, Override, JavaStatic)
425423

426424
val TypeSourceModifierFlags: FlagSet =
427425
CommonSourceModifierFlags.toTypeFlags | Abstract | Sealed | Opaque
@@ -443,7 +441,7 @@ object Flags {
443441
HigherKinded, Param, ParamAccessor,
444442
Scala2ExistentialCommon, Mutable, Opaque, Touched, JavaStatic,
445443
OuterOrCovariant, LabelOrContravariant, CaseAccessor,
446-
Extension, NonMember, Implicit, Given, Delegate, Permanent, Synthetic,
444+
Extension, NonMember, Implicit, Given, Permanent, Synthetic,
447445
SuperAccessorOrScala2x, Inline)
448446

449447
/** Flags that are not (re)set when completing the denotation, or, if symbol is
@@ -502,14 +500,14 @@ object Flags {
502500

503501
/** Flags that can apply to a module val */
504502
val RetainedModuleValFlags: FlagSet = RetainedModuleValAndClassFlags |
505-
Override | Final | Method | Implicit | Delegate | Lazy |
503+
Override | Final | Method | Implicit | Given | Lazy |
506504
Accessor | AbsOverride | StableRealizable | Captured | Synchronized | Erased
507505

508506
/** Flags that can apply to a module class */
509507
val RetainedModuleClassFlags: FlagSet = RetainedModuleValAndClassFlags | Enum
510508

511509
/** Flags retained in export forwarders */
512-
val RetainedExportFlags = Delegate | Given | Implicit | Extension
510+
val RetainedExportFlags = Given | Implicit | Extension
513511

514512
// ------- Other flag sets -------------------------------------
515513

@@ -528,10 +526,6 @@ object Flags {
528526
val DeferredOrLazyOrMethod: FlagSet = Deferred | Lazy | Method
529527
val DeferredOrTermParamOrAccessor: FlagSet = Deferred | ParamAccessor | TermParam // term symbols without right-hand sides
530528
val DeferredOrTypeParam: FlagSet = Deferred | TypeParam // type symbols without right-hand sides
531-
val DelegateOrGiven: FlagSet = Delegate | Given
532-
val DelegateOrGivenOrImplicit: FlagSet = Delegate | Given | Implicit
533-
val DelegateOrGivenOrImplicitVal: FlagSet = DelegateOrGivenOrImplicit.toTermFlags
534-
val DelegateOrImplicit: FlagSet = Delegate | Implicit
535529
val EnumValue: FlagSet = Enum | JavaStatic | StableRealizable // A Scala enum value
536530
val StableOrErased: FlagSet = Erased | StableRealizable // Assumed to be pure
537531
val ExtensionMethod: FlagSet = Extension | Method
@@ -540,6 +534,7 @@ object Flags {
540534
val EffectivelyFinalFlags: FlagSet = Final | Private
541535
val FinalOrSealed: FlagSet = Final | Sealed
542536
val GivenOrImplicit: FlagSet = Given | Implicit
537+
val GivenOrImplicitVal: FlagSet = GivenOrImplicit.toTermFlags
543538
val InlineOrProxy: FlagSet = Inline | InlineProxy // An inline method or inline argument proxy */
544539
val InlineMethod: FlagSet = Inline | Method
545540
val InlineParam: FlagSet = Inline | Param
@@ -570,7 +565,7 @@ object Flags {
570565
val Scala2Trait: FlagSet = Scala2x | Trait
571566
val SyntheticArtifact: FlagSet = Synthetic | Artifact
572567
val SyntheticCase: FlagSet = Synthetic | Case
573-
val SyntheticDelegateMethod: FlagSet = Synthetic | Delegate | Method
568+
val SyntheticGivenMethod: FlagSet = Synthetic | Given | Method
574569
val SyntheticModule: FlagSet = Synthetic | Module
575570
val SyntheticOpaque: FlagSet = Synthetic | Opaque
576571
val SyntheticTermParam: FlagSet = Synthetic | TermParam

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ object Scopes {
409409
var irefs = new mutable.ListBuffer[TermRef]
410410
var e = lastEntry
411411
while (e ne null) {
412-
if (e.sym.isOneOf(DelegateOrGivenOrImplicit)) {
412+
if (e.sym.isOneOf(GivenOrImplicit)) {
413413
val d = e.sym.denot
414414
irefs += TermRef(NoPrefix, d.symbol.asTerm).withDenot(d)
415415
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@ object SymDenotations {
19801980
if (keepOnly eq implicitFilter)
19811981
if (this.is(Package)) Iterator.empty
19821982
// implicits in package objects are added by the overriding `memberNames` in `PackageClassDenotation`
1983-
else info.decls.iterator.filter(_.isOneOf(DelegateOrGivenOrImplicit))
1983+
else info.decls.iterator.filter(_.isOneOf(GivenOrImplicit))
19841984
else info.decls.iterator
19851985
for (sym <- ownSyms) maybeAdd(sym.name)
19861986
names

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class CyclicReference private (val denot: SymDenotation) extends TypeError {
142142
}
143143
}
144144
// Give up and give generic errors.
145-
else if (cycleSym.isOneOf(DelegateOrGivenOrImplicit, butNot = Method) && cycleSym.owner.isTerm)
145+
else if (cycleSym.isOneOf(GivenOrImplicit, butNot = Method) && cycleSym.owner.isTerm)
146146
CyclicReferenceInvolvingImplicit(cycleSym)
147147
else
148148
CyclicReferenceInvolving(denot)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ object Types {
794794
*/
795795
final def implicitMembers(kind: FlagSet)(implicit ctx: Context): List[TermRef] = track("implicitMembers") {
796796
memberDenots(implicitFilter,
797-
(name, buf) => buf ++= member(name).altsWith(_.isOneOf(DelegateOrGivenOrImplicitVal & kind)))
797+
(name, buf) => buf ++= member(name).altsWith(_.isOneOf(GivenOrImplicitVal & kind)))
798798
.toList.map(d => TermRef(this, d.symbol.asTerm))
799799
}
800800

compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Standard-Section: "ASTs" TopLevelStat*
5757
Stat = Term
5858
ValOrDefDef
5959
TYPEDEF Length NameRef (type_Term | Template) Modifier* -- modifiers type name (= type | bounds) | moifiers class name template
60-
IMPORT Length [IMPLIED] qual_Term Selector* -- import implied? qual selectors
60+
IMPORT Length [GIVEN] qual_Term Selector* -- import given? qual selectors
6161
ValOrDefDef = VALDEF Length NameRef type_Term rhs_Term? Modifier* -- modifiers val name : type (= rhs)?
6262
DEFDEF Length NameRef TypeParam* Params* returnType_Term rhs_Term?
6363
Modifier* -- modifiers def name [typeparams] paramss : returnType (= rhs)?
@@ -182,7 +182,7 @@ Standard-Section: "ASTs" TopLevelStat*
182182
SEALED -- sealed
183183
CASE -- case (for classes or objects)
184184
IMPLICIT -- implicit
185-
IMPLIED -- implied
185+
GIVEN -- given
186186
ERASED -- erased
187187
LAZY -- lazy
188188
OVERRIDE -- override
@@ -206,7 +206,6 @@ Standard-Section: "ASTs" TopLevelStat*
206206
DEFAULTparameterized -- Method with default parameters (default arguments are separate methods with DEFAULTGETTER names)
207207
STABLE -- Method that is assumed to be stable, i.e. its applications are legal paths
208208
EXTENSION -- An extension method
209-
GIVEN -- A new style implicit parameter, introduced with `given`
210209
PARAMsetter -- The setter part `x_=` of a var parameter `x` which itself is pickled as a PARAM
211210
EXPORTED -- An export forwarder
212211
Annotation
@@ -249,7 +248,7 @@ Standard Section: "Comments" Comment*
249248
object TastyFormat {
250249

251250
final val header: Array[Int] = Array(0x5C, 0xA1, 0xAB, 0x1F)
252-
val MajorVersion: Int = 15
251+
val MajorVersion: Int = 16
253252
val MinorVersion: Int = 0
254253

255254
/** Tags used to serialize names */
@@ -328,9 +327,8 @@ object TastyFormat {
328327
final val OPAQUE = 35
329328
final val EXTENSION = 36
330329
final val GIVEN = 37
331-
final val IMPLIED = 38
332-
final val PARAMsetter = 39
333-
final val EXPORTED = 40
330+
final val PARAMsetter = 38
331+
final val EXPORTED = 39
334332

335333
// Cat. 2: tag Nat
336334

@@ -477,7 +475,7 @@ object TastyFormat {
477475
| SEALED
478476
| CASE
479477
| IMPLICIT
480-
| IMPLIED
478+
| GIVEN
481479
| ERASED
482480
| LAZY
483481
| OVERRIDE
@@ -538,7 +536,6 @@ object TastyFormat {
538536
case SEALED => "SEALED"
539537
case CASE => "CASE"
540538
case IMPLICIT => "IMPLICIT"
541-
case IMPLIED => "IMPLIED"
542539
case ERASED => "ERASED"
543540
case LAZY => "LAZY"
544541
case OVERRIDE => "OVERRIDE"

0 commit comments

Comments
 (0)