Skip to content

Commit e68ee42

Browse files
committed
Remove erased keyword from erasedValue
But retain erased semantics
1 parent 27d90e8 commit e68ee42

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,12 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
389389
case Ident(_) =>
390390
refPurity(tree)
391391
case Select(qual, _) =>
392-
if (tree.symbol.is(Erased)) Pure
392+
if (tree.symbol.isErased) Pure
393393
else refPurity(tree) `min` exprPurity(qual)
394394
case New(_) | Closure(_, _, _) =>
395395
Pure
396396
case TypeApply(fn, _) =>
397-
if (fn.symbol.is(Erased) || fn.symbol == defn.InternalQuoted_typeQuote) Pure else exprPurity(fn)
397+
if (fn.symbol.isErased || fn.symbol == defn.InternalQuoted_typeQuote) Pure else exprPurity(fn)
398398
case Apply(fn, args) =>
399399
def isKnownPureOp(sym: Symbol) =
400400
sym.owner.isPrimitiveValueClass
@@ -404,7 +404,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
404404
|| (fn.symbol.isStableMember && !fn.symbol.is(Lazy))
405405
|| fn.symbol.isPrimaryConstructor && fn.symbol.owner.isNoInitsClass) // TODO: include in isStable?
406406
minOf(exprPurity(fn), args.map(exprPurity)) `min` Pure
407-
else if (fn.symbol.is(Erased)) Pure
407+
else if (fn.symbol.isErased) Pure
408408
else if (fn.symbol.isStableMember) /* && fn.symbol.is(Lazy) */
409409
minOf(exprPurity(fn), args.map(exprPurity)) `min` Idempotent
410410
else Impure

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -754,10 +754,10 @@ object SymDenotations {
754754
originalName.isSetterName &&
755755
(!isCompleted || info.firstParamTypes.nonEmpty) // to avoid being fooled by var x_= : Unit = ...
756756

757-
/** is this a symbol representing an import? */
757+
/** Is this a symbol representing an import? */
758758
final def isImport: Boolean = name == nme.IMPORT
759759

760-
/** is this the constructor of a class? */
760+
/** Is this the constructor of a class? */
761761
final def isClassConstructor: Boolean = name == nme.CONSTRUCTOR
762762

763763
/** Is this the constructor of a trait or a class */
@@ -777,6 +777,9 @@ object SymDenotations {
777777
/** Is this a subclass of the given class `base`? */
778778
def isSubClass(base: Symbol)(implicit ctx: Context): Boolean = false
779779

780+
/** Is this a symbol representing an erased term? */
781+
def isErased(given Context): Boolean = is(Erased) || symbol == defn.Compiletime_erasedValue
782+
780783
/** Is this a subclass of `base`,
781784
* and is the denoting symbol also different from `Null` or `Nothing`?
782785
* @note erroneous classes are assumed to derive from all other classes
@@ -940,7 +943,7 @@ object SymDenotations {
940943
/** An erased value or an inline method.
941944
*/
942945
def isEffectivelyErased(implicit ctx: Context): Boolean =
943-
is(Erased) || isInlineMethod
946+
isErased || isInlineMethod
944947

945948
/** ()T and => T types should be treated as equivalent for this symbol.
946949
* Note: For the moment, we treat Scala-2 compiled symbols as loose matching,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ object Checking {
456456
fail(CannotHaveSameNameAs(sym, cls, CannotHaveSameNameAs.CannotBeOverridden))
457457
sym.setFlag(Private) // break the overriding relationship by making sym Private
458458
}
459-
if (sym.is(Erased))
459+
if (sym.isErased)
460460
if ctx.settings.YerasedTerms.value || sym == defn.Compiletime_erasedValue then checkApplicable(Erased, !sym.isOneOf(MutableOrLazy))
461461
else fail("cannot use `erased` without " + ctx.settings.YerasedTerms.name)
462462
}

library/src/scala/compiletime/package.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package scala
22

33
package object compiletime {
44

5-
erased def erasedValue[T]: T = ???
5+
/*erased*/ def erasedValue[T]: T = ???
66

77
/** The error method is used to produce user-defined compile errors during inline expansion.
88
* If an inline expansion results in a call error(msgStr) the compiler produces an error message containing the given msgStr.

0 commit comments

Comments
 (0)