Skip to content

Commit 5850775

Browse files
committed
Drop TypeParamAccessor
... and all code related to it.
1 parent c771374 commit 5850775

File tree

11 files changed

+23
-28
lines changed

11 files changed

+23
-28
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ package ast
55
import core._
66
import util.Positions._, Types._, Contexts._, Constants._, Names._, NameOps._, Flags._
77
import SymDenotations._, Symbols._, StdNames._, Annotations._, Trees._
8-
import Decorators._
8+
import Decorators._, transform.SymUtils._
99
import NameKinds.{UniqueName, EvidenceParamName, DefaultGetterName}
1010
import language.higherKinds
1111
import typer.FrontEnd
@@ -70,7 +70,7 @@ object desugar {
7070
def apply(tp: Type) = tp match {
7171
case tp: NamedType if tp.symbol.exists && (tp.symbol.owner eq originalOwner) =>
7272
val defctx = ctx.outersIterator.dropWhile(_.scope eq ctx.scope).next()
73-
var local = defctx.denotNamed(tp.name).suchThat(_ is ParamOrAccessor).symbol
73+
var local = defctx.denotNamed(tp.name).suchThat(_.isParamOrAccessor).symbol
7474
if (local.exists) (defctx.owner.thisType select local).dealias
7575
else {
7676
def msg =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
304304
true
305305
case pre: ThisType =>
306306
pre.cls.isStaticOwner ||
307-
tp.symbol.is(ParamOrAccessor) && !pre.cls.is(Trait) && ctx.owner.enclosingClass == pre.cls
307+
tp.symbol.isParamOrAccessor && !pre.cls.is(Trait) && ctx.owner.enclosingClass == pre.cls
308308
// was ctx.owner.enclosingClass.derivesFrom(pre.cls) which was not tight enough
309309
// and was spuriously triggered in case inner class would inherit from outer one
310310
// eg anonymous TypeMap inside TypeMap.andThen

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

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,7 @@ object Flags {
249249
/** A field generated for a primary constructor parameter (no matter if it's a 'val' or not),
250250
* or an accessor of such a field.
251251
*/
252-
final val ParamAccessor = commonFlag(14, "<paramaccessor>")
253-
final val TermParamAccessor = ParamAccessor.toTermFlags
254-
final val TypeParamAccessor = ParamAccessor.toTypeFlags // @!!!
252+
final val ParamAccessor = termFlag(14, "<paramaccessor>")
255253

256254
/** A value or class implementing a module */
257255
final val Module = commonFlag(15, "module")
@@ -451,7 +449,7 @@ object Flags {
451449

452450
/** Flags guaranteed to be set upon symbol creation */
453451
final val FromStartFlags =
454-
Module | Package | Deferred | MethodOrHKCommon | Param | ParamAccessor |
452+
Module | Package | Deferred | MethodOrHKCommon | Param | ParamAccessor.toCommonFlags |
455453
Scala2ExistentialCommon | Mutable.toCommonFlags | Touched | JavaStatic |
456454
CovariantOrOuter | ContravariantOrLabel | CaseAccessorOrBaseTypeArg |
457455
Fresh | Erroneous | ImplicitCommon | Permanent | Synthetic |
@@ -557,8 +555,8 @@ object Flags {
557555
/** An inline parameter */
558556
final val InlineParam = allOf(Inline, Param)
559557

560-
/** A parameter or parameter accessor */
561-
final val ParamOrAccessor = Param | ParamAccessor
558+
/** A term parameter or parameter accessor */
559+
final val TermParamOrAccessor = Param | ParamAccessor
562560

563561
/** A lazy or deferred value */
564562
final val LazyOrDeferred = Lazy | Deferred
@@ -569,9 +567,6 @@ object Flags {
569567
/** A synthetic or private definition */
570568
final val SyntheticOrPrivate = Synthetic | Private
571569

572-
/** A type parameter or type parameter accessor */
573-
final val TypeParamOrAccessor = TypeParam | TypeParamAccessor
574-
575570
/** A deferred member or a parameter accessor (these don't have right hand sides) */
576571
final val DeferredOrParamAccessor = Deferred | ParamAccessor
577572

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ object Types {
11711171
/** The full parent types, including all type arguments */
11721172
def parents(implicit ctx: Context): List[Type] = this match {
11731173
case tp @ AppliedType(tycon, args) if tycon.typeSymbol.isClass =>
1174-
tycon.parents.map(_.subst(tycon.typeSymbol.typeParams, args)) // !@@@ cache?
1174+
tycon.parents.map(_.subst(tycon.typeSymbol.typeParams, args)) // @!!! cache?
11751175
case tp: TypeRef =>
11761176
if (tp.info.isInstanceOf[TempClassInfo]) {
11771177
tp.reloadDenot()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ class TreeUnpickler(reader: TastyReader, nameAtRef: NameRef => TermName, posUnpi
367367
private def normalizeFlags(tag: Int, givenFlags: FlagSet, name: Name, isAbsType: Boolean, rhsIsEmpty: Boolean)(implicit ctx: Context): FlagSet = {
368368
val lacksDefinition =
369369
rhsIsEmpty &&
370-
name.isTermName && !name.isConstructorName && !givenFlags.is(ParamOrAccessor) ||
370+
name.isTermName && !name.isConstructorName && !givenFlags.is(TermParamOrAccessor) ||
371371
isAbsType
372372
var flags = givenFlags
373373
if (lacksDefinition && tag != PARAM) flags |= Deferred

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class HoistSuperArgs extends MiniPhaseTransform with IdentityDenotTransformer {
6464
val constr = cdef.symbol
6565
lazy val origParams = // The parameters that can be accessed in the supercall
6666
if (constr == cls.primaryConstructor)
67-
cls.info.decls.filter(d => d.is(TypeParam) || d.is(TermParamAccessor))
67+
cls.info.decls.filter(d => d.is(TypeParam) || d.is(ParamAccessor))
6868
else
6969
(cdef.tparams ::: cdef.vparamss.flatten).map(_.symbol)
7070

@@ -127,7 +127,7 @@ class HoistSuperArgs extends MiniPhaseTransform with IdentityDenotTransformer {
127127
def apply(tp: Type) = tp match {
128128
case tp: NamedType
129129
if (tp.symbol.owner == cls || tp.symbol.owner == constr) &&
130-
tp.symbol.is(ParamOrAccessor) =>
130+
tp.symbol.isParamOrAccessor =>
131131
val mappedSym = origToParam(tp.symbol)
132132
if (tp.symbol.isType) mappedSym.typeRef else mappedSym.termRef
133133
case _ =>

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ class SymUtils(val self: Symbol) extends AnyVal {
6060

6161
def isSuperAccessor(implicit ctx: Context) = self.name.is(SuperAccessorName)
6262

63+
/** A type or term parameter or a term parameter accessor */
64+
def isParamOrAccessor(implicit ctx: Context) =
65+
self.is(Param) || self.is(ParamAccessor)
66+
6367
/** If this is a constructor, its owner: otherwise this. */
6468
final def skipConstructor(implicit ctx: Context): Symbol =
6569
if (self.isConstructor) self.owner else self
@@ -87,8 +91,8 @@ class SymUtils(val self: Symbol) extends AnyVal {
8791
def accessorNamed(name: TermName)(implicit ctx: Context): Symbol =
8892
self.owner.info.decl(name).suchThat(_ is Accessor).symbol
8993

90-
def termParamAccessors(implicit ctx: Context): List[Symbol] =
91-
self.info.decls.filter(_ is TermParamAccessor).toList
94+
def paramAccessors(implicit ctx: Context): List[Symbol] =
95+
self.info.decls.filter(_ is ParamAccessor).toList
9296

9397
def caseAccessors(implicit ctx:Context) =
9498
self.info.decls.filter(_ is CaseAccessor).toList

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ class SyntheticMethods(thisTransformer: DenotTransformer) {
5656
def syntheticMethods(clazz: ClassSymbol)(implicit ctx: Context): List[Tree] = {
5757
val clazzType = clazz.appliedRef
5858
lazy val accessors =
59-
if (isDerivedValueClass(clazz))
60-
clazz.termParamAccessors
61-
else
62-
clazz.caseAccessors
59+
if (isDerivedValueClass(clazz)) clazz.paramAccessors
60+
else clazz.caseAccessors
6361

6462
val symbolsToSynthesize: List[Symbol] =
6563
if (clazz.is(Case)) caseSymbols

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ object ValueClasses {
3131
/** The member of a derived value class that unboxes it. */
3232
def valueClassUnbox(d: ClassDenotation)(implicit ctx: Context): Symbol =
3333
// (info.decl(nme.unbox)).orElse(...) uncomment once we accept unbox methods
34-
d.classInfo.decls.find(_.is(TermParamAccessor))
34+
d.classInfo.decls.find(_.is(ParamAccessor))
3535

3636
/** For a value class `d`, this returns the synthetic cast from the underlying type to
3737
* ErasedValueType defined in the companion module. This method is added to the module

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ trait TypeAssigner {
6464

6565
def close(tp: Type) = RecType.closeOver(rt => tp.substThis(cls, rt.recThis))
6666

67-
val refinableDecls = info.decls.filter(
68-
sym => !(sym.is(TypeParamAccessor | Private) || sym.isConstructor))
67+
def isRefinable(sym: Symbol) = !sym.is(Private) && !sym.isConstructor
68+
val refinableDecls = info.decls.filter(isRefinable)
6969
val raw = (parentType /: refinableDecls)(addRefinement)
7070
HKTypeLambda.fromParams(cls.typeParams, raw) match {
7171
case tl: HKTypeLambda => tl.derivedLambdaType(resType = close(tl.resType))
@@ -208,8 +208,6 @@ trait TypeAssigner {
208208
else errorType(ex"$what cannot be accessed as a member of $pre$where.$whyNot", pos)
209209
}
210210
}
211-
else if (d.symbol is TypeParamAccessor)
212-
ensureAccessible(d.info.bounds.hi, superAccess, pos)
213211
else
214212
ctx.makePackageObjPrefixExplicit(tpe withDenot d)
215213
case _ =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
14131413
.withType(dummy.nonMemberTermRef)
14141414
checkVariance(impl1)
14151415
if (!cls.is(AbstractOrTrait) && !ctx.isAfterTyper)
1416-
checkRealizableBounds(cls, cdef.namePos) // !@@@ adapt
1416+
checkRealizableBounds(cls, cdef.namePos)
14171417
val cdef1 = assignType(cpy.TypeDef(cdef)(name, impl1), cls)
14181418
if (ctx.phase.isTyper && cdef1.tpe.derivesFrom(defn.DynamicClass) && !ctx.dynamicsEnabled) {
14191419
val isRequired = parents1.exists(_.tpe.isRef(defn.DynamicClass))

0 commit comments

Comments
 (0)