File tree Expand file tree Collapse file tree 5 files changed +11
-8
lines changed
compiler/src/dotty/tools/dotc
docs/docs/reference/metaprogramming Expand file tree Collapse file tree 5 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -519,6 +519,7 @@ object Flags {
519519 val AbstractSealed : FlagSet = Abstract | Sealed
520520 val AbstractOrTrait : FlagSet = Abstract | Trait
521521 val EffectivelyOpenFlags = Abstract | JavaDefined | Open | Scala2x | Trait
522+ val AccessorOrDeferred : FlagSet = Accessor | Deferred
522523 val PrivateAccessor : FlagSet = Accessor | Private
523524 val AccessorOrSynthetic : FlagSet = Accessor | Synthetic
524525 val EnumCase : FlagSet = Case | Enum
Original file line number Diff line number Diff line change @@ -938,16 +938,17 @@ object SymDenotations {
938938 def isInlineMethod (implicit ctx : Context ): Boolean =
939939 isAllOf(InlineMethod , butNot = Accessor )
940940
941- def isInlineRetained (using Context ): Boolean =
942- ! is(Deferred ) && allOverriddenSymbols.exists(! _.is(Inline ))
941+ def isRetainedInlineMethod (using Context ): Boolean =
942+ isAllOf(InlineMethod , butNot = AccessorOrDeferred )
943+ && allOverriddenSymbols.exists(! _.is(Inline ))
943944
944945 /** Is this a Scala 2 macro */
945946 final def isScala2Macro (implicit ctx : Context ): Boolean = is(Macro ) && symbol.owner.is(Scala2x )
946947
947948 /** An erased value or an inline method.
948949 */
949950 def isEffectivelyErased (implicit ctx : Context ): Boolean =
950- is(Erased ) || isInlineMethod && ! isInlineRetained
951+ is(Erased ) || isInlineMethod && ! isRetainedInlineMethod
951952
952953 /** ()T and => T types should be treated as equivalent for this symbol.
953954 * Note: For the moment, we treat Scala-2 compiled symbols as loose matching,
Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ class Erasure extends Phase with DenotTransformer {
8585 else oldFlags &~ Flags .HasDefaultParamsFlags // HasDefaultParamsFlags needs to be dropped because overriding might become overloading
8686 val oldAnnotations = ref.annotations
8787 var newAnnotations = oldAnnotations
88- if oldSymbol.isInlineMethod && oldSymbol.isInlineRetained then
88+ if oldSymbol.isRetainedInlineMethod then
8989 newFlags = newFlags &~ Flags .Inline
9090 newAnnotations = newAnnotations.filterConserve(! _.isInstanceOf [BodyAnnotation ])
9191 // TODO: define derivedSymDenotation?
@@ -922,7 +922,7 @@ object Erasure {
922922 (inlineMeth, stat)
923923 }.toMap
924924 stats.mapConserve {
925- case stat : DefDef if stat.symbol.isInlineMethod && stat.symbol.isInlineRetained =>
925+ case stat : DefDef if stat.symbol.isRetainedInlineMethod =>
926926 val rdef = retainerDef(stat.symbol)
927927 val fromParams = untpd.allParamSyms(rdef)
928928 val toParams = untpd.allParamSyms(stat)
Original file line number Diff line number Diff line change @@ -2421,7 +2421,7 @@ class Typer extends Namer
24212421 */
24222422 protected def inlineExpansion (mdef : DefDef )(implicit ctx : Context ): List [Tree ] =
24232423 tpd.cpy.DefDef (mdef)(rhs = Inliner .bodyToInline(mdef.symbol))
2424- :: (if mdef.symbol.isInlineRetained then Inliner .bodyRetainer(mdef) :: Nil else Nil )
2424+ :: (if mdef.symbol.isRetainedInlineMethod then Inliner .bodyRetainer(mdef) :: Nil else Nil )
24252425
24262426 def typedExpr (tree : untpd.Tree , pt : Type = WildcardType )(implicit ctx : Context ): Tree =
24272427 typed(tree, pt)(ctx retractMode Mode .PatternOrTypeBits )
Original file line number Diff line number Diff line change @@ -177,8 +177,9 @@ abstract class A {
177177object B extends A {
178178 inline def f (): Int = 22
179179}
180- B .f() // OK
181- val a : A = B ; a.f() // error: cannot inline f() in A.
180+ B .f() // OK
181+ val a : A = B
182+ a.f() // error: cannot inline f() in A.
182183```
183184
184185### Relationship to @inline
You can’t perform that action at this time.
0 commit comments