Skip to content

Commit e7f67c7

Browse files
Merge pull request #7475 from dotty-staging/remove-forceinline
Drop `forceInline` annotation
2 parents ef707e6 + 7e802a7 commit e7f67c7

File tree

15 files changed

+17
-49
lines changed

15 files changed

+17
-49
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ trait ConstraintHandling[AbstractContext] {
205205
else
206206
isSubType(tp1, tp2)
207207

208-
@forceInline final def inFrozenConstraint[T](op: => T): T = {
208+
inline final def inFrozenConstraint[T](op: => T): T = {
209209
val savedFrozen = frozenConstraint
210210
val savedLambda = caseLambda
211211
frozenConstraint = true

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,6 @@ class Definitions {
750750
@tu lazy val DeprecatedAnnot: ClassSymbol = ctx.requiredClass("scala.deprecated")
751751
@tu lazy val ImplicitAmbiguousAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.implicitAmbiguous")
752752
@tu lazy val ImplicitNotFoundAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.implicitNotFound")
753-
@tu lazy val ForceInlineAnnot: ClassSymbol = ctx.requiredClass("scala.forceInline")
754753
@tu lazy val InlineParamAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.internal.InlineParam")
755754
@tu lazy val InvariantBetweenAnnot: ClassSymbol = ctx.requiredClass("scala.annotation.internal.InvariantBetween")
756755
@tu lazy val MainAnnot: ClassSymbol = ctx.requiredClass("scala.main")

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -918,17 +918,10 @@ object SymDenotations {
918918
/** Is this a Scala 2 macro */
919919
final def isScala2Macro(implicit ctx: Context): Boolean = is(Macro) && symbol.owner.is(Scala2x)
920920

921-
/** An erased value or an inline method, excluding @forceInline annotated methods.
922-
* The latter have to be kept around to get to parity with Scala.
923-
* This is necessary at least until we have full bootstrap. Right now
924-
* dotty-bootstrapped involves running the Dotty compiler compiled with Scala 2 with
925-
* a Dotty runtime library compiled with Dotty. If we erase @forceInline annotated
926-
* methods, this means that the support methods in dotty.runtime.LazyVals vanish.
927-
* But they are needed for running the lazy val implementations in the Scala-2 compiled compiler.
921+
/** An erased value or an inline method.
928922
*/
929923
def isEffectivelyErased(implicit ctx: Context): Boolean =
930-
is(Erased) ||
931-
isInlineMethod && unforcedAnnotation(defn.ForceInlineAnnot).isEmpty
924+
is(Erased) || isInlineMethod
932925

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,6 @@ object Symbols {
908908
override def toString: String = value.asScala.toString()
909909
}
910910

911-
@forceInline def newMutableSymbolMap[T]: MutableSymbolMap[T] =
911+
inline def newMutableSymbolMap[T]: MutableSymbolMap[T] =
912912
new MutableSymbolMap(new java.util.IdentityHashMap[Symbol, T]())
913913
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4432,7 +4432,7 @@ object Types {
44324432
abstract class VariantTraversal {
44334433
protected[core] var variance: Int = 1
44344434

4435-
@forceInline protected def atVariance[T](v: Int)(op: => T): T = {
4435+
inline protected def atVariance[T](v: Int)(op: => T): T = {
44364436
val saved = variance
44374437
variance = v
44384438
val res = op

compiler/src/dotty/tools/dotc/parsing/xml/MarkupParsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ object MarkupParsers {
317317
}
318318

319319
/** Some try/catch/finally logic used by xLiteral and xLiteralPattern. */
320-
@forceInline private def xLiteralCommon(f: () => Tree, ifTruncated: String => Unit): Tree = {
320+
inline private def xLiteralCommon(f: () => Tree, ifTruncated: String => Unit): Tree = {
321321
assert(parser.in.token == Tokens.XMLSTART)
322322
val saved = parser.in.newTokenData
323323
saved.copyFrom(parser.in)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object ConstFold {
4848
}
4949
}
5050

51-
@forceInline private def finish[T <: Tree](tree: T)(compX: => Constant)(implicit ctx: Context): T =
51+
inline private def finish[T <: Tree](tree: T)(compX: => Constant)(implicit ctx: Context): T =
5252
try {
5353
val x = compX
5454
if (x ne null) tree.withType(ConstantType(x)).asInstanceOf[T]

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,12 @@ import dotty.tools.dotc.transform.{Splicer, TreeMapWithStages}
3333
object Inliner {
3434
import tpd._
3535

36-
/** `sym` is an inline method with a known body to inline (note: definitions coming
37-
* from Scala2x class files might be `@forceInline`, but still lack that body).
36+
/** `sym` is an inline method with a known body to inline.
3837
*/
3938
def hasBodyToInline(sym: SymDenotation)(implicit ctx: Context): Boolean =
4039
sym.isInlineMethod && sym.hasAnnotation(defn.BodyAnnot)
4140

4241
/** The body to inline for method `sym`, or `EmptyTree` if none exists.
43-
* Note: definitions coming from Scala2x class files might be `@forceInline`,
44-
* but still lack that body.
4542
* @pre hasBodyToInline(sym)
4643
*/
4744
def bodyToInline(sym: SymDenotation)(implicit ctx: Context): Tree =

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,6 @@ class Namer { typer: Typer =>
830830
else {
831831
val ann = Annotation.deferred(cls)(typedAnnotation(annotTree))
832832
sym.addAnnotation(ann)
833-
if (cls == defn.ForceInlineAnnot && sym.is(Method, butNot = Accessor))
834-
sym.setFlag(Inline)
835833
}
836834
}
837835
case _ =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ trait QuotesAndSplices {
165165
object splitter extends tpd.TreeMap {
166166
private var variance: Int = 1
167167

168-
@forceInline private def atVariance[T](v: Int)(op: => T): T = {
168+
inline private def atVariance[T](v: Int)(op: => T): T = {
169169
val saved = variance
170170
variance = v
171171
val res = op

0 commit comments

Comments
 (0)