Skip to content

Commit 8ac0c6f

Browse files
committed
Rename SymDenotation.isStable to SymDenotation.isStableMember
This reduces confusion with `Type.isStable`. I'm tempted to call this `isPure`.
1 parent 9db4ab6 commit 8ac0c6f

File tree

9 files changed

+13
-13
lines changed

9 files changed

+13
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
402402
sym.owner.isPrimitiveValueClass || sym.owner == defn.StringClass
403403
if (tree.tpe.isInstanceOf[ConstantType] && isKnownPureOp(tree.symbol)
404404
// A constant expression with pure arguments is pure.
405-
|| fn.symbol.isStable)
405+
|| fn.symbol.isStableMember)
406406
minOf(exprPurity(fn), args.map(exprPurity)) `min` Pure
407407
else
408408
Impure
@@ -438,7 +438,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
438438
val sym = tree.symbol
439439
if (!tree.hasType) Impure
440440
else if (!tree.tpe.widen.isParameterless || sym.is(Erased)) SimplyPure
441-
else if (!sym.isStable) Impure
441+
else if (!sym.isStableMember) Impure
442442
else if (sym.is(Module))
443443
if (sym.moduleClass.isNoInitsClass) Pure else Idempotent
444444
else if (sym.is(Lazy)) Idempotent
@@ -504,7 +504,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
504504
case tpe: PolyType => maybeGetterType(tpe.resultType)
505505
case _ => false
506506
}
507-
sym.owner.isClass && !sym.isStable && maybeGetterType(sym.info)
507+
sym.owner.isClass && !sym.isStableMember && maybeGetterType(sym.info)
508508
}
509509

510510
/** Is tree a reference to a mutable variable, or to a potential getter

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class CheckRealizable(implicit ctx: Context) {
8888
r.mapError(if (tp.info.isStableRealizable) Realizable else _)
8989
val r =
9090
// Reject fields that are mutable, by-name, and similar.
91-
if (!sym.isStable)
91+
if (!sym.isStableMember)
9292
patchRealizability(NotStable)
9393
// 3. If the symbol isn't "lazy" and its prefix is realizable
9494
else if (!isLateInitialized(sym)) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ object SymDenotations {
589589
)
590590

591591
/** Is this a denotation of a stable term (or an arbitrary type)? */
592-
final def isStable(implicit ctx: Context) = {
592+
final def isStableMember(implicit ctx: Context) = {
593593
def isUnstableValue = is(UnstableValue) || info.isInstanceOf[ExprType]
594594
isType || is(StableOrErased) || !isUnstableValue
595595
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ object Types {
151151

152152
/** Does this type denote a stable reference (i.e. singleton type)? */
153153
final def isStable(implicit ctx: Context): Boolean = stripTypeVar match {
154-
case tp: TermRef => tp.termSymbol.isStable && tp.prefix.isStable || tp.info.isStable
154+
case tp: TermRef => tp.termSymbol.isStableMember && tp.prefix.isStable || tp.info.isStable
155155
case _: SingletonType | NoPrefix => true
156156
case tp: RefinedOrRecType => tp.parent.isStable
157157
case tp: ExprType => tp.resultType.isStable
@@ -992,7 +992,7 @@ object Types {
992992
/** Widen type if it is unstable (i.e. an ExprType, or TermRef to unstable symbol */
993993
final def widenIfUnstable(implicit ctx: Context): Type = stripTypeVar match {
994994
case tp: ExprType => tp.resultType.widenIfUnstable
995-
case tp: TermRef if !tp.symbol.isStable => tp.underlying.widenIfUnstable
995+
case tp: TermRef if !tp.symbol.isStableMember => tp.underlying.widenIfUnstable
996996
case _ => this
997997
}
998998

compiler/src/dotty/tools/dotc/sbt/ExtractAPI.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ private class ExtractAPICollector(implicit val ctx: Context) extends ThunkHolder
328328
} else if (sym.is(Mutable, butNot = Accessor)) {
329329
api.Var.of(sym.name.toString, apiAccess(sym), apiModifiers(sym),
330330
apiAnnotations(sym).toArray, apiType(sym.info))
331-
} else if (sym.isStable && !sym.isRealMethod) {
331+
} else if (sym.isStableMember && !sym.isRealMethod) {
332332
api.Val.of(sym.name.toString, apiAccess(sym), apiModifiers(sym),
333333
apiAnnotations(sym).toArray, apiType(sym.info))
334334
} else {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Getters extends MiniPhase with SymTransformer {
6464

6565
var d1 =
6666
if (d.isTerm && (d.is(Lazy) || d.owner.isClass) && d.info.isValueType && !noGetterNeeded) {
67-
val maybeStable = if (d.isStable) Stable else EmptyFlags
67+
val maybeStable = if (d.isStableMember) Stable else EmptyFlags
6868
d.copySymDenotation(
6969
initFlags = d.flags | maybeStable | AccessorCreationFlags,
7070
info = ExprType(d.info))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ class Inliner(call: tpd.Tree, rhsToInline: tpd.Tree)(implicit ctx: Context) {
747747
case tpe: NamedType if tpe.symbol.exists && !tpe.symbol.isAccessibleFrom(tpe.prefix, superAccess) =>
748748
tpe.info match {
749749
case TypeAlias(alias) => return ensureAccessible(alias, superAccess, pos)
750-
case info: ConstantType if tpe.symbol.isStable => return info
750+
case info: ConstantType if tpe.symbol.isStableMember => return info
751751
case _ =>
752752
}
753753
case _ =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ object PrepareTransparent {
8181
sym.isTerm &&
8282
(sym.is(AccessFlags) || sym.privateWithin.exists) &&
8383
!sym.isContainedIn(inlineSym) &&
84-
!(sym.isStable && sym.info.widenTermRefExpr.isInstanceOf[ConstantType])
84+
!(sym.isStableMember && sym.info.widenTermRefExpr.isInstanceOf[ConstantType])
8585

8686
def preTransform(tree: Tree)(implicit ctx: Context): Tree
8787

@@ -438,4 +438,4 @@ object PrepareTransparent {
438438
val untpdSplice = tpd.UntypedSplice(addRefs.transform(original)).withType(typed.tpe)
439439
seq(implicitBindings, untpdSplice)
440440
}
441-
}
441+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ object RefChecks {
367367
intersectionIsEmpty(member.extendedOverriddenSymbols, other.extendedOverriddenSymbols)) {
368368
overrideError("cannot override a concrete member without a third member that's overridden by both " +
369369
"(this rule is designed to prevent ``accidental overrides'')")
370-
} else if (other.isStable && !member.isStable) { // (1.4)
370+
} else if (other.isStableMember && !member.isStableMember) { // (1.4)
371371
overrideError("needs to be a stable, immutable value")
372372
} else if (member.is(ModuleVal) && !other.isRealMethod && !other.is(Deferred | Lazy)) {
373373
overrideError("may not override a concrete non-lazy value")

0 commit comments

Comments
 (0)