File tree 5 files changed +11
-8
lines changed
compiler/src/dotty/tools/dotc
docs/docs/reference/metaprogramming
5 files changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -519,6 +519,7 @@ object Flags {
519
519
val AbstractSealed : FlagSet = Abstract | Sealed
520
520
val AbstractOrTrait : FlagSet = Abstract | Trait
521
521
val EffectivelyOpenFlags = Abstract | JavaDefined | Open | Scala2x | Trait
522
+ val AccessorOrDeferred : FlagSet = Accessor | Deferred
522
523
val PrivateAccessor : FlagSet = Accessor | Private
523
524
val AccessorOrSynthetic : FlagSet = Accessor | Synthetic
524
525
val EnumCase : FlagSet = Case | Enum
Original file line number Diff line number Diff line change @@ -938,16 +938,17 @@ object SymDenotations {
938
938
def isInlineMethod (implicit ctx : Context ): Boolean =
939
939
isAllOf(InlineMethod , butNot = Accessor )
940
940
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 ))
943
944
944
945
/** Is this a Scala 2 macro */
945
946
final def isScala2Macro (implicit ctx : Context ): Boolean = is(Macro ) && symbol.owner.is(Scala2x )
946
947
947
948
/** An erased value or an inline method.
948
949
*/
949
950
def isEffectivelyErased (implicit ctx : Context ): Boolean =
950
- is(Erased ) || isInlineMethod && ! isInlineRetained
951
+ is(Erased ) || isInlineMethod && ! isRetainedInlineMethod
951
952
952
953
/** ()T and => T types should be treated as equivalent for this symbol.
953
954
* 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 {
85
85
else oldFlags &~ Flags .HasDefaultParamsFlags // HasDefaultParamsFlags needs to be dropped because overriding might become overloading
86
86
val oldAnnotations = ref.annotations
87
87
var newAnnotations = oldAnnotations
88
- if oldSymbol.isInlineMethod && oldSymbol.isInlineRetained then
88
+ if oldSymbol.isRetainedInlineMethod then
89
89
newFlags = newFlags &~ Flags .Inline
90
90
newAnnotations = newAnnotations.filterConserve(! _.isInstanceOf [BodyAnnotation ])
91
91
// TODO: define derivedSymDenotation?
@@ -922,7 +922,7 @@ object Erasure {
922
922
(inlineMeth, stat)
923
923
}.toMap
924
924
stats.mapConserve {
925
- case stat : DefDef if stat.symbol.isInlineMethod && stat.symbol.isInlineRetained =>
925
+ case stat : DefDef if stat.symbol.isRetainedInlineMethod =>
926
926
val rdef = retainerDef(stat.symbol)
927
927
val fromParams = untpd.allParamSyms(rdef)
928
928
val toParams = untpd.allParamSyms(stat)
Original file line number Diff line number Diff line change @@ -2421,7 +2421,7 @@ class Typer extends Namer
2421
2421
*/
2422
2422
protected def inlineExpansion (mdef : DefDef )(implicit ctx : Context ): List [Tree ] =
2423
2423
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 )
2425
2425
2426
2426
def typedExpr (tree : untpd.Tree , pt : Type = WildcardType )(implicit ctx : Context ): Tree =
2427
2427
typed(tree, pt)(ctx retractMode Mode .PatternOrTypeBits )
Original file line number Diff line number Diff line change @@ -177,8 +177,9 @@ abstract class A {
177
177
object B extends A {
178
178
inline def f (): Int = 22
179
179
}
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.
182
183
```
183
184
184
185
### Relationship to @inline
You can’t perform that action at this time.
0 commit comments