diff --git a/compiler/src/dotty/tools/dotc/Compiler.scala b/compiler/src/dotty/tools/dotc/Compiler.scala index 73fa76f9236d..fe1ce0f02742 100644 --- a/compiler/src/dotty/tools/dotc/Compiler.scala +++ b/compiler/src/dotty/tools/dotc/Compiler.scala @@ -80,7 +80,7 @@ class Compiler { new ShortcutImplicits, // Allow implicit functions without creating closures new CrossCastAnd, // Normalize selections involving intersection types. new Splitter) :: // Expand selections involving union types into conditionals - List(new GhostDecls, // Removes all ghost defs and vals decls (except for parameters) + List(new ErasedDecls, // Removes all erased defs and vals decls (except for parameters) new VCInlineMethods, // Inlines calls to value class methods new SeqLiterals, // Express vararg arguments as arrays new InterceptedMethods, // Special handling of `==`, `|=`, `getClass` methods diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index b14a954876f6..30dad2f44847 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -262,7 +262,7 @@ object desugar { private def toDefParam(tparam: TypeDef): TypeDef = tparam.withMods(tparam.rawMods & EmptyFlags | Param) private def toDefParam(vparam: ValDef): ValDef = - vparam.withMods(vparam.rawMods & (Implicit | Ghost) | Param) + vparam.withMods(vparam.rawMods & (Implicit | Erased) | Param) /** The expansion of a class definition. See inline comments for what is involved */ def classDef(cdef: TypeDef)(implicit ctx: Context): Tree = { diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index a358c433dd4d..89dc8fc4756e 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -396,7 +396,7 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] => * flags set. */ private def refPurity(tree: Tree)(implicit ctx: Context): PurityLevel = - if (!tree.tpe.widen.isParameterless || tree.symbol.is(Ghost)) SimplyPure + if (!tree.tpe.widen.isParameterless || tree.symbol.is(Erased)) SimplyPure else if (!tree.symbol.isStable) Impure else if (tree.symbol.is(Lazy)) Idempotent // TODO add Module flag, sinxce Module vals or not Lazy from the start. else SimplyPure diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 2e1eedb2dd5b..a3be000dbbc2 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -202,8 +202,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { case tp: MethodType => def valueParam(name: TermName, info: Type): TermSymbol = { val maybeImplicit = if (tp.isImplicitMethod) Implicit else EmptyFlags - val maybeGhost = if (tp.isGhostMethod) Ghost else EmptyFlags - ctx.newSymbol(sym, name, TermParam | maybeImplicit | maybeGhost, info, coord = sym.coord) + val maybeErased = if (tp.isErasedMethod) Erased else EmptyFlags + ctx.newSymbol(sym, name, TermParam | maybeImplicit | maybeErased, info, coord = sym.coord) } val params = (tp.paramNames, tp.paramInfos).zipped.map(valueParam) val (paramss, rtp) = valueParamss(tp.instantiate(params map (_.termRef))) diff --git a/compiler/src/dotty/tools/dotc/ast/untpd.scala b/compiler/src/dotty/tools/dotc/ast/untpd.scala index 57075f599de2..252b301c2954 100644 --- a/compiler/src/dotty/tools/dotc/ast/untpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/untpd.scala @@ -118,7 +118,7 @@ object untpd extends Trees.Instance[Untyped] with UntypedTreeInfo { case class Implicit() extends Mod(Flags.ImplicitCommon) - case class Ghost() extends Mod(Flags.Ghost) + case class Erased() extends Mod(Flags.Erased) case class Final() extends Mod(Flags.Final) diff --git a/compiler/src/dotty/tools/dotc/core/Definitions.scala b/compiler/src/dotty/tools/dotc/core/Definitions.scala index 6cbb089401f6..dc9e700cefc4 100644 --- a/compiler/src/dotty/tools/dotc/core/Definitions.scala +++ b/compiler/src/dotty/tools/dotc/core/Definitions.scala @@ -88,7 +88,7 @@ class Definitions { newClassSymbol(ScalaPackageClass, name, EmptyFlags, completer).entered } - /** The trait FunctionN, ImplicitFunctionN, GhostFunctionN or GhostImplicitFunction, for some N + /** The trait FunctionN, ImplicitFunctionN, ErasedFunctionN or ErasedImplicitFunction, for some N * @param name The name of the trait to be created * * FunctionN traits follow this template: @@ -107,19 +107,19 @@ class Definitions { * def apply(implicit $x0: T0, ..., $x{N_1}: T{N-1}): R * } * - * GhostFunctionN traits follow this template: + * ErasedFunctionN traits follow this template: * - * trait GhostFunctionN[T0,...,T{N-1}, R] extends Object { - * def apply(ghost $x0: T0, ..., $x{N_1}: T{N-1}): R + * trait ErasedFunctionN[T0,...,T{N-1}, R] extends Object { + * def apply(erased $x0: T0, ..., $x{N_1}: T{N-1}): R * } * - * GhostImplicitFunctionN traits follow this template: + * ErasedImplicitFunctionN traits follow this template: * - * trait GhostImplicitFunctionN[T0,...,T{N-1}, R] extends Object with GhostFunctionN[T0,...,T{N-1}, R] { - * def apply(ghost implicit $x0: T0, ..., $x{N_1}: T{N-1}): R + * trait ErasedImplicitFunctionN[T0,...,T{N-1}, R] extends Object with ErasedFunctionN[T0,...,T{N-1}, R] { + * def apply(erased implicit $x0: T0, ..., $x{N_1}: T{N-1}): R * } * - * GhostFunctionN and GhostImplicitFunctionN erase to Function0. + * ErasedFunctionN and ErasedImplicitFunctionN erase to Function0. */ def newFunctionNTrait(name: TypeName): ClassSymbol = { val completer = new LazyType { @@ -132,10 +132,10 @@ class Definitions { enterTypeParam(cls, paramNamePrefix ++ "T" ++ (i + 1).toString, Contravariant, decls).typeRef } val resParamRef = enterTypeParam(cls, paramNamePrefix ++ "R", Covariant, decls).typeRef - val methodType = MethodType.maker(isJava = false, name.isImplicitFunction, name.isGhostFunction) + val methodType = MethodType.maker(isJava = false, name.isImplicitFunction, name.isErasedFunction) val parentTraits = if (!name.isImplicitFunction) Nil - else FunctionType(arity, isGhost = name.isGhostFunction).appliedTo(argParamRefs ::: resParamRef :: Nil) :: Nil + else FunctionType(arity, isErased = name.isErasedFunction).appliedTo(argParamRefs ::: resParamRef :: Nil) :: Nil decls.enter(newMethod(cls, nme.apply, methodType(argParamRefs, resParamRef), Deferred)) denot.info = ClassInfo(ScalaPackageClass.thisType, cls, ObjectType :: parentTraits, decls) @@ -756,14 +756,14 @@ class Definitions { sym.owner.linkedClass.typeRef object FunctionOf { - def apply(args: List[Type], resultType: Type, isImplicit: Boolean = false, isGhost: Boolean = false)(implicit ctx: Context) = - FunctionType(args.length, isImplicit, isGhost).appliedTo(args ::: resultType :: Nil) + def apply(args: List[Type], resultType: Type, isImplicit: Boolean = false, isErased: Boolean = false)(implicit ctx: Context) = + FunctionType(args.length, isImplicit, isErased).appliedTo(args ::: resultType :: Nil) def unapply(ft: Type)(implicit ctx: Context) = { val tsym = ft.typeSymbol if (isFunctionClass(tsym)) { val targs = ft.dealias.argInfos if (targs.isEmpty) None - else Some(targs.init, targs.last, tsym.name.isImplicitFunction, tsym.name.isGhostFunction) + else Some(targs.init, targs.last, tsym.name.isImplicitFunction, tsym.name.isErasedFunction) } else None } @@ -827,18 +827,18 @@ class Definitions { lazy val TupleType = mkArityArray("scala.Tuple", MaxTupleArity, 2) - def FunctionClass(n: Int, isImplicit: Boolean = false, isGhost: Boolean = false)(implicit ctx: Context) = { - if (isImplicit && isGhost) { + def FunctionClass(n: Int, isImplicit: Boolean = false, isErased: Boolean = false)(implicit ctx: Context) = { + if (isImplicit && isErased) { require(n > 0) - ctx.requiredClass("scala.GhostImplicitFunction" + n.toString) + ctx.requiredClass("scala.ErasedImplicitFunction" + n.toString) } else if (isImplicit) { require(n > 0) ctx.requiredClass("scala.ImplicitFunction" + n.toString) } - else if (isGhost) { + else if (isErased) { require(n > 0) - ctx.requiredClass("scala.GhostFunction" + n.toString) + ctx.requiredClass("scala.ErasedFunction" + n.toString) } else if (n <= MaxImplementedFunctionArity) FunctionClassPerRun()(ctx)(n) else ctx.requiredClass("scala.Function" + n.toString) @@ -847,9 +847,9 @@ class Definitions { lazy val Function0_applyR = ImplementedFunctionType(0).symbol.requiredMethodRef(nme.apply) def Function0_apply(implicit ctx: Context) = Function0_applyR.symbol - def FunctionType(n: Int, isImplicit: Boolean = false, isGhost: Boolean = false)(implicit ctx: Context): TypeRef = - if (n <= MaxImplementedFunctionArity && (!isImplicit || ctx.erasedTypes) && !isGhost) ImplementedFunctionType(n) - else FunctionClass(n, isImplicit, isGhost).typeRef + def FunctionType(n: Int, isImplicit: Boolean = false, isErased: Boolean = false)(implicit ctx: Context): TypeRef = + if (n <= MaxImplementedFunctionArity && (!isImplicit || ctx.erasedTypes) && !isErased) ImplementedFunctionType(n) + else FunctionClass(n, isImplicit, isErased).typeRef private lazy val TupleTypes: Set[TypeRef] = TupleType.toSet @@ -874,22 +874,22 @@ class Definitions { /** Is a function class. * - FunctionN for N >= 0 * - ImplicitFunctionN for N > 0 - * - GhostFunctionN for N > 0 - * - GhostImplicitFunctionN for N > 0 + * - ErasedFunctionN for N > 0 + * - ErasedImplicitFunctionN for N > 0 */ def isFunctionClass(cls: Symbol) = scalaClassName(cls).isFunction /** Is an implicit function class. * - ImplicitFunctionN for N > 0 - * - GhostImplicitFunctionN for N > 0 + * - ErasedImplicitFunctionN for N > 0 */ def isImplicitFunctionClass(cls: Symbol) = scalaClassName(cls).isImplicitFunction - /** Is an ghost function class. - * - GhostFunctionN for N > 0 - * - GhostImplicitFunctionN for N > 0 + /** Is an erased function class. + * - ErasedFunctionN for N > 0 + * - ErasedImplicitFunctionN for N > 0 */ - def isGhostFunctionClass(cls: Symbol) = scalaClassName(cls).isGhostFunction + def isErasedFunctionClass(cls: Symbol) = scalaClassName(cls).isErasedFunction /** Is a class that will be erased to FunctionXXL * - FunctionN for N >= 22 @@ -915,13 +915,13 @@ class Definitions { * - FunctionN for 22 > N >= 0 remains as FunctionN * - ImplicitFunctionN for N > 22 becomes FunctionXXL * - ImplicitFunctionN for 22 > N >= 0 becomes FunctionN - * - GhostFunctionN becomes Function0 - * - ImplicitGhostFunctionN becomes Function0 + * - ErasedFunctionN becomes Function0 + * - ImplicitErasedFunctionN becomes Function0 * - anything else becomes a NoSymbol */ def erasedFunctionClass(cls: Symbol): Symbol = { val arity = scalaClassName(cls).functionArity - if (cls.name.isGhostFunction) FunctionClass(0) + if (cls.name.isErasedFunction) FunctionClass(0) else if (arity > 22) FunctionXXLClass else if (arity >= 0) FunctionClass(arity) else NoSymbol @@ -932,13 +932,13 @@ class Definitions { * - FunctionN for 22 > N >= 0 remains as FunctionN * - ImplicitFunctionN for N > 22 becomes FunctionXXL * - ImplicitFunctionN for 22 > N >= 0 becomes FunctionN - * - GhostFunctionN becomes Function0 - * - ImplicitGhostFunctionN becomes Function0 + * - ErasedFunctionN becomes Function0 + * - ImplicitErasedFunctionN becomes Function0 * - anything else becomes a NoType */ def erasedFunctionType(cls: Symbol): Type = { val arity = scalaClassName(cls).functionArity - if (cls.name.isGhostFunction) FunctionType(0) + if (cls.name.isErasedFunction) FunctionType(0) else if (arity > 22) FunctionXXLType else if (arity >= 0) FunctionType(arity) else NoType @@ -1008,7 +1008,7 @@ class Definitions { def isNonDepFunctionType(tp: Type)(implicit ctx: Context) = { val arity = functionArity(tp) val sym = tp.dealias.typeSymbol - arity >= 0 && isFunctionClass(sym) && tp.isRef(FunctionType(arity, sym.name.isImplicitFunction, sym.name.isGhostFunction).typeSymbol) + arity >= 0 && isFunctionClass(sym) && tp.isRef(FunctionType(arity, sym.name.isImplicitFunction, sym.name.isErasedFunction).typeSymbol) } /** Is `tp` a representation of a (possibly depenent) function type or an alias of such? */ @@ -1074,8 +1074,8 @@ class Definitions { def isImplicitFunctionType(tp: Type)(implicit ctx: Context): Boolean = asImplicitFunctionType(tp).exists - def isGhostFunctionType(tp: Type)(implicit ctx: Context) = - isFunctionType(tp) && tp.dealias.typeSymbol.name.isGhostFunction + def isErasedFunctionType(tp: Type)(implicit ctx: Context) = + isFunctionType(tp) && tp.dealias.typeSymbol.name.isErasedFunction // ----- primitive value class machinery ------------------------------------------ diff --git a/compiler/src/dotty/tools/dotc/core/Flags.scala b/compiler/src/dotty/tools/dotc/core/Flags.scala index 9a7fa0b5541c..9f88fdbc0cf3 100644 --- a/compiler/src/dotty/tools/dotc/core/Flags.scala +++ b/compiler/src/dotty/tools/dotc/core/Flags.scala @@ -367,8 +367,8 @@ object Flags { /** Symbol is a Java enum */ final val Enum = commonFlag(40, "") - /** Labeled with `ghost` modifier (ghost value) */ - final val Ghost = termFlag(42, "ghost") + /** Labeled with `erased` modifier (erased value) */ + final val Erased = termFlag(42, "erased") // Flags following this one are not pickled @@ -441,7 +441,7 @@ object Flags { /** Flags representing source modifiers */ final val SourceModifierFlags = commonFlags(Private, Protected, Abstract, Final, Inline, - Sealed, Case, Implicit, Override, AbsOverride, Lazy, JavaStatic, Ghost) + Sealed, Case, Implicit, Override, AbsOverride, Lazy, JavaStatic, Erased) /** Flags representing modifiers that can appear in trees */ final val ModifierFlags = @@ -515,7 +515,7 @@ object Flags { /** Flags that can apply to a module val */ final val RetainedModuleValFlags: FlagSet = RetainedModuleValAndClassFlags | Override | Final | Method | Implicit | Lazy | - Accessor | AbsOverride | Stable | Captured | Synchronized | Inline | Ghost + Accessor | AbsOverride | Stable | Captured | Synchronized | Inline | Erased /** Flags that can apply to a module class */ final val RetainedModuleClassFlags: FlagSet = RetainedModuleValAndClassFlags | ImplClass | Enum diff --git a/compiler/src/dotty/tools/dotc/core/NameOps.scala b/compiler/src/dotty/tools/dotc/core/NameOps.scala index df2f2a0c43e8..584139248959 100644 --- a/compiler/src/dotty/tools/dotc/core/NameOps.scala +++ b/compiler/src/dotty/tools/dotc/core/NameOps.scala @@ -176,51 +176,51 @@ object NameOps { functionArityFor(str.Function) max { val n = functionArityFor(str.ImplicitFunction) max - functionArityFor(str.GhostFunction) max - functionArityFor(str.GhostImplicitFunction) + functionArityFor(str.ErasedFunction) max + functionArityFor(str.ErasedImplicitFunction) if (n == 0) -1 else n } /** Is a function name * - FunctionN for N >= 0 * - ImplicitFunctionN for N >= 1 - * - GhostFunctionN for N >= 1 - * - GhostImplicitFunctionN for N >= 1 + * - ErasedFunctionN for N >= 1 + * - ErasedImplicitFunctionN for N >= 1 * - false otherwise */ def isFunction: Boolean = functionArity >= 0 /** Is a implicit function name * - ImplicitFunctionN for N >= 1 - * - GhostImplicitFunctionN for N >= 1 + * - ErasedImplicitFunctionN for N >= 1 * - false otherwise */ def isImplicitFunction: Boolean = { functionArityFor(str.ImplicitFunction) >= 1 || - functionArityFor(str.GhostImplicitFunction) >= 1 + functionArityFor(str.ErasedImplicitFunction) >= 1 } /** Is a implicit function name - * - GhostFunctionN for N >= 1 - * - GhostImplicitFunctionN for N >= 1 + * - ErasedFunctionN for N >= 1 + * - ErasedImplicitFunctionN for N >= 1 * - false otherwise */ - def isGhostFunction: Boolean = { - functionArityFor(str.GhostFunction) >= 1 || - functionArityFor(str.GhostImplicitFunction) >= 1 + def isErasedFunction: Boolean = { + functionArityFor(str.ErasedFunction) >= 1 || + functionArityFor(str.ErasedImplicitFunction) >= 1 } /** Is a synthetic function name * - FunctionN for N > 22 * - ImplicitFunctionN for N >= 1 - * - GhostFunctionN for N >= 1 - * - GhostImplicitFunctionN for N >= 1 + * - ErasedFunctionN for N >= 1 + * - ErasedImplicitFunctionN for N >= 1 * - false otherwise */ def isSyntheticFunction: Boolean = { functionArityFor(str.Function) > MaxImplementedFunctionArity || functionArityFor(str.ImplicitFunction) >= 1 || - isGhostFunction + isErasedFunction } /** Parsed function arity for function with some specific prefix */ diff --git a/compiler/src/dotty/tools/dotc/core/StdNames.scala b/compiler/src/dotty/tools/dotc/core/StdNames.scala index 6a4f5d22a15e..1e64ff94d872 100644 --- a/compiler/src/dotty/tools/dotc/core/StdNames.scala +++ b/compiler/src/dotty/tools/dotc/core/StdNames.scala @@ -36,9 +36,9 @@ object StdNames { final val MODULE_INSTANCE_FIELD = "MODULE$" final val Function = "Function" - final val GhostFunction = "GhostFunction" + final val ErasedFunction = "ErasedFunction" final val ImplicitFunction = "ImplicitFunction" - final val GhostImplicitFunction = "GhostImplicitFunction" + final val ErasedImplicitFunction = "ErasedImplicitFunction" final val AbstractFunction = "AbstractFunction" final val Tuple = "Tuple" final val Product = "Product" diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 4090adf032b4..989a6ae7e60c 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -1400,13 +1400,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { * * In these cases, a MergeError is thrown. */ - final def andType(tp1: Type, tp2: Type, erased: Boolean = ctx.erasedTypes) = trace(s"glb(${tp1.show}, ${tp2.show})", subtyping, show = true) { + final def andType(tp1: Type, tp2: Type, isErased: Boolean = ctx.erasedTypes) = trace(s"glb(${tp1.show}, ${tp2.show})", subtyping, show = true) { val t1 = distributeAnd(tp1, tp2) if (t1.exists) t1 else { val t2 = distributeAnd(tp2, tp1) if (t2.exists) t2 - else if (erased) erasedGlb(tp1, tp2, isJava = false) + else if (isErased) erasedGlb(tp1, tp2, isJava = false) else liftIfHK(tp1, tp2, AndType(_, _), _ & _) } } @@ -1421,16 +1421,16 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling { * the types are in conflict of each other. (@see `andType` for an enumeration * of these cases). In cases of conflict a `MergeError` is raised. * - * @param erased Apply erasure semantics. If erased is true, instead of creating + * @param isErased Apply erasure semantics. If erased is true, instead of creating * an OrType, the lub will be computed using TypeCreator#erasedLub. */ - final def orType(tp1: Type, tp2: Type, erased: Boolean = ctx.erasedTypes) = { + final def orType(tp1: Type, tp2: Type, isErased: Boolean = ctx.erasedTypes) = { val t1 = distributeOr(tp1, tp2) if (t1.exists) t1 else { val t2 = distributeOr(tp2, tp1) if (t2.exists) t2 - else if (erased) erasedLub(tp1, tp2) + else if (isErased) erasedLub(tp1, tp2) else liftIfHK(tp1, tp2, OrType(_, _), _ | _) } } diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index 2aaf33fd063e..74d965ef48ac 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -406,11 +406,11 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean case AndType(tp1, tp2) => erasedGlb(this(tp1), this(tp2), isJava) case OrType(tp1, tp2) => - ctx.typeComparer.orType(this(tp1), this(tp2), erased = true) + ctx.typeComparer.orType(this(tp1), this(tp2), isErased = true) case tp: MethodType => def paramErasure(tpToErase: Type) = erasureFn(tp.isJavaMethod, semiEraseVCs, isConstructor, wildcardOK)(tpToErase) - val (names, formals0) = if (tp.isGhostMethod) (Nil, Nil) else (tp.paramNames, tp.paramInfos) + val (names, formals0) = if (tp.isErasedMethod) (Nil, Nil) else (tp.paramNames, tp.paramInfos) val formals = formals0.mapConserve(paramErasure) eraseResult(tp.resultType) match { case rt: MethodType => @@ -558,9 +558,9 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean case tp: WildcardType => sigName(tp.optBounds) case _ => - val erased = this(tp) - assert(erased ne tp, tp) - sigName(erased) + val erasedTp = this(tp) + assert(erasedTp ne tp, tp) + sigName(erasedTp) } } catch { case ex: AssertionError => diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 43e5b1a74401..3675d6e8033c 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -267,7 +267,7 @@ object Types { def isImplicitMethod: Boolean = false /** Is this a MethodType for which the parameters will not be used */ - def isGhostMethod: Boolean = false + def isErasedMethod: Boolean = false // ----- Higher-order combinators ----------------------------------- @@ -1317,10 +1317,10 @@ object Types { case mt: MethodType if !mt.isParamDependent => val formals1 = if (dropLast == 0) mt.paramInfos else mt.paramInfos dropRight dropLast val isImplicit = mt.isImplicitMethod && !ctx.erasedTypes - val isGhost = mt.isGhostMethod && !ctx.erasedTypes + val isErased = mt.isErasedMethod && !ctx.erasedTypes val funType = defn.FunctionOf( formals1 mapConserve (_.underlyingIfRepeated(mt.isJavaMethod)), - mt.nonDependentResultApprox, isImplicit, isGhost) + mt.nonDependentResultApprox, isImplicit, isErased) if (mt.isResultDependent) RefinedType(funType, nme.apply, mt) else funType } @@ -2833,15 +2833,15 @@ object Types { def companion: MethodTypeCompanion final override def isJavaMethod: Boolean = companion eq JavaMethodType - final override def isImplicitMethod: Boolean = companion.eq(ImplicitMethodType) || companion.eq(GhostImplicitMethodType) - final override def isGhostMethod: Boolean = companion.eq(GhostMethodType) || companion.eq(GhostImplicitMethodType) + final override def isImplicitMethod: Boolean = companion.eq(ImplicitMethodType) || companion.eq(ErasedImplicitMethodType) + final override def isErasedMethod: Boolean = companion.eq(ErasedMethodType) || companion.eq(ErasedImplicitMethodType) val paramInfos = paramInfosExp(this) val resType = resultTypeExp(this) assert(resType.exists) def computeSignature(implicit ctx: Context): Signature = { - val params = if (isGhostMethod) Nil else paramInfos + val params = if (isErasedMethod) Nil else paramInfos resultSignature.prepend(params, isJavaMethod) } @@ -2931,22 +2931,22 @@ object Types { } object MethodType extends MethodTypeCompanion { - def maker(isJava: Boolean = false, isImplicit: Boolean = false, isGhost: Boolean = false): MethodTypeCompanion = { + def maker(isJava: Boolean = false, isImplicit: Boolean = false, isErased: Boolean = false): MethodTypeCompanion = { if (isJava) { assert(!isImplicit) - assert(!isGhost) + assert(!isErased) JavaMethodType } - else if (isImplicit && isGhost) GhostImplicitMethodType + else if (isImplicit && isErased) ErasedImplicitMethodType else if (isImplicit) ImplicitMethodType - else if (isGhost) GhostMethodType + else if (isErased) ErasedMethodType else MethodType } } object JavaMethodType extends MethodTypeCompanion object ImplicitMethodType extends MethodTypeCompanion - object GhostMethodType extends MethodTypeCompanion - object GhostImplicitMethodType extends MethodTypeCompanion + object ErasedMethodType extends MethodTypeCompanion + object ErasedImplicitMethodType extends MethodTypeCompanion /** A ternary extractor for MethodType */ object MethodTpe { diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index cfad7550297b..7e4d94dc1f93 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -732,7 +732,7 @@ object Parsers { def functionRest(params: List[Tree]): Tree = atPos(start, accept(ARROW)) { val t = typ() - if (imods.is(Implicit) || imods.is(Ghost)) new NonEmptyFunction(params, t, imods) + if (imods.is(Implicit) || imods.is(Erased)) new NonEmptyFunction(params, t, imods) else Function(params, t) } def funArgTypesRest(first: Tree, following: () => Tree) = { @@ -1068,7 +1068,7 @@ object Parsers { def expr(location: Location.Value): Tree = { val start = in.offset - if (in.token == IMPLICIT || in.token == GHOST) { + if (in.token == IMPLICIT || in.token == ERASED) { val imods = modifiers(funArgMods) implicitClosure(start, location, imods) } else { @@ -1642,7 +1642,7 @@ object Parsers { case ABSTRACT => Mod.Abstract() case FINAL => Mod.Final() case IMPLICIT => Mod.Implicit() - case GHOST => Mod.Ghost() + case ERASED => Mod.Erased() case INLINE => Mod.Inline() case LAZY => Mod.Lazy() case OVERRIDE => Mod.Override() @@ -1731,9 +1731,9 @@ object Parsers { normalize(loop(start)) } - /** FunArgMods ::= { `implicit` | `ghost` } + /** FunArgMods ::= { `implicit` | `erased` } */ - def funArgMods = BitSet(IMPLICIT, GHOST) + def funArgMods = BitSet(IMPLICIT, ERASED) /** Wrap annotation or constructor in New(...). */ def wrapNew(tpt: Tree) = Select(New(tpt), nme.CONSTRUCTOR) @@ -1822,11 +1822,11 @@ object Parsers { if (in.token == LBRACKET) typeParamClause(ownerKind) else Nil /** ClsParamClauses ::= {ClsParamClause} [[nl] `(' [FunArgMods] ClsParams `)'] - * ClsParamClause ::= [nl] `(' [`ghost'] [ClsParams] ')' + * ClsParamClause ::= [nl] `(' [`erased'] [ClsParams] ')' * ClsParams ::= ClsParam {`' ClsParam} * ClsParam ::= {Annotation} [{Modifier} (`val' | `var') | `inline'] Param * DefParamClauses ::= {DefParamClause} [[nl] `(' [FunArgMods] DefParams `)'] - * DefParamClause ::= [nl] `(' [`ghost'] [DefParams] ')' + * DefParamClause ::= [nl] `(' [`erased'] [DefParams] ')' * DefParams ::= DefParam {`,' DefParam} * DefParam ::= {Annotation} [`inline'] Param * Param ::= id `:' ParamType [`=' Expr] @@ -1884,8 +1884,8 @@ object Parsers { implicitOffset = in.offset imods = addMod(imods, atPos(accept(IMPLICIT)) { Mod.Implicit() }) funArgMods() - } else if (in.token == GHOST) { - imods = addMod(imods, atPos(accept(GHOST)) { Mod.Ghost() }) + } else if (in.token == ERASED) { + imods = addMod(imods, atPos(accept(ERASED)) { Mod.Erased() }) funArgMods() } } @@ -2466,7 +2466,7 @@ object Parsers { else if (isExprIntro) stats += expr(Location.InBlock) else if (isDefIntro(localModifierTokens)) - if (in.token == IMPLICIT || in.token == GHOST) { + if (in.token == IMPLICIT || in.token == ERASED) { val start = in.offset var imods = modifiers(funArgMods) if (isBindingIntro) stats += implicitClosure(start, Location.InBlock, imods) diff --git a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala index ac8733151c13..0cc0cc16fcea 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Tokens.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Tokens.scala @@ -177,7 +177,7 @@ object Tokens extends TokensCommon { final val FORSOME = 61; enter(FORSOME, "forSome") // TODO: deprecate final val INLINE = 62; enter(INLINE, "inline") final val ENUM = 63; enter(ENUM, "enum") - final val GHOST = 64; enter(GHOST, "ghost") + final val ERASED = 64; enter(ERASED, "erased") /** special symbols */ final val NEWLINE = 78; enter(NEWLINE, "end of statement", "new line") @@ -198,7 +198,7 @@ object Tokens extends TokensCommon { /** XML mode */ final val XMLSTART = 96; enter(XMLSTART, "$XMLSTART$<") // TODO: deprecate - final val alphaKeywords = tokenRange(IF, GHOST) + final val alphaKeywords = tokenRange(IF, ERASED) final val symbolicKeywords = tokenRange(USCORE, VIEWBOUND) final val symbolicTokens = tokenRange(COMMA, VIEWBOUND) final val keywords = alphaKeywords | symbolicKeywords @@ -226,7 +226,7 @@ object Tokens extends TokensCommon { final val defIntroTokens = templateIntroTokens | dclIntroTokens final val localModifierTokens = BitSet( - ABSTRACT, FINAL, SEALED, IMPLICIT, INLINE, LAZY, GHOST) + ABSTRACT, FINAL, SEALED, IMPLICIT, INLINE, LAZY, ERASED) final val accessModifierTokens = BitSet( PRIVATE, PROTECTED) diff --git a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala index 96f5b446a90e..719b9498671f 100644 --- a/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -132,14 +132,14 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { def toTextTuple(args: List[Type]): Text = "(" ~ Text(args.map(argText), ", ") ~ ")" - def toTextFunction(args: List[Type], isImplicit: Boolean, isGhost: Boolean): Text = + def toTextFunction(args: List[Type], isImplicit: Boolean, isErased: Boolean): Text = changePrec(GlobalPrec) { val argStr: Text = if (args.length == 2 && !defn.isTupleType(args.head)) atPrec(InfixPrec) { argText(args.head) } else toTextTuple(args.init) - (keywordText("ghost ") provided isGhost) ~ (keywordText("implicit ") provided isImplicit) ~ argStr ~ " => " ~ argText(args.last) + (keywordText("erased ") provided isErased) ~ (keywordText("implicit ") provided isImplicit) ~ argStr ~ " => " ~ argText(args.last) } def toTextDependentFunction(appType: MethodType): Text = { @@ -174,7 +174,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { case AppliedType(tycon, args) => val cls = tycon.typeSymbol if (tycon.isRepeatedParam) return toTextLocal(args.head) ~ "*" - if (defn.isFunctionClass(cls)) return toTextFunction(args, cls.name.isImplicitFunction, cls.name.isGhostFunction) + if (defn.isFunctionClass(cls)) return toTextFunction(args, cls.name.isImplicitFunction, cls.name.isErasedFunction) if (defn.isTupleClass(cls)) return toTextTuple(args) if (isInfixType(tp)) return toTextInfixType(tycon, args) case EtaExpansion(tycon) => @@ -745,7 +745,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { else if (sym.isClass && flags.is(Case)) "case class" else if (flags is Module) "object" else if (sym.isTerm && !flags.is(Param) && flags.is(Implicit)) "implicit val" - else if (sym.isTerm && !flags.is(Param) && flags.is(Ghost)) "ghost val" + else if (sym.isTerm && !flags.is(Param) && flags.is(Erased)) "erased val" else super.keyString(sym) } diff --git a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 00f5f76874d3..c98e219a027a 100644 --- a/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -1713,10 +1713,10 @@ object messages { } } - case class FunctionTypeNeedsNonEmptyParameterList(isImplicit: Boolean = true, isGhost: Boolean = true)(implicit ctx: Context) + case class FunctionTypeNeedsNonEmptyParameterList(isImplicit: Boolean = true, isErased: Boolean = true)(implicit ctx: Context) extends Message(FunctionTypeNeedsNonEmptyParameterListID) { val kind = "Syntax" - val mods = ((isImplicit, "implicit") :: (isGhost, "ghost") :: Nil).filter(_._1).mkString(" ") + val mods = ((isImplicit, "implicit") :: (isErased, "erased") :: Nil).filter(_._1).mkString(" ") val msg = mods + " function type needs non-empty parameter list" val explanation = { val code1 = s"type Transactional[T] = $mods Transaction => T" diff --git a/compiler/src/dotty/tools/dotc/transform/Erasure.scala b/compiler/src/dotty/tools/dotc/transform/Erasure.scala index bd6d0c389585..76e5dc4a3fc5 100644 --- a/compiler/src/dotty/tools/dotc/transform/Erasure.scala +++ b/compiler/src/dotty/tools/dotc/transform/Erasure.scala @@ -322,9 +322,9 @@ object Erasure { override def promote(tree: untpd.Tree)(implicit ctx: Context): tree.ThisTree[Type] = { assert(tree.hasType) - val erased = erasedType(tree) - ctx.log(s"promoting ${tree.show}: ${erased.showWithUnderlying()}") - tree.withType(erased) + val erasedTp = erasedType(tree) + ctx.log(s"promoting ${tree.show}: ${erasedTp.showWithUnderlying()}") + tree.withType(erasedTp) } /** When erasing most TypeTrees we should not semi-erase value types. @@ -452,7 +452,7 @@ object Erasure { } private def protoArgs(pt: Type, methTp: Type): List[untpd.Tree] = (pt, methTp) match { - case (pt: FunProto, methTp: MethodType) if methTp.isGhostMethod => + case (pt: FunProto, methTp: MethodType) if methTp.isErasedMethod => protoArgs(pt.resType, methTp.resType) case (pt: FunProto, methTp: MethodType) => pt.args ++ protoArgs(pt.resType, methTp.resType) @@ -489,7 +489,7 @@ object Erasure { fun1.tpe.widen match { case mt: MethodType => val outers = outer.args(fun.asInstanceOf[tpd.Tree]) // can't use fun1 here because its type is already erased - val ownArgs = if (mt.paramNames.nonEmpty && !mt.isGhostMethod) args else Nil + val ownArgs = if (mt.paramNames.nonEmpty && !mt.isErasedMethod) args else Nil var args0 = outers ::: ownArgs ::: protoArgs(pt, tree.typeOpt) if (args0.length > MaxImplementedFunctionArity && mt.paramInfos.length == 1) { @@ -559,7 +559,7 @@ object Erasure { vparamss1 = (tpd.ValDef(bunchedParam) :: Nil) :: Nil rhs1 = untpd.Block(paramDefs, rhs1) } - vparamss1 = vparamss1.mapConserve(_.filterConserve(!_.symbol.is(Flags.Ghost))) + vparamss1 = vparamss1.mapConserve(_.filterConserve(!_.symbol.is(Flags.Erased))) val ddef1 = untpd.cpy.DefDef(ddef)( tparams = Nil, vparamss = vparamss1, diff --git a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala index 0e76cf7ab8fd..de558d2494b3 100644 --- a/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala +++ b/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala @@ -237,9 +237,9 @@ object GenericSignatures { methodResultSig(restpe) case mtpe: MethodType => - // ghost method parameters do not make it to the bytecode. + // erased method parameters do not make it to the bytecode. def effectiveParamInfoss(t: Type)(implicit ctx: Context): List[List[Type]] = t match { - case t: MethodType if t.isGhostMethod => effectiveParamInfoss(t.resType) + case t: MethodType if t.isErasedMethod => effectiveParamInfoss(t.resType) case t: MethodType => t.paramInfos :: effectiveParamInfoss(t.resType) case _ => Nil } diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index 6ea39a10a9d9..2371bd3e4c70 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -178,14 +178,14 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase override def transform(tree: Tree)(implicit ctx: Context): Tree = try tree match { case tree: Ident if !tree.isType => - checkNotGhost(tree) + checkNotErased(tree) handleMeta(tree.symbol) tree.tpe match { case tpe: ThisType => This(tpe.cls).withPos(tree.pos) case _ => tree } case tree @ Select(qual, name) => - checkNotGhost(tree) + checkNotErased(tree) handleMeta(tree.symbol) if (name.isTypeName) { Checking.checkRealizable(qual.tpe, qual.pos.focus) @@ -311,11 +311,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase throw ex } - private def checkNotGhost(tree: RefTree)(implicit ctx: Context): Unit = { - if (tree.symbol.is(Ghost) && !ctx.mode.is(Mode.Type)) { + private def checkNotErased(tree: RefTree)(implicit ctx: Context): Unit = { + if (tree.symbol.is(Erased) && !ctx.mode.is(Mode.Type)) { val msg = - if (tree.symbol.is(CaseAccessor)) "First parameter list of case class may not contain `ghost` parameters" - else i"${tree.symbol} is declared as ghost, but is in fact used" + if (tree.symbol.is(CaseAccessor)) "First parameter list of case class may not contain `erased` parameters" + else i"${tree.symbol} is declared as erased, but is in fact used" ctx.error(msg, tree.pos) } } diff --git a/compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala b/compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala index ce03bb51b1bb..a5cf2447418c 100644 --- a/compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala +++ b/compiler/src/dotty/tools/dotc/transform/SyntheticMethods.scala @@ -59,7 +59,7 @@ class SyntheticMethods(thisPhase: DenotTransformer) { def syntheticMethods(clazz: ClassSymbol)(implicit ctx: Context): List[Tree] = { val clazzType = clazz.appliedRef lazy val accessors = - if (isDerivedValueClass(clazz)) clazz.paramAccessors.take(1) // Tail parameters can only be `ghost` + if (isDerivedValueClass(clazz)) clazz.paramAccessors.take(1) // Tail parameters can only be `erased` else clazz.caseAccessors val symbolsToSynthesize: List[Symbol] = diff --git a/compiler/src/dotty/tools/dotc/transform/UnusedDecls.scala b/compiler/src/dotty/tools/dotc/transform/UnusedDecls.scala index 06e84f0c6dd3..0cc5060e3125 100644 --- a/compiler/src/dotty/tools/dotc/transform/UnusedDecls.scala +++ b/compiler/src/dotty/tools/dotc/transform/UnusedDecls.scala @@ -9,14 +9,14 @@ import dotty.tools.dotc.core.Phases.Phase import dotty.tools.dotc.core.Types._ import dotty.tools.dotc.transform.MegaPhase.MiniPhase -/** This phase removes ghost declarations of val`s (except for parameters). +/** This phase removes erased declarations of val`s (except for parameters). * - * `ghost val x = ...` are removed + * `erased val x = ...` are removed */ -class GhostDecls extends MiniPhase with InfoTransformer { +class ErasedDecls extends MiniPhase with InfoTransformer { import tpd._ - override def phaseName: String = "ghostDecls" + override def phaseName: String = "erasedDecls" override def runsAfterGroupsOf: Set[Class[_ <: Phase]] = Set( classOf[PatternMatcher] // Make sure pattern match errors are emitted @@ -24,7 +24,7 @@ class GhostDecls extends MiniPhase with InfoTransformer { /** Check what the phase achieves, to be called at any point after it is finished. */ override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = tree match { - case tree: ValOrDefDef if !tree.symbol.is(Param) => assert(!tree.symbol.is(Ghost, butNot = Param)) + case tree: ValOrDefDef if !tree.symbol.is(Param) => assert(!tree.symbol.is(Erased, butNot = Param)) case _ => } @@ -35,15 +35,15 @@ class GhostDecls extends MiniPhase with InfoTransformer { override def transformValDef(tree: ValDef)(implicit ctx: Context): Tree = transformValOrDefDef(tree) private def transformValOrDefDef(tree: ValOrDefDef)(implicit ctx: Context): Tree = - if (tree.symbol.is(Ghost, butNot = Param)) EmptyTree else tree + if (tree.symbol.is(Erased, butNot = Param)) EmptyTree else tree /* Info transform */ override def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp match { case tp: ClassInfo => - if (tp.classSymbol.is(JavaDefined) || !tp.decls.iterator.exists(_.is(Ghost))) tp - else tp.derivedClassInfo(decls = tp.decls.filteredScope(!_.is(Ghost))) + if (tp.classSymbol.is(JavaDefined) || !tp.decls.iterator.exists(_.is(Erased))) tp + else tp.derivedClassInfo(decls = tp.decls.filteredScope(!_.is(Erased))) case _ => tp } } diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 9ec8dc6a8b97..12808301f93b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -780,8 +780,8 @@ trait Applications extends Compatibility { self: Typer with Dynamic => case _ => } app match { - case Apply(fun, args) if fun.tpe.widen.isGhostMethod => - tpd.cpy.Apply(app)(fun = fun, args = args.map(arg => normalizeGhostExpr(arg, "This argument is given to an ghost parameter. "))) + case Apply(fun, args) if fun.tpe.widen.isErasedMethod => + tpd.cpy.Apply(app)(fun = fun, args = args.map(arg => normalizeErasedExpr(arg, "This argument is given to an erased parameter. "))) case _ => app } } @@ -1446,7 +1446,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic => val formalsForArg: List[Type] = altFormals.map(_.head) def argTypesOfFormal(formal: Type): List[Type] = formal match { - case defn.FunctionOf(args, result, isImplicit, isGhost) => args + case defn.FunctionOf(args, result, isImplicit, isErased) => args case defn.PartialFunctionOf(arg, result) => arg :: Nil case _ => Nil } @@ -1546,17 +1546,17 @@ trait Applications extends Compatibility { self: Typer with Dynamic => /** Transforms the tree into a its default tree. * Performed to shrink the tree that is known to be erased later. */ - protected def normalizeGhostExpr(tree: Tree, msg: String)(implicit ctx: Context): Tree = { + protected def normalizeErasedExpr(tree: Tree, msg: String)(implicit ctx: Context): Tree = { if (!isPureExpr(tree)) ctx.warning(msg + "This expression will not be evaluated.", tree.pos) defaultValue(tree.tpe) } - /** Transforms the rhs tree into a its default tree if it is in an `ghost` val/def. + /** Transforms the rhs tree into a its default tree if it is in an `erased` val/def. * Performed to shrink the tree that is known to be erased later. */ - protected def normalizeGhostRhs(rhs: Tree, sym: Symbol)(implicit ctx: Context) = { - if (sym.is(Ghost) && rhs.tpe.exists) normalizeGhostExpr(rhs, "Expression is on the RHS of an `ghost` " + sym.showKind + ". ") + protected def normalizeErasedRhs(rhs: Tree, sym: Symbol)(implicit ctx: Context) = { + if (sym.is(Erased) && rhs.tpe.exists) normalizeErasedExpr(rhs, "Expression is on the RHS of an `erased` " + sym.showKind + ". ") else rhs } diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index 828da5d007da..942628519545 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -384,8 +384,8 @@ object Checking { fail(CannotHaveSameNameAs(sym, cls, CannotHaveSameNameAs.CannotBeOverridden)) sym.setFlag(Private) // break the overriding relationship by making sym Private } - if (sym.is(Ghost)) - checkApplicable(Ghost, !sym.is(MutableOrLazy)) + if (sym.is(Erased)) + checkApplicable(Erased, !sym.is(MutableOrLazy)) } /** Check the type signature of the symbol `M` defined by `tree` does not refer @@ -503,11 +503,11 @@ object Checking { case param :: params => if (param.is(Mutable)) ctx.error(ValueClassParameterMayNotBeAVar(clazz, param), param.pos) - if (param.is(Ghost)) - ctx.error("value class first parameter cannot be `ghost`", param.pos) + if (param.is(Erased)) + ctx.error("value class first parameter cannot be `erased`", param.pos) else { - for (p <- params if !p.is(Ghost)) - ctx.error("value class can only have one non `ghost` parameter", p.pos) + for (p <- params if !p.is(Erased)) + ctx.error("value class can only have one non `erased` parameter", p.pos) } case Nil => ctx.error(ValueClassNeedsOneValParam(clazz), clazz.pos) diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 41f6230889eb..69836719c7d3 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -134,10 +134,10 @@ trait NamerContextOps { this: Context => def methodType(typeParams: List[Symbol], valueParamss: List[List[Symbol]], resultType: Type, isJava: Boolean = false)(implicit ctx: Context): Type = { val monotpe = (valueParamss :\ resultType) { (params, resultType) => - val (isImplicit, isGhost) = + val (isImplicit, isErased) = if (params.isEmpty) (false, false) - else (params.head is Implicit, params.head is Ghost) - val make = MethodType.maker(isJava, isImplicit, isGhost) + else (params.head is Implicit, params.head is Erased) + val make = MethodType.maker(isJava, isImplicit, isErased) if (isJava) for (param <- params) if (param.info.isDirectRef(defn.ObjectClass)) param.info = defn.AnyType diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 9387a89311e7..feac27039f59 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -759,16 +759,16 @@ class Typer extends Namer def typedFunctionType(tree: untpd.Function, pt: Type)(implicit ctx: Context) = { val untpd.Function(args, body) = tree - val (isImplicit, isGhost) = tree match { + val (isImplicit, isErased) = tree match { case tree: untpd.NonEmptyFunction => - if (args.nonEmpty) (tree.mods.is(Implicit), tree.mods.is(Ghost)) + if (args.nonEmpty) (tree.mods.is(Implicit), tree.mods.is(Erased)) else { ctx.error(FunctionTypeNeedsNonEmptyParameterList(), tree.pos) (false, false) } case _ => (false, false) } - val funCls = defn.FunctionClass(args.length, isImplicit, isGhost) + val funCls = defn.FunctionClass(args.length, isImplicit, isErased) /** Typechecks dependent function type with given parameters `params` */ def typedDependent(params: List[ValDef])(implicit ctx: Context): Tree = { @@ -1344,7 +1344,7 @@ class Typer extends Namer val tpt1 = checkSimpleKinded(typedType(tpt)) val rhs1 = vdef.rhs match { case rhs @ Ident(nme.WILDCARD) => rhs withType tpt1.tpe - case rhs => normalizeGhostRhs(typedExpr(rhs, tpt1.tpe), sym) + case rhs => normalizeErasedRhs(typedExpr(rhs, tpt1.tpe), sym) } val vdef1 = assignType(cpy.ValDef(vdef)(name, tpt1, rhs1), sym) if (sym.is(Inline, butNot = DeferredOrTermParamOrAccessor)) @@ -1402,7 +1402,7 @@ class Typer extends Namer (tparams1, sym.owner.typeParams).zipped.foreach ((tdef, tparam) => rhsCtx.gadt.setBounds(tdef.symbol, TypeAlias(tparam.typeRef))) } - val rhs1 = normalizeGhostRhs(typedExpr(ddef.rhs, tpt1.tpe)(rhsCtx), sym) + val rhs1 = normalizeErasedRhs(typedExpr(ddef.rhs, tpt1.tpe)(rhsCtx), sym) // Overwrite inline body to make sure it is not evaluated twice if (sym.isInlineMethod) Inliner.registerInlineInfo(sym, _ => rhs1) @@ -2139,8 +2139,8 @@ class Typer extends Namer arg :: implicitArgs(formals1) } } - def eraseGhostArgs(args: List[Tree]): List[Tree] = { - if (!wtp.isGhostMethod) args + def eraseErasedArgs(args: List[Tree]): List[Tree] = { + if (!wtp.isErasedMethod) args else args.map { arg => arg.tpe match { case tpe if tpe.isStable => arg @@ -2149,7 +2149,7 @@ class Typer extends Namer } } } - val args = eraseGhostArgs(implicitArgs(wtp.paramInfos)) + val args = eraseErasedArgs(implicitArgs(wtp.paramInfos)) def propagatedFailure(args: List[Tree]): Type = args match { diff --git a/compiler/test/dotty/tools/dotc/FromTastyTests.scala b/compiler/test/dotty/tools/dotc/FromTastyTests.scala index 01a5237f79f4..9393160a78b9 100644 --- a/compiler/test/dotty/tools/dotc/FromTastyTests.scala +++ b/compiler/test/dotty/tools/dotc/FromTastyTests.scala @@ -114,12 +114,12 @@ class FromTastyTests extends ParallelTesting { "phantom-poly-4.scala", // Issue with JFunction1$mcI$sp/T - "ghost-15.scala", - "ghost-17.scala", - "ghost-20.scala", - "ghost-21.scala", - "ghost-23.scala", - "ghost-value-class.scala", + "erased-15.scala", + "erased-17.scala", + "erased-20.scala", + "erased-21.scala", + "erased-23.scala", + "erased-value-class.scala", ) ) step1.checkCompile() // Compile all files to generate the class files with tasty diff --git a/docs/_includes/features.html b/docs/_includes/features.html index 34c64d59ef36..1b1638268039 100644 --- a/docs/_includes/features.html +++ b/docs/_includes/features.html @@ -41,7 +41,7 @@

So, features?

Implemented - Ghost Terms + Erased Terms In progress diff --git a/docs/docs/internals/syntax.md b/docs/docs/internals/syntax.md index c7b61fb3751d..2e8aa21f3f55 100644 --- a/docs/docs/internals/syntax.md +++ b/docs/docs/internals/syntax.md @@ -120,7 +120,7 @@ ClassQualifier ::= ‘[’ id ‘]’ Type ::= [FunArgMods] FunArgTypes ‘=>’ Type Function(ts, t) | HkTypeParamClause ‘=>’ Type TypeLambda(ps, t) | InfixType -FunArgMods ::= { `implicit` | `ghost` } +FunArgMods ::= { `implicit` | `erased` } FunArgTypes ::= InfixType | ‘(’ [ FunArgType {‘,’ FunArgType } ] ‘)’ | '(' TypedFunParam {',' TypedFunParam } ')' diff --git a/docs/docs/reference/ghost-terms.md b/docs/docs/reference/erased-terms.md similarity index 55% rename from docs/docs/reference/ghost-terms.md rename to docs/docs/reference/erased-terms.md index 0307fa97e6ac..3e1ecdb652b6 100644 --- a/docs/docs/reference/ghost-terms.md +++ b/docs/docs/reference/erased-terms.md @@ -1,9 +1,9 @@ --- layout: doc-page -title: "Ghost Terms" +title: "Erased Terms" --- -Why ghost terms? +Why erased terms? ---------------------- The following examples shows an implementation of a simple state machine which can be in a state `On` or `Off`. The machine can change state from `Off` to `On` with `turnedOn` only if it is currently `Off`. This last constraint is @@ -36,51 +36,51 @@ Note that in the code above the actual implicit arguments for `IsOff` are never As these terms are never used at runtime there is not real need to have them around, but they still need to be present in some form in the generated code to be able to do separate compilation and retain binary compatiblity. -How to define ghost terms? +How to define erased terms? ------------------------------- -Parameters of methods and functions can be declared as ghost, placing `ghost` at the start of the parameter list (like `implicit`). +Parameters of methods and functions can be declared as erased, placing `erased` at the start of the parameter list (like `implicit`). ```scala -def methodWithGhostEv(ghost ev: Ev): Int = 42 +def methodWithErasedEv(erased ev: Ev): Int = 42 -val lambdaWithGhostEv: ghost Ev => Int = - ghost (ev: Ev) => 42 +val lambdaWithErasedEv: erased Ev => Int = + erased (ev: Ev) => 42 ``` -`ghost` parameters will not be usable for computations, though they can be used as arguments to other `ghost` parameters. +`erased` parameters will not be usable for computations, though they can be used as arguments to other `erased` parameters. ```scala -def methodWithGhostInt1(ghost i: Int): Int = +def methodWithErasedInt1(erased i: Int): Int = i + 42 // ERROR: can not use i -def methodWithGhostInt2(ghost i: Int): Int = - methodWithGhostInt1(i) // OK +def methodWithErasedInt2(erased i: Int): Int = + methodWithErasedInt1(i) // OK ``` -Not only parameters can be marked as ghost, `val` and `def` can also be marked with `ghost`. These will also only be usable as arguments to `ghost` parameters. +Not only parameters can be marked as erased, `val` and `def` can also be marked with `erased`. These will also only be usable as arguments to `erased` parameters. ```scala -ghost val ghostEvidence: Ev = ... -methodWithGhostEv(ghostEvidence) +erased val erasedEvidence: Ev = ... +methodWithErasedEv(erasedEvidence) ``` -What happens with ghost values at runtime? +What happens with erased values at runtime? ------------------------------------------- -As `ghost` are guaranteed not to be used in computations, they can and will be erased. +As `erased` are guaranteed not to be used in computations, they can and will be erased. ```scala -// becomes def methodWithGhostEv(): Int at runtime -def methodWithGhostEv(ghost ev: Ev): Int = ... +// becomes def methodWithErasedEv(): Int at runtime +def methodWithErasedEv(erased ev: Ev): Int = ... def evidence1: Ev = ... -ghost def ghostEvidence2: Ev = ... // does not exist at runtime -ghost val ghostEvidence3: Ev = ... // does not exist at runtime +erased def erasedEvidence2: Ev = ... // does not exist at runtime +erased val erasedEvidence3: Ev = ... // does not exist at runtime -// evidence1 is not evaluated and no value is passed to methodWithGhostEv -methodWithGhostEv(evidence1) +// evidence1 is not evaluated and no value is passed to methodWithErasedEv +methodWithErasedEv(evidence1) ``` -State machine with ghost evidence example +State machine with erased evidence example ------------------------------------------ The following example is an extended implementation of a simple state machine which can be in a state `On` or `Off`. The machine can change state from `Off` to `On` with `turnedOn` only if it is currently `Off`, @@ -90,9 +90,9 @@ For example, not allowing calling `turnedOff` on in an `Off` state as we would r that will not be found. As the implicit evidences of `turnedOn` and `turnedOff` are not used in the bodies of those functions -we can mark them as `ghost`. This will remove the evidence parameters at runtime, but we would still +we can mark them as `erased`. This will remove the evidence parameters at runtime, but we would still evaluate the `isOn` and `isOff` implicits that where found as arguments. -As `isOn` and `isOff` are not used except as as `ghost` arguments, we can mark them as `ghost`, hence +As `isOn` and `isOff` are not used except as as `erased` arguments, we can mark them as `erased`, hence removing the evaluation of the `isOn` and `isOff` evidences. ```scala @@ -113,13 +113,13 @@ object IsOff { class IsOn[S <: State] object IsOn { // def isOn will not exist at runtime, the compiler will only require that this evidence exists at compile time - ghost implicit val isOn: IsOn[On] = new IsOn[On] + erased implicit val isOn: IsOn[On] = new IsOn[On] } class Machine[S <: State] private { // ev will disapear from both functions - def turnedOn(implicit ghost ev: IsOff[S]): Machine[On] = new Machine[On] - def turnedOff(implicit ghost ev: IsOn[S]): Machine[Off] = new Machine[Off] + def turnedOn(implicit erased ev: IsOff[S]): Machine[On] = new Machine[On] + def turnedOff(implicit erased ev: IsOn[S]): Machine[Off] = new Machine[Off] } object Machine { @@ -147,50 +147,50 @@ object Test { Rules ----- -1) The `ghost` modifier can appear: +1) The `erased` modifier can appear: * At the start of a parameter block of a method, function or class * In a method definition * In a `val` definition (but not `lazy val` or `var`) ```scala -ghost val x = ... -ghost def f = ... +erased val x = ... +erased def f = ... -def g(ghost x: Int) = ... +def g(erased x: Int) = ... -(ghost x: Int) => ... -def h(x: ghost Int => Int) = ... +(erased x: Int) => ... +def h(x: erased Int => Int) = ... -class K(ghost x: Int) { ... } +class K(erased x: Int) { ... } ``` -2) A reference to an `ghost` definition can only be used -* Inside the expression of argument to an `ghost` parameter -* Inside the body of an `ghost` `val` or `def` +2) A reference to an `erased` definition can only be used +* Inside the expression of argument to an `erased` parameter +* Inside the body of an `erased` `val` or `def` 3) Functions -* `(ghost x1: T1, x2: T2, ..., xN: TN) => y : (ghost T1, T2, ..., TN) => R` -* `(implicit ghost x1: T1, x2: T2, ..., xN: TN) => y : (implicit ghost T1, T2, ..., TN) => R` -* `implicit ghost T1 => R <:< ghost T1 => R` -* `(implicit ghost T1, T2) => R <:< (ghost T1, T2) => R` +* `(erased x1: T1, x2: T2, ..., xN: TN) => y : (erased T1, T2, ..., TN) => R` +* `(implicit erased x1: T1, x2: T2, ..., xN: TN) => y : (implicit erased T1, T2, ..., TN) => R` +* `implicit erased T1 => R <:< erased T1 => R` +* `(implicit erased T1, T2) => R <:< (erased T1, T2) => R` * ... -Note that there is no subtype relation between `ghost T => R` and `T => R` (or `implicit ghost T => R` and `implicit T => R`) +Note that there is no subtype relation between `erased T => R` and `T => R` (or `implicit erased T => R` and `implicit T => R`) 4) Eta expansion -if `def f(ghost x: T): U` then `f: (ghost T) => U`. +if `def f(erased x: T): U` then `f: (erased T) => U`. 5) Erasure Semantics -* All `ghost` paramters are removed from the function -* All argument to `ghost` paramters are not passed to the function -* All `ghost` definitions are removed -* All `(ghost T1, T2, ..., TN) => R` and `(implicit ghost T1, T2, ..., TN) => R` become `() => R` +* All `erased` paramters are removed from the function +* All argument to `erased` paramters are not passed to the function +* All `erased` definitions are removed +* All `(erased T1, T2, ..., TN) => R` and `(implicit erased T1, T2, ..., TN) => R` become `() => R` 6) Overloading -Method with `ghost` parameters will follow the normal overloading constraints after erasure. +Method with `erased` parameters will follow the normal overloading constraints after erasure. 7) Overriding -* Member definitions overidding each other must both be `ghost` or not be `ghost` -* `def foo(x: T): U` cannot be overriden by `def foo(ghost x: T): U` an viceversa +* Member definitions overidding each other must both be `erased` or not be `erased` +* `def foo(x: T): U` cannot be overriden by `def foo(erased x: T): U` an viceversa diff --git a/docs/sidebar.yml b/docs/sidebar.yml index 0b602d254505..2aed6909d5ef 100644 --- a/docs/sidebar.yml +++ b/docs/sidebar.yml @@ -53,8 +53,8 @@ sidebar: url: docs/reference/auto-parameter-tupling.html - title: Named Type Arguments url: docs/reference/named-typeargs.html - - title: Ghost Terms - url: docs/reference/ghost-terms.html + - title: Erased Terms + url: docs/reference/erased-terms.html - title: Local Optimisations url: docs/reference/optimisations.html - title: Changed Features diff --git a/tests/generic-java-signatures/erased.check b/tests/generic-java-signatures/erased.check new file mode 100644 index 000000000000..06c86c9c4668 --- /dev/null +++ b/tests/generic-java-signatures/erased.check @@ -0,0 +1,2 @@ +public int MyErased$.f1() +U <: java.lang.Object diff --git a/tests/generic-java-signatures/ghost.scala b/tests/generic-java-signatures/erased.scala similarity index 65% rename from tests/generic-java-signatures/ghost.scala rename to tests/generic-java-signatures/erased.scala index 3bd7ec89ecfb..a9731cc748fb 100644 --- a/tests/generic-java-signatures/ghost.scala +++ b/tests/generic-java-signatures/erased.scala @@ -1,10 +1,10 @@ -object MyGhost { - def f1[U](ghost a: Int): Int = 0 +object MyErased { + def f1[U](erased a: Int): Int = 0 } object Test { def main(args: Array[String]): Unit = { - val f1 = MyGhost.getClass.getMethods.find(_.getName.endsWith("f1")).get + val f1 = MyErased.getClass.getMethods.find(_.getName.endsWith("f1")).get val tParams = f1.getTypeParameters println(f1.toGenericString) tParams.foreach { tp => diff --git a/tests/generic-java-signatures/ghost.check b/tests/generic-java-signatures/ghost.check deleted file mode 100644 index d504bc38052e..000000000000 --- a/tests/generic-java-signatures/ghost.check +++ /dev/null @@ -1,2 +0,0 @@ -public int MyGhost$.f1() -U <: java.lang.Object diff --git a/tests/neg/ghost-1.scala b/tests/neg/erased-1.scala similarity index 78% rename from tests/neg/ghost-1.scala rename to tests/neg/erased-1.scala index 57f4ef681d1a..552d2cc7e086 100644 --- a/tests/neg/ghost-1.scala +++ b/tests/neg/erased-1.scala @@ -1,6 +1,6 @@ object Test { def foo0(a: Int): Int = a - def foo1(ghost a: Int): Int = { + def foo1(erased a: Int): Int = { foo0( a // error ) @@ -17,14 +17,14 @@ object Test { ) a // error } - ghost def foo2(a: Int): Int = { + erased def foo2(a: Int): Int = { foo0(a) // OK foo1(a) // OK foo2(a) // OK foo3(a) // OK a // OK } - ghost def foo3(ghost a: Int): Int = { + erased def foo3(erased a: Int): Int = { foo0(a) // OK foo1(a) // OK foo2(a) // OK diff --git a/tests/neg/ghost-2.scala b/tests/neg/erased-2.scala similarity index 75% rename from tests/neg/ghost-2.scala rename to tests/neg/erased-2.scala index 58bc4f236aa0..bab269061899 100644 --- a/tests/neg/ghost-2.scala +++ b/tests/neg/erased-2.scala @@ -1,6 +1,6 @@ object Test { def foo0(a: Int): Int = a - def foo1(ghost a: Int): Int = { + def foo1(erased a: Int): Int = { foo0( u // error ) @@ -14,7 +14,7 @@ object Test { u // error u // error } - ghost def foo2(a: Int): Int = { + erased def foo2(a: Int): Int = { foo0(u) // OK foo1(u) // OK foo2(u) // OK @@ -22,7 +22,7 @@ object Test { u // warn u // OK } - ghost def foo3(ghost a: Int): Int = { + erased def foo3(erased a: Int): Int = { foo0(u) // OK foo1(u) // OK foo2(u) // OK @@ -31,7 +31,7 @@ object Test { u // OK } - ghost val foo4: Int = { + erased val foo4: Int = { foo0(u) // OK foo1(u) // OK foo2(u) // OK @@ -40,5 +40,5 @@ object Test { u // OK } - ghost def u: Int = 42 + erased def u: Int = 42 } \ No newline at end of file diff --git a/tests/neg/ghost-3.scala b/tests/neg/erased-3.scala similarity index 77% rename from tests/neg/ghost-3.scala rename to tests/neg/erased-3.scala index cb2a1435cbc9..3858208afc2a 100644 --- a/tests/neg/ghost-3.scala +++ b/tests/neg/erased-3.scala @@ -1,6 +1,6 @@ object Test { def foo0(a: Int): Int = a - def foo1(ghost a: Int): Int = { + def foo1(erased a: Int): Int = { foo0( u() // error ) @@ -14,7 +14,7 @@ object Test { u() // error u() // error } - ghost def foo2(a: Int): Int = { + erased def foo2(a: Int): Int = { foo0(u()) // OK foo1(u()) // OK foo2(u()) // OK @@ -22,7 +22,7 @@ object Test { u() // warn u() // OK } - ghost def foo3(ghost a: Int): Int = { + erased def foo3(erased a: Int): Int = { foo0(u()) // OK foo1(u()) // OK foo2(u()) // OK @@ -31,7 +31,7 @@ object Test { u() // OK } - ghost val foo4: Int = { + erased val foo4: Int = { foo0(u()) // OK foo1(u()) // OK foo2(u()) // OK @@ -41,5 +41,5 @@ object Test { u() // OK } - ghost def u(): Int = 42 + erased def u(): Int = 42 } \ No newline at end of file diff --git a/tests/neg/erased-4.scala b/tests/neg/erased-4.scala new file mode 100644 index 000000000000..99a09de2c404 --- /dev/null +++ b/tests/neg/erased-4.scala @@ -0,0 +1,17 @@ +object Test { + + def main(args: Array[String]): Unit = { + val f: erased Int => Int = + erased (x: Int) => { + x // error + } + + val f2: erased Int => Int = + erased (x: Int) => { + foo(x) + } + + def foo (erased i: Int) = 0 + } + +} diff --git a/tests/neg/ghost-5.scala b/tests/neg/erased-5.scala similarity index 62% rename from tests/neg/ghost-5.scala rename to tests/neg/erased-5.scala index 3d38f7614d0d..4137d039fc69 100644 --- a/tests/neg/ghost-5.scala +++ b/tests/neg/erased-5.scala @@ -1,14 +1,14 @@ object Test { - type UU[T] = ghost T => Int + type UU[T] = erased T => Int def main(args: Array[String]): Unit = { fun { x => - x // error: Cannot use `ghost` value in a context that is not `ghost` + x // error: Cannot use `erased` value in a context that is not `erased` } fun { - (x: Int) => x // error: `Int => Int` not compatible with `ghost Int => Int` + (x: Int) => x // error: `Int => Int` not compatible with `erased Int => Int` } } diff --git a/tests/neg/ghost-6.scala b/tests/neg/erased-6.scala similarity index 83% rename from tests/neg/ghost-6.scala rename to tests/neg/erased-6.scala index 3e0c6a3b1876..21d77d03afc2 100644 --- a/tests/neg/ghost-6.scala +++ b/tests/neg/erased-6.scala @@ -1,5 +1,5 @@ object Test { - ghost def foo: Foo = new Foo + erased def foo: Foo = new Foo foo.x() // error foo.y // error foo.z // error diff --git a/tests/neg/ghost-args-lifted.scala b/tests/neg/erased-args-lifted.scala similarity index 87% rename from tests/neg/ghost-args-lifted.scala rename to tests/neg/erased-args-lifted.scala index 78f382e5d87e..0f4b9e11ca1c 100644 --- a/tests/neg/ghost-args-lifted.scala +++ b/tests/neg/erased-args-lifted.scala @@ -1,6 +1,6 @@ object Test { def foo(a: Int)(b: Int, c: Int) = 42 - ghost def bar(i: Int): Int = { + erased def bar(i: Int): Int = { println(1) 42 } diff --git a/tests/neg/ghost-assign.scala b/tests/neg/erased-assign.scala similarity index 62% rename from tests/neg/ghost-assign.scala rename to tests/neg/erased-assign.scala index eee1c153a733..5f1bd9250e84 100644 --- a/tests/neg/ghost-assign.scala +++ b/tests/neg/erased-assign.scala @@ -1,8 +1,8 @@ object Test { var i: Int = 1 - def foo(ghost a: Int): Int = { + def foo(erased a: Int): Int = { i = a // error - ghost def r = { + erased def r = { i = a () } diff --git a/tests/neg/erased-case-class.scala b/tests/neg/erased-case-class.scala new file mode 100644 index 000000000000..d23a09ba24f0 --- /dev/null +++ b/tests/neg/erased-case-class.scala @@ -0,0 +1 @@ +case class Foo1(erased x: Int) // error diff --git a/tests/neg/erased-class.scala b/tests/neg/erased-class.scala new file mode 100644 index 000000000000..577165c0d70c --- /dev/null +++ b/tests/neg/erased-class.scala @@ -0,0 +1 @@ +erased class Test // error diff --git a/tests/neg/ghost-def-rhs.scala b/tests/neg/erased-def-rhs.scala similarity index 66% rename from tests/neg/ghost-def-rhs.scala rename to tests/neg/erased-def-rhs.scala index 92bbd336d021..23417583f860 100644 --- a/tests/neg/ghost-def-rhs.scala +++ b/tests/neg/erased-def-rhs.scala @@ -1,5 +1,5 @@ object Test { - def f(ghost i: Int) = { + def f(erased i: Int) = { def j: Int = i // error j } diff --git a/tests/neg/ghost-if-else.scala b/tests/neg/erased-if-else.scala similarity index 84% rename from tests/neg/ghost-if-else.scala rename to tests/neg/erased-if-else.scala index 253918853641..503dfc0bd1e3 100644 --- a/tests/neg/ghost-if-else.scala +++ b/tests/neg/erased-if-else.scala @@ -1,6 +1,6 @@ object Test { var b = true - def foo(ghost a: Boolean): Boolean = { + def foo(erased a: Boolean): Boolean = { if (a) // error true else diff --git a/tests/neg/ghost-implicit.scala b/tests/neg/erased-implicit.scala similarity index 58% rename from tests/neg/ghost-implicit.scala rename to tests/neg/erased-implicit.scala index fb33943c6f3c..ecfdc24a6cdf 100644 --- a/tests/neg/ghost-implicit.scala +++ b/tests/neg/erased-implicit.scala @@ -4,5 +4,5 @@ object Test { def fun(implicit a: Double): Int = 42 - ghost implicit def doubleImplicit: Double = 42.0 + erased implicit def doubleImplicit: Double = 42.0 } diff --git a/tests/neg/erased-lazy-val.scala b/tests/neg/erased-lazy-val.scala new file mode 100644 index 000000000000..7b89809eddff --- /dev/null +++ b/tests/neg/erased-lazy-val.scala @@ -0,0 +1,3 @@ +object Test { + erased lazy val i: Int = 1 // error +} diff --git a/tests/neg/ghost-match.scala b/tests/neg/erased-match.scala similarity index 88% rename from tests/neg/ghost-match.scala rename to tests/neg/erased-match.scala index d541f1192c51..2d8057519bfc 100644 --- a/tests/neg/ghost-match.scala +++ b/tests/neg/erased-match.scala @@ -1,6 +1,6 @@ object Test { var b = true - def foo(ghost a: Int): Int = { + def foo(erased a: Int): Int = { a match { // error case _ => } diff --git a/tests/neg/erased-object.scala b/tests/neg/erased-object.scala new file mode 100644 index 000000000000..99720f244ef5 --- /dev/null +++ b/tests/neg/erased-object.scala @@ -0,0 +1 @@ +erased object Test // error diff --git a/tests/neg/ghost-return.scala b/tests/neg/erased-return.scala similarity index 81% rename from tests/neg/ghost-return.scala rename to tests/neg/erased-return.scala index 4c3498f42ee7..f7cf15a079be 100644 --- a/tests/neg/ghost-return.scala +++ b/tests/neg/erased-return.scala @@ -1,6 +1,6 @@ object Test { var b = true - def foo(ghost a: Int): Int = { + def foo(erased a: Int): Int = { if (b) return a // error else diff --git a/tests/neg/erased-trait.scala b/tests/neg/erased-trait.scala new file mode 100644 index 000000000000..d80ad3848b83 --- /dev/null +++ b/tests/neg/erased-trait.scala @@ -0,0 +1 @@ +erased trait Test // error diff --git a/tests/neg/ghost-try.scala b/tests/neg/erased-try.scala similarity index 69% rename from tests/neg/ghost-try.scala rename to tests/neg/erased-try.scala index 5153343f47ea..3e9aae8ab9a4 100644 --- a/tests/neg/ghost-try.scala +++ b/tests/neg/erased-try.scala @@ -1,12 +1,12 @@ object Test { - def foo(ghost a: Int): Int = { + def foo(erased a: Int): Int = { try { a // error } catch { case _ => 42 } } - def foo2(ghost a: Int): Int = { + def foo2(erased a: Int): Int = { try { 42 } catch { diff --git a/tests/neg/erased-type.scala b/tests/neg/erased-type.scala new file mode 100644 index 000000000000..62acb815442a --- /dev/null +++ b/tests/neg/erased-type.scala @@ -0,0 +1,3 @@ +class Test { + erased type T // error +} diff --git a/tests/neg/ghost-val-rhs.scala b/tests/neg/erased-val-rhs.scala similarity index 67% rename from tests/neg/ghost-val-rhs.scala rename to tests/neg/erased-val-rhs.scala index 1c8684c12021..1b904c671478 100644 --- a/tests/neg/ghost-val-rhs.scala +++ b/tests/neg/erased-val-rhs.scala @@ -1,5 +1,5 @@ object Test { - def f(ghost i: Int) = { + def f(erased i: Int) = { val j: Int = i // error () } diff --git a/tests/neg/ghost-value-class.scala b/tests/neg/erased-value-class.scala similarity index 51% rename from tests/neg/ghost-value-class.scala rename to tests/neg/erased-value-class.scala index 38495a05dcb7..65cd3e2f961b 100644 --- a/tests/neg/ghost-value-class.scala +++ b/tests/neg/erased-value-class.scala @@ -1,4 +1,4 @@ -class Foo(ghost x: Int) extends AnyVal // error +class Foo(erased x: Int) extends AnyVal // error class Bar(x: Int)(y: Int) extends AnyVal // error diff --git a/tests/neg/erased-var.scala b/tests/neg/erased-var.scala new file mode 100644 index 000000000000..465b3362e529 --- /dev/null +++ b/tests/neg/erased-var.scala @@ -0,0 +1,3 @@ +object Test { + erased var i: Int = 1 // error +} diff --git a/tests/neg/ghost-4.scala b/tests/neg/ghost-4.scala deleted file mode 100644 index 43d80c9b8329..000000000000 --- a/tests/neg/ghost-4.scala +++ /dev/null @@ -1,17 +0,0 @@ -object Test { - - def main(args: Array[String]): Unit = { - val f: ghost Int => Int = - ghost (x: Int) => { - x // error - } - - val f2: ghost Int => Int = - ghost (x: Int) => { - foo(x) - } - - def foo (ghost i: Int) = 0 - } - -} diff --git a/tests/neg/ghost-case-class.scala b/tests/neg/ghost-case-class.scala deleted file mode 100644 index 3a3f5f9b3143..000000000000 --- a/tests/neg/ghost-case-class.scala +++ /dev/null @@ -1 +0,0 @@ -case class Foo1(ghost x: Int) // error diff --git a/tests/neg/ghost-class.scala b/tests/neg/ghost-class.scala deleted file mode 100644 index 2c4ed12df517..000000000000 --- a/tests/neg/ghost-class.scala +++ /dev/null @@ -1 +0,0 @@ -ghost class Test // error diff --git a/tests/neg/ghost-lazy-val.scala b/tests/neg/ghost-lazy-val.scala deleted file mode 100644 index 66fde1fabeb6..000000000000 --- a/tests/neg/ghost-lazy-val.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - ghost lazy val i: Int = 1 // error -} diff --git a/tests/neg/ghost-object.scala b/tests/neg/ghost-object.scala deleted file mode 100644 index 2c36a3e84fb6..000000000000 --- a/tests/neg/ghost-object.scala +++ /dev/null @@ -1 +0,0 @@ -ghost object Test // error diff --git a/tests/neg/ghost-trait.scala b/tests/neg/ghost-trait.scala deleted file mode 100644 index 407dd6bdf47a..000000000000 --- a/tests/neg/ghost-trait.scala +++ /dev/null @@ -1 +0,0 @@ -ghost trait Test // error diff --git a/tests/neg/ghost-type.scala b/tests/neg/ghost-type.scala deleted file mode 100644 index bfb2533ab21d..000000000000 --- a/tests/neg/ghost-type.scala +++ /dev/null @@ -1,3 +0,0 @@ -class Test { - ghost type T // error -} diff --git a/tests/neg/ghost-var.scala b/tests/neg/ghost-var.scala deleted file mode 100644 index c9d7275f5a9d..000000000000 --- a/tests/neg/ghost-var.scala +++ /dev/null @@ -1,3 +0,0 @@ -object Test { - ghost var i: Int = 1 // error -} diff --git a/tests/pos/ghost-args-lifted.scala b/tests/pos/erased-args-lifted.scala similarity index 81% rename from tests/pos/ghost-args-lifted.scala rename to tests/pos/erased-args-lifted.scala index 7a7184787e82..faa07cdcb0b5 100644 --- a/tests/pos/ghost-args-lifted.scala +++ b/tests/pos/erased-args-lifted.scala @@ -1,5 +1,5 @@ object Test { - def foo(ghost a: Int)(b: Int, c: Int) = 42 + def foo(erased a: Int)(b: Int, c: Int) = 42 def bar(i: Int): Int = { println(1) 42 diff --git a/tests/pos/ghost-asInstanceOf.scala b/tests/pos/erased-asInstanceOf.scala similarity index 80% rename from tests/pos/ghost-asInstanceOf.scala rename to tests/pos/erased-asInstanceOf.scala index adb46a05f59e..956e325646d9 100644 --- a/tests/pos/ghost-asInstanceOf.scala +++ b/tests/pos/erased-asInstanceOf.scala @@ -1,6 +1,6 @@ trait Dataset { - def select(ghost c: Column): Unit = () + def select(erased c: Column): Unit = () } class Column diff --git a/tests/pos/ghost-deep-context.scala b/tests/pos/erased-deep-context.scala similarity index 52% rename from tests/pos/ghost-deep-context.scala rename to tests/pos/erased-deep-context.scala index 90c2c05af7a8..049bf14c2e4f 100644 --- a/tests/pos/ghost-deep-context.scala +++ b/tests/pos/erased-deep-context.scala @@ -1,12 +1,12 @@ object Test { def outer1(): Int = { - def inner(ghost a: Int): Int = 0 + def inner(erased a: Int): Int = 0 inner(42) } def outer2(): Int = { - def inner(ghost b: Int): Int = { - def inner2(ghost a: Int): Int = 0 + def inner(erased b: Int): Int = { + def inner2(erased a: Int): Int = 0 inner2(b) } inner(42) diff --git a/tests/pos/ghost-extension-method.scala b/tests/pos/erased-extension-method.scala similarity index 58% rename from tests/pos/ghost-extension-method.scala rename to tests/pos/erased-extension-method.scala index fc73fbb9bbf4..7ef14d65e4a4 100644 --- a/tests/pos/ghost-extension-method.scala +++ b/tests/pos/erased-extension-method.scala @@ -1,3 +1,3 @@ class IntDeco(x: Int) extends AnyVal { - def foo(ghost y: Int) = x + def foo(erased y: Int) = x } diff --git a/tests/pos/erased-pathdep-1.scala b/tests/pos/erased-pathdep-1.scala new file mode 100644 index 000000000000..159f1fd5aea3 --- /dev/null +++ b/tests/pos/erased-pathdep-1.scala @@ -0,0 +1,19 @@ +object Test { + + fun1(new Bar) + fun2(new Bar) + fun3(new Bar) + + def fun1[F >: Bar <: Foo](erased f: F): f.X = null.asInstanceOf[f.X] + def fun2[F >: Bar <: Foo](erased f: F)(erased bar: f.B): f.B = null.asInstanceOf[f.B] + def fun3[F >: Bar <: Foo](erased f: F)(erased b: f.B): b.X = null.asInstanceOf[b.X] +} + +class Foo { + type X + type B <: Bar +} + +class Bar extends Foo { + type X = String +} diff --git a/tests/pos/ghost-pathdep-2.scala b/tests/pos/erased-pathdep-2.scala similarity index 85% rename from tests/pos/ghost-pathdep-2.scala rename to tests/pos/erased-pathdep-2.scala index 86788713d2d2..8fd7cc0dc7fc 100644 --- a/tests/pos/ghost-pathdep-2.scala +++ b/tests/pos/erased-pathdep-2.scala @@ -2,7 +2,7 @@ object Test { type F >: Bar <: Foo - class A(ghost val f: F) { + class A(erased val f: F) { type F1 <: f.X type F2[Z <: f.X] } diff --git a/tests/pos/ghost-pathdep-1.scala b/tests/pos/ghost-pathdep-1.scala deleted file mode 100644 index 6dfc85bdf57b..000000000000 --- a/tests/pos/ghost-pathdep-1.scala +++ /dev/null @@ -1,19 +0,0 @@ -object Test { - - fun1(new Bar) - fun2(new Bar) - fun3(new Bar) - - def fun1[F >: Bar <: Foo](ghost f: F): f.X = null.asInstanceOf[f.X] - def fun2[F >: Bar <: Foo](ghost f: F)(ghost bar: f.B): f.B = null.asInstanceOf[f.B] - def fun3[F >: Bar <: Foo](ghost f: F)(ghost b: f.B): b.X = null.asInstanceOf[b.X] -} - -class Foo { - type X - type B <: Bar -} - -class Bar extends Foo { - type X = String -} diff --git a/tests/pos/phantom-Eq.scala b/tests/pos/phantom-Eq.scala index 3552ded393b8..3a500123a754 100644 --- a/tests/pos/phantom-Eq.scala +++ b/tests/pos/phantom-Eq.scala @@ -18,15 +18,15 @@ object EqUtil { type PhantomEqEq[T] = PhantomEq[T, T] implicit class EqualsDeco[T](val x: T) extends AnyVal { - def ===[U] (y: U)(implicit ghost ce: PhantomEq[T, U]) = x.equals(y) + def ===[U] (y: U)(implicit erased ce: PhantomEq[T, U]) = x.equals(y) } - implicit ghost def eqString: PhantomEqEq[String] = ??? - implicit ghost def eqInt: PhantomEqEq[Int] = ??? - implicit ghost def eqDouble: PhantomEqEq[Double] = ??? + implicit erased def eqString: PhantomEqEq[String] = ??? + implicit erased def eqInt: PhantomEqEq[Int] = ??? + implicit erased def eqDouble: PhantomEqEq[Double] = ??? - implicit ghost def eqByteNum: PhantomEq[Byte, Number] = ??? - implicit ghost def eqNumByte: PhantomEq[Number, Byte] = ??? + implicit erased def eqByteNum: PhantomEq[Byte, Number] = ??? + implicit erased def eqNumByte: PhantomEq[Number, Byte] = ??? - implicit ghost def eqSeq[T, U](implicit ghost eq: PhantomEq[T, U]): PhantomEq[Seq[T], Seq[U]] = ??? + implicit erased def eqSeq[T, U](implicit erased eq: PhantomEq[T, U]): PhantomEq[Seq[T], Seq[U]] = ??? } diff --git a/tests/pos/phantom-Eq2/Phantom-Eq_1.scala b/tests/pos/phantom-Eq2/Phantom-Eq_1.scala index de1a723a98e9..be61e817eb99 100644 --- a/tests/pos/phantom-Eq2/Phantom-Eq_1.scala +++ b/tests/pos/phantom-Eq2/Phantom-Eq_1.scala @@ -6,16 +6,16 @@ object EqUtil { type PhantomEqEq[T] = PhantomEq[T, T] implicit class EqualsDeco[T](val x: T) extends AnyVal { - def ===[U] (y: U)(implicit ghost ce: PhantomEq[T, U]) = x.equals(y) + def ===[U] (y: U)(implicit erased ce: PhantomEq[T, U]) = x.equals(y) } - implicit ghost def eqString: PhantomEqEq[String] = new PhantomEq[String, String] - implicit ghost def eqInt: PhantomEqEq[Int] = new PhantomEq[Int, Int] - implicit ghost def eqDouble: PhantomEqEq[Double] = new PhantomEq[Double, Double] + implicit erased def eqString: PhantomEqEq[String] = new PhantomEq[String, String] + implicit erased def eqInt: PhantomEqEq[Int] = new PhantomEq[Int, Int] + implicit erased def eqDouble: PhantomEqEq[Double] = new PhantomEq[Double, Double] - implicit ghost def eqByteNum: PhantomEq[Byte, Number] = new PhantomEq[Byte, Number] - implicit ghost def eqNumByte: PhantomEq[Number, Byte] = new PhantomEq[Number, Byte] + implicit erased def eqByteNum: PhantomEq[Byte, Number] = new PhantomEq[Byte, Number] + implicit erased def eqNumByte: PhantomEq[Number, Byte] = new PhantomEq[Number, Byte] - implicit ghost def eqSeq[T, U](implicit ghost eq: PhantomEq[T, U]): PhantomEq[Seq[T], Seq[U]] = + implicit erased def eqSeq[T, U](implicit erased eq: PhantomEq[T, U]): PhantomEq[Seq[T], Seq[U]] = new PhantomEq[Seq[T], Seq[U]] } diff --git a/tests/pos/phantom-Evidence.scala b/tests/pos/phantom-Evidence.scala index 809409d98cf6..732d9795d571 100644 --- a/tests/pos/phantom-Evidence.scala +++ b/tests/pos/phantom-Evidence.scala @@ -10,8 +10,8 @@ object WithNormalState { def newInstance(): Instance[Off] = new Instance[Off] } class Instance[S <: State] private { - def getOnInstance(implicit ghost ev: S =::= Off): Instance[On] = new Instance[On] // phantom parameter ev is erased - def getOffInstance(implicit ghost ev: S =::= On): Instance[Off] = new Instance[Off] // phantom parameter ev is erased + def getOnInstance(implicit erased ev: S =::= Off): Instance[On] = new Instance[On] // phantom parameter ev is erased + def getOffInstance(implicit erased ev: S =::= On): Instance[Off] = new Instance[Off] // phantom parameter ev is erased } def run() = { @@ -24,5 +24,5 @@ object WithNormalState { object Utils { type =::=[From, To] - implicit ghost def tpEquals[A]: A =::= A = ??? + implicit erased def tpEquals[A]: A =::= A = ??? } diff --git a/tests/run/ghost-1.check b/tests/run/erased-1.check similarity index 100% rename from tests/run/ghost-1.check rename to tests/run/erased-1.check diff --git a/tests/run/ghost-1.scala b/tests/run/erased-1.scala similarity index 79% rename from tests/run/ghost-1.scala rename to tests/run/erased-1.scala index 3ba55257ad55..acb8ce68f9bf 100644 --- a/tests/run/ghost-1.scala +++ b/tests/run/erased-1.scala @@ -8,7 +8,7 @@ object Test { println("foo") 42 } - def fun(ghost boo: Int): Unit = { + def fun(erased boo: Int): Unit = { println("fun") } } diff --git a/tests/run/ghost-10.check b/tests/run/erased-10.check similarity index 100% rename from tests/run/ghost-10.check rename to tests/run/erased-10.check diff --git a/tests/run/ghost-10.scala b/tests/run/erased-10.scala similarity index 77% rename from tests/run/ghost-10.scala rename to tests/run/erased-10.scala index 2ec9861328b0..25c86c0267c8 100644 --- a/tests/run/ghost-10.scala +++ b/tests/run/erased-10.scala @@ -4,11 +4,11 @@ object Test { fun2.pacFun4(inky) } - def pacFun4(ghost clyde: Int) = { + def pacFun4(erased clyde: Int) = { println("pacFun4") } - ghost def inky: Int = { + erased def inky: Int = { println("inky") // in erased function 42 } diff --git a/tests/run/ghost-11.check b/tests/run/erased-11.check similarity index 100% rename from tests/run/ghost-11.check rename to tests/run/erased-11.check diff --git a/tests/run/ghost-11.scala b/tests/run/erased-11.scala similarity index 75% rename from tests/run/ghost-11.scala rename to tests/run/erased-11.scala index e8193c4281f3..36a8d08f8d7f 100644 --- a/tests/run/ghost-11.scala +++ b/tests/run/erased-11.scala @@ -8,17 +8,17 @@ object Test { (new Fun2().fun)({ println("z1"); boo })({ println("z2"); boo }) } - def fun(ghost x1: Int)(ghost x2: Int) = { + def fun(erased x1: Int)(erased x2: Int) = { println("fun") } - class Fun(ghost y1: Int)(ghost y2: Int) { + class Fun(erased y1: Int)(erased y2: Int) { println("Fun") } class Fun2 { println("Fun2") - def fun(ghost z1: Int)(ghost z2: Int) = { + def fun(erased z1: Int)(erased z2: Int) = { println("Fun2fun") } } diff --git a/tests/run/ghost-12.check b/tests/run/erased-12.check similarity index 100% rename from tests/run/ghost-12.check rename to tests/run/erased-12.check diff --git a/tests/run/ghost-12.scala b/tests/run/erased-12.scala similarity index 81% rename from tests/run/ghost-12.scala rename to tests/run/erased-12.scala index 463c4c88cf0e..cde677050dd6 100644 --- a/tests/run/ghost-12.scala +++ b/tests/run/erased-12.scala @@ -12,6 +12,6 @@ object Test { } -case class Foo(a: Int)(ghost b: Int) { +case class Foo(a: Int)(erased b: Int) { println("Foo") } diff --git a/tests/run/ghost-13.check b/tests/run/erased-13.check similarity index 100% rename from tests/run/ghost-13.check rename to tests/run/erased-13.check diff --git a/tests/run/ghost-13.scala b/tests/run/erased-13.scala similarity index 72% rename from tests/run/ghost-13.scala rename to tests/run/erased-13.scala index cfa8ca278bc4..442a3eab4c01 100644 --- a/tests/run/ghost-13.scala +++ b/tests/run/erased-13.scala @@ -1,14 +1,14 @@ object Test { def main(args: Array[String]): Unit = { - ghost val x = { + erased val x = { println("x") 42 } foo(x) } - def foo(ghost a: Int) = { + def foo(erased a: Int) = { println("foo") } diff --git a/tests/run/ghost-14.check b/tests/run/erased-14.check similarity index 100% rename from tests/run/ghost-14.check rename to tests/run/erased-14.check diff --git a/tests/run/ghost-14.scala b/tests/run/erased-14.scala similarity index 85% rename from tests/run/ghost-14.scala rename to tests/run/erased-14.scala index 0b1fe1e65291..6486ba8085c4 100644 --- a/tests/run/ghost-14.scala +++ b/tests/run/erased-14.scala @@ -7,7 +7,7 @@ object Test { } class Foo { - ghost val x: Int = { + erased val x: Int = { println("x") 42 } diff --git a/tests/run/ghost-15.check b/tests/run/erased-15.check similarity index 100% rename from tests/run/ghost-15.check rename to tests/run/erased-15.check diff --git a/tests/run/ghost-15.scala b/tests/run/erased-15.scala similarity index 67% rename from tests/run/ghost-15.scala rename to tests/run/erased-15.scala index 4fb21600849e..b879ee4c54d8 100644 --- a/tests/run/ghost-15.scala +++ b/tests/run/erased-15.scala @@ -10,8 +10,8 @@ object Test { } } -class Foo extends GhostFunction1[Int, Int] { - def apply(ghost x: Int): Int = { +class Foo extends ErasedFunction1[Int, Int] { + def apply(erased x: Int): Int = { println("Foo.apply") 42 } diff --git a/tests/run/ghost-16.check b/tests/run/erased-16.check similarity index 100% rename from tests/run/ghost-16.check rename to tests/run/erased-16.check diff --git a/tests/run/ghost-16.scala b/tests/run/erased-16.scala similarity index 72% rename from tests/run/ghost-16.scala rename to tests/run/erased-16.scala index 74dc6fe8d186..879af76765b7 100644 --- a/tests/run/ghost-16.scala +++ b/tests/run/erased-16.scala @@ -11,11 +11,11 @@ object Test { } class Foo { - def foo(ghost x: Int): Int = 42 + def foo(erased x: Int): Int = 42 } class Bar extends Foo { - override def foo(ghost x: Int): Int = { + override def foo(erased x: Int): Int = { println("Bar.foo") 42 } diff --git a/tests/run/ghost-17.check b/tests/run/erased-17.check similarity index 100% rename from tests/run/ghost-17.check rename to tests/run/erased-17.check diff --git a/tests/run/ghost-17.scala b/tests/run/erased-17.scala similarity index 59% rename from tests/run/ghost-17.scala rename to tests/run/erased-17.scala index eeae59837720..bde3da8ba63c 100644 --- a/tests/run/ghost-17.scala +++ b/tests/run/erased-17.scala @@ -1,8 +1,8 @@ object Test { def main(args: Array[String]): Unit = { - val f: ghost Int => Int = - ghost (x: Int) => { println("lambda"); 42 } + val f: erased Int => Int = + erased (x: Int) => { println("lambda"); 42 } f(foo) } diff --git a/tests/run/ghost-18.check b/tests/run/erased-18.check similarity index 100% rename from tests/run/ghost-18.check rename to tests/run/erased-18.check diff --git a/tests/run/ghost-18.scala b/tests/run/erased-18.scala similarity index 86% rename from tests/run/ghost-18.scala rename to tests/run/erased-18.scala index 1702cfcd1cee..c55d559f16b1 100644 --- a/tests/run/ghost-18.scala +++ b/tests/run/erased-18.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { ( - ghost (x: Int) => { + erased (x: Int) => { println("lambda") 42 } diff --git a/tests/run/ghost-19.check b/tests/run/erased-19.check similarity index 100% rename from tests/run/ghost-19.check rename to tests/run/erased-19.check diff --git a/tests/run/ghost-19.scala b/tests/run/erased-19.scala similarity index 77% rename from tests/run/ghost-19.scala rename to tests/run/erased-19.scala index 15896356dc4c..326a4eede19e 100644 --- a/tests/run/ghost-19.scala +++ b/tests/run/erased-19.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { { - ghost (x: Int) => 42 + erased (x: Int) => 42 } println("ok") diff --git a/tests/run/ghost-2.check b/tests/run/erased-2.check similarity index 100% rename from tests/run/ghost-2.check rename to tests/run/erased-2.check diff --git a/tests/run/ghost-2.scala b/tests/run/erased-2.scala similarity index 70% rename from tests/run/ghost-2.scala rename to tests/run/erased-2.scala index 9f10484b52f9..20d89990b362 100644 --- a/tests/run/ghost-2.scala +++ b/tests/run/erased-2.scala @@ -2,7 +2,7 @@ object Test { def main(args: Array[String]): Unit = { - ghost def !!! : Nothing = ??? + erased def !!! : Nothing = ??? try { fun(!!!) @@ -12,7 +12,7 @@ object Test { } } - def fun(ghost bottom: Nothing): Unit = { + def fun(erased bottom: Nothing): Unit = { println("fun") } } diff --git a/tests/run/ghost-20.check b/tests/run/erased-20.check similarity index 100% rename from tests/run/ghost-20.check rename to tests/run/erased-20.check diff --git a/tests/run/ghost-20.scala b/tests/run/erased-20.scala similarity index 61% rename from tests/run/ghost-20.scala rename to tests/run/erased-20.scala index 443055b252c9..f4e717492b6b 100644 --- a/tests/run/ghost-20.scala +++ b/tests/run/erased-20.scala @@ -1,14 +1,14 @@ object Test { def main(args: Array[String]): Unit = { - fun { ghost (x: Int) => + fun { erased (x: Int) => println("lambda") "abc" } } - def fun(f: ghost Int => String): String = { + def fun(f: erased Int => String): String = { f(35) } } diff --git a/tests/run/ghost-21.check b/tests/run/erased-21.check similarity index 100% rename from tests/run/ghost-21.check rename to tests/run/erased-21.check diff --git a/tests/run/ghost-21.scala b/tests/run/erased-21.scala similarity index 73% rename from tests/run/ghost-21.scala rename to tests/run/erased-21.scala index e9619ba2ef27..03f57ffda6c4 100644 --- a/tests/run/ghost-21.scala +++ b/tests/run/erased-21.scala @@ -1,9 +1,9 @@ object Test { - type UU[T] = ghost T => Int + type UU[T] = erased T => Int def main(args: Array[String]): Unit = { - fun { ghost x => + fun { erased x => println("lambda") 42 } diff --git a/tests/run/ghost-22.check b/tests/run/erased-22.check similarity index 100% rename from tests/run/ghost-22.check rename to tests/run/erased-22.check diff --git a/tests/run/ghost-22.scala b/tests/run/erased-22.scala similarity index 79% rename from tests/run/ghost-22.scala rename to tests/run/erased-22.scala index 643803c03bb6..ae6ed279b0ca 100644 --- a/tests/run/ghost-22.scala +++ b/tests/run/erased-22.scala @@ -10,7 +10,7 @@ object Test { println("foo") 42 } - def fun1(implicit ghost boo: Int): Int = { + def fun1(implicit erased boo: Int): Int = { println("fun1") 43 } diff --git a/tests/run/ghost-23.check b/tests/run/erased-23.check similarity index 100% rename from tests/run/ghost-23.check rename to tests/run/erased-23.check diff --git a/tests/run/erased-23.scala b/tests/run/erased-23.scala new file mode 100644 index 000000000000..8545a7bf8384 --- /dev/null +++ b/tests/run/erased-23.scala @@ -0,0 +1,22 @@ +object Test { + + def main(args: Array[String]): Unit = { + fun { implicit erased (x: Int) => + println("lambda1") + "abc" + } + + fun2 { erased implicit (x: Int) => + println("lambda2") + "abc" + } + } + + def fun(f: implicit erased Int => String): String = { + f(35) + } + + def fun2(f: erased implicit Int => String): String = { + f(36) + } +} diff --git a/tests/run/ghost-24.check b/tests/run/erased-24.check similarity index 100% rename from tests/run/ghost-24.check rename to tests/run/erased-24.check diff --git a/tests/run/ghost-24.scala b/tests/run/erased-24.scala similarity index 71% rename from tests/run/ghost-24.scala rename to tests/run/erased-24.scala index 23d00c52c57a..4faab9d85798 100644 --- a/tests/run/ghost-24.scala +++ b/tests/run/erased-24.scala @@ -4,11 +4,11 @@ object Test { println(fun(new Bar)) } - def fun(ghost foo: Foo): foo.X = { + def fun(erased foo: Foo): foo.X = { null.asInstanceOf[foo.X] } - def fun2(ghost foo: Foo)(ghost bar: foo.B): bar.X = { + def fun2(erased foo: Foo)(erased bar: foo.B): bar.X = { null.asInstanceOf[bar.X] } } diff --git a/tests/run/ghost-25.check b/tests/run/erased-25.check similarity index 100% rename from tests/run/ghost-25.check rename to tests/run/erased-25.check diff --git a/tests/run/ghost-25.scala b/tests/run/erased-25.scala similarity index 75% rename from tests/run/ghost-25.scala rename to tests/run/erased-25.scala index 036d640eda8a..97a85dd1460d 100644 --- a/tests/run/ghost-25.scala +++ b/tests/run/erased-25.scala @@ -6,5 +6,5 @@ object Test { } class Dataset { - def select[A](ghost c: Boolean): String = "abc" + def select[A](erased c: Boolean): String = "abc" } diff --git a/tests/run/ghost-26.check b/tests/run/erased-26.check similarity index 100% rename from tests/run/ghost-26.check rename to tests/run/erased-26.check diff --git a/tests/run/ghost-26.scala b/tests/run/erased-26.scala similarity index 56% rename from tests/run/ghost-26.scala rename to tests/run/erased-26.scala index 0c9d84497132..eed903ac2753 100644 --- a/tests/run/ghost-26.scala +++ b/tests/run/erased-26.scala @@ -2,5 +2,5 @@ object Test { def main(args: Array[String]): Unit = { col("abc")(true) } - def col[S](s: String)(ghost ev: Boolean): Unit = println(s) + def col[S](s: String)(erased ev: Boolean): Unit = println(s) } diff --git a/tests/run/ghost-27.check b/tests/run/erased-27.check similarity index 100% rename from tests/run/ghost-27.check rename to tests/run/erased-27.check diff --git a/tests/run/ghost-27.scala b/tests/run/erased-27.scala similarity index 83% rename from tests/run/ghost-27.scala rename to tests/run/erased-27.scala index e28b16e6c6e6..68b551520daa 100644 --- a/tests/run/ghost-27.scala +++ b/tests/run/erased-27.scala @@ -5,7 +5,7 @@ object Test { foo })(x) } - def foo(ghost a: Int): Unit = { + def foo(erased a: Int): Unit = { println("foo") } def x: Int = { diff --git a/tests/run/ghost-28.check b/tests/run/erased-28.check similarity index 100% rename from tests/run/ghost-28.check rename to tests/run/erased-28.check diff --git a/tests/run/ghost-28.scala b/tests/run/erased-28.scala similarity index 77% rename from tests/run/ghost-28.scala rename to tests/run/erased-28.scala index f51b4ca9ab23..8b916b810dff 100644 --- a/tests/run/ghost-28.scala +++ b/tests/run/erased-28.scala @@ -5,10 +5,10 @@ object Test { a = false (if (a) foo else bar)(x) } - def foo(ghost a: Int): Unit = { + def foo(erased a: Int): Unit = { println("foo") } - def bar(ghost a: Int): Unit = { + def bar(erased a: Int): Unit = { println("bar") } def x: Int = { diff --git a/tests/run/ghost-3.check b/tests/run/erased-3.check similarity index 100% rename from tests/run/ghost-3.check rename to tests/run/erased-3.check diff --git a/tests/run/ghost-3.scala b/tests/run/erased-3.scala similarity index 80% rename from tests/run/ghost-3.scala rename to tests/run/erased-3.scala index e08d48daa507..68d2f8b629c2 100644 --- a/tests/run/ghost-3.scala +++ b/tests/run/erased-3.scala @@ -14,7 +14,7 @@ object Test { "abc" } - def fun(ghost a: Int)(ghost b: String): Unit = { + def fun(erased a: Int)(erased b: String): Unit = { println("fun") } diff --git a/tests/run/ghost-4.check b/tests/run/erased-4.check similarity index 100% rename from tests/run/ghost-4.check rename to tests/run/erased-4.check diff --git a/tests/run/ghost-4.scala b/tests/run/erased-4.scala similarity index 74% rename from tests/run/ghost-4.scala rename to tests/run/erased-4.scala index e57febf0fd30..8725a7ebc00f 100644 --- a/tests/run/ghost-4.scala +++ b/tests/run/erased-4.scala @@ -15,11 +15,11 @@ object Test { "abc" } - def fun(a: Int)(ghost b: String): Unit = { + def fun(a: Int)(erased b: String): Unit = { println("fun " + a) } - def fun2(ghost a: Int)(b: String): Unit = { + def fun2(erased a: Int)(b: String): Unit = { println("fun2 " + b) } } diff --git a/tests/run/ghost-5.check b/tests/run/erased-5.check similarity index 100% rename from tests/run/ghost-5.check rename to tests/run/erased-5.check diff --git a/tests/run/ghost-5.scala b/tests/run/erased-5.scala similarity index 67% rename from tests/run/ghost-5.scala rename to tests/run/erased-5.scala index 8109e3fcd4d5..043d1a4781a7 100644 --- a/tests/run/ghost-5.scala +++ b/tests/run/erased-5.scala @@ -10,11 +10,11 @@ object Test { i } - def fun(a: Int)(ghost b: Int)(c: Int)(ghost d: Int): Unit = { + def fun(a: Int)(erased b: Int)(c: Int)(erased d: Int): Unit = { println("fun " + a + " " + c) } - def fun2(ghost a2: Int)(b2: Int)(ghost c2: Int)(d2: Int): Unit = { + def fun2(erased a2: Int)(b2: Int)(erased c2: Int)(d2: Int): Unit = { println("fun2 " + b2 + " " + d2) } } diff --git a/tests/run/ghost-6.check b/tests/run/erased-6.check similarity index 100% rename from tests/run/ghost-6.check rename to tests/run/erased-6.check diff --git a/tests/run/ghost-6.scala b/tests/run/erased-6.scala similarity index 84% rename from tests/run/ghost-6.scala rename to tests/run/erased-6.scala index d5d047cc218d..ec113fbb426b 100644 --- a/tests/run/ghost-6.scala +++ b/tests/run/erased-6.scala @@ -11,6 +11,6 @@ object Test { } -class Foo(ghost a: Int) { +class Foo(erased a: Int) { println("Foo") } diff --git a/tests/run/ghost-7.check b/tests/run/erased-7.check similarity index 100% rename from tests/run/ghost-7.check rename to tests/run/erased-7.check diff --git a/tests/run/ghost-7.scala b/tests/run/erased-7.scala similarity index 72% rename from tests/run/ghost-7.scala rename to tests/run/erased-7.scala index f6f3a0d924d6..6027c2e1572c 100644 --- a/tests/run/ghost-7.scala +++ b/tests/run/erased-7.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - def f(ghost i: Int) = { + def f(erased i: Int) = { new Foo(i)(foo) } f(5) @@ -14,6 +14,6 @@ object Test { } -class Foo(ghost a: Int)(b: Int) { +class Foo(erased a: Int)(b: Int) { println("Foo") } diff --git a/tests/run/ghost-8.check b/tests/run/erased-8.check similarity index 100% rename from tests/run/ghost-8.check rename to tests/run/erased-8.check diff --git a/tests/run/ghost-8.scala b/tests/run/erased-8.scala similarity index 72% rename from tests/run/ghost-8.scala rename to tests/run/erased-8.scala index dc0b34acea0b..afa637e709ef 100644 --- a/tests/run/ghost-8.scala +++ b/tests/run/erased-8.scala @@ -1,7 +1,7 @@ object Test { def main(args: Array[String]): Unit = { - def f(ghost i: Int) = { + def f(erased i: Int) = { new Foo(foo)(i) } f(foo) @@ -14,6 +14,6 @@ object Test { } -class Foo(a: Int)(ghost b: Int) { +class Foo(a: Int)(erased b: Int) { println("Foo") } diff --git a/tests/run/ghost-9.check b/tests/run/erased-9.check similarity index 100% rename from tests/run/ghost-9.check rename to tests/run/erased-9.check diff --git a/tests/run/ghost-9.scala b/tests/run/erased-9.scala similarity index 80% rename from tests/run/ghost-9.scala rename to tests/run/erased-9.scala index d2d203f8ec3a..a989bce068a2 100644 --- a/tests/run/ghost-9.scala +++ b/tests/run/erased-9.scala @@ -9,7 +9,7 @@ object Test { 42 } - def fun[T](ghost x: T): Unit = { + def fun[T](erased x: T): Unit = { println("fun") } } diff --git a/tests/run/ghost-frameless.check b/tests/run/erased-frameless.check similarity index 100% rename from tests/run/ghost-frameless.check rename to tests/run/erased-frameless.check diff --git a/tests/run/ghost-frameless.scala b/tests/run/erased-frameless.scala similarity index 95% rename from tests/run/ghost-frameless.scala rename to tests/run/erased-frameless.scala index 9134284d82de..5c18ef378d5f 100644 --- a/tests/run/ghost-frameless.scala +++ b/tests/run/erased-frameless.scala @@ -26,7 +26,7 @@ trait Dataset[T] { // Use c.label to do an untyped select on actual Spark Dataset, and // cast the result to TypedDataset[A] - def col[S <: String, A](s: S)(implicit ghost ev: Exists[T, s.type, A]) = + def col[S <: String, A](s: S)(implicit erased ev: Exists[T, s.type, A]) = new Column[T, A](s) // ev is only here to check than this is safe, it's never used at runtime! def collect(): Vector[T] @@ -111,8 +111,8 @@ object Test { val ds: Dataset[X4[Int, String, Double, Boolean]] = Dataset.create(source) - val ghostD = ds.col("d") - val outSpark1: Vector[Boolean] = ds.select(ghostD).collect() + val erasedD = ds.col("d") + val outSpark1: Vector[Boolean] = ds.select(erasedD).collect() assert(outSpark1 == outColl) println("end") diff --git a/tests/run/ghost-machine-state.check b/tests/run/erased-machine-state.check similarity index 100% rename from tests/run/ghost-machine-state.check rename to tests/run/erased-machine-state.check diff --git a/tests/run/ghost-machine-state.scala b/tests/run/erased-machine-state.scala similarity index 89% rename from tests/run/ghost-machine-state.scala rename to tests/run/erased-machine-state.scala index 749c35c7eeda..241bc9959903 100644 --- a/tests/run/ghost-machine-state.scala +++ b/tests/run/erased-machine-state.scala @@ -23,11 +23,11 @@ object IsOn { } class Machine[S <: State] private { - def turnedOn(implicit ghost s: IsOff[S]): Machine[On] = { + def turnedOn(implicit erased s: IsOff[S]): Machine[On] = { println("turnedOn") new Machine[On] } - def turnedOff(implicit ghost s: IsOn[S]): Machine[Off] = { + def turnedOff(implicit erased s: IsOn[S]): Machine[Off] = { println("turnedOff") new Machine[Off] } diff --git a/tests/run/ghost-poly-ref.check b/tests/run/erased-poly-ref.check similarity index 100% rename from tests/run/ghost-poly-ref.check rename to tests/run/erased-poly-ref.check diff --git a/tests/run/ghost-poly-ref.scala b/tests/run/erased-poly-ref.scala similarity index 58% rename from tests/run/ghost-poly-ref.scala rename to tests/run/erased-poly-ref.scala index ec3302227d56..9f0d3c38d417 100644 --- a/tests/run/ghost-poly-ref.scala +++ b/tests/run/erased-poly-ref.scala @@ -4,9 +4,9 @@ object Test { fun(foo(bar(5))(bar(6))) } - def fun(ghost a: Int): Unit = println("fun") + def fun(erased a: Int): Unit = println("fun") - def foo[P](ghost x: Int)(ghost y: Int): Int = 0 + def foo[P](erased x: Int)(erased y: Int): Int = 0 def bar(x: Int) = { println(x) diff --git a/tests/run/ghost-select-prefix.check b/tests/run/erased-select-prefix.check similarity index 100% rename from tests/run/ghost-select-prefix.check rename to tests/run/erased-select-prefix.check diff --git a/tests/run/ghost-select-prefix.scala b/tests/run/erased-select-prefix.scala similarity index 67% rename from tests/run/ghost-select-prefix.scala rename to tests/run/erased-select-prefix.scala index 0ab06f6d1cb1..718779ccdcfb 100644 --- a/tests/run/ghost-select-prefix.scala +++ b/tests/run/erased-select-prefix.scala @@ -25,11 +25,11 @@ object Test { () } - def bar(ghost i: Int): Unit = () + def bar(erased i: Int): Unit = () - ghost def foo0: Int = 0 - ghost def foo1(): Int = 1 - ghost def foo2[T]: Int = 2 - ghost def foo3[T](): Int = 3 + erased def foo0: Int = 0 + erased def foo1(): Int = 1 + erased def foo2[T]: Int = 2 + erased def foo3[T](): Int = 3 } diff --git a/tests/run/ghost-value-class.check b/tests/run/erased-value-class.check similarity index 100% rename from tests/run/ghost-value-class.check rename to tests/run/erased-value-class.check diff --git a/tests/run/ghost-value-class.scala b/tests/run/erased-value-class.scala similarity index 78% rename from tests/run/ghost-value-class.scala rename to tests/run/erased-value-class.scala index 6acb8063c6a2..a87b0e8bf4af 100644 --- a/tests/run/ghost-value-class.scala +++ b/tests/run/erased-value-class.scala @@ -11,6 +11,6 @@ object Test { } } -class Bar(x: Int)(ghost y: Int) extends AnyVal { +class Bar(x: Int)(erased y: Int) extends AnyVal { def foo() = x } diff --git a/tests/run/ghost-23.scala b/tests/run/ghost-23.scala deleted file mode 100644 index e4bae77828c0..000000000000 --- a/tests/run/ghost-23.scala +++ /dev/null @@ -1,22 +0,0 @@ -object Test { - - def main(args: Array[String]): Unit = { - fun { implicit ghost (x: Int) => - println("lambda1") - "abc" - } - - fun2 { ghost implicit (x: Int) => - println("lambda2") - "abc" - } - } - - def fun(f: implicit ghost Int => String): String = { - f(35) - } - - def fun2(f: ghost implicit Int => String): String = { - f(36) - } -} diff --git a/tests/run/phantom-OnHList.scala b/tests/run/phantom-OnHList.scala index 59b29dff2a8d..b97f7f812f56 100644 --- a/tests/run/phantom-OnHList.scala +++ b/tests/run/phantom-OnHList.scala @@ -77,7 +77,7 @@ trait Appender[L1 <: HList, L2 <: HList] { } object Appender { - implicit def lowLevelAppender[L1 <: HList, L2 <: HList, O <: HList](implicit ghost p: PhantomAppender.Aux[L1, L2, O]): Appender[L1, L2] { type Out = O } = + implicit def lowLevelAppender[L1 <: HList, L2 <: HList, O <: HList](implicit erased p: PhantomAppender.Aux[L1, L2, O]): Appender[L1, L2] { type Out = O } = new Appender[L1, L2] { type Out = O def apply(l1: L1, l2: L2): Out = HListN(Array.concat(l1.underlying, l2.underlying)).asInstanceOf[O] @@ -88,6 +88,6 @@ object Appender { object PhantomAppender { type Aux[L1 <: HList, L2 <: HList, O <: HList] - implicit ghost def caseHNil[L <: HList]: Aux[HNil, L, L] = ??? - implicit ghost def caseHCons[H, T <: HList, L <: HList, O <: HList](implicit ghost p: Aux[T, L, O]): Aux[H :: T, L, H :: O] = ??? + implicit erased def caseHNil[L <: HList]: Aux[HNil, L, L] = ??? + implicit erased def caseHCons[H, T <: HList, L <: HList, O <: HList](implicit erased p: Aux[T, L, O]): Aux[H :: T, L, H :: O] = ??? }