Skip to content

Commit d9b9f01

Browse files
committed
Use effectivelyFinal for inline methods
1 parent 483567c commit d9b9f01

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,6 @@ object desugar {
251251
cpy.DefDef(meth)(name = methName, tparams = tparams1), epbuf.toList)
252252

253253
if (meth1.mods.is(Inline))
254-
if !meth1.rhs.isEmpty then
255-
meth1 = meth1.withMods(meth1.mods | Final)
256254
meth1.tpt match {
257255
case TypeBoundsTree(_, tpt1, _) =>
258256
meth1 = cpy.DefDef(meth1)(tpt = tpt1)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,9 @@ object SymDenotations {
10971097

10981098
/** A symbol is effectively final if it cannot be overridden in a subclass */
10991099
final def isEffectivelyFinal(implicit ctx: Context): Boolean =
1100-
isOneOf(EffectivelyFinalFlags) || !owner.isExtensibleClass
1100+
isOneOf(EffectivelyFinalFlags)
1101+
|| is(Inline, butNot = Deferred)
1102+
|| !owner.isExtensibleClass
11011103

11021104
/** A class is effectively sealed if has the `final` or `sealed` modifier, or it
11031105
* is defined in Scala 3 and is neither abstract nor open.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ object RefChecks {
157157
* 1.8.3 M is of type ()S, O is of type []T and S <: T, or
158158
* 1.9.1 If M is erased, O is erased. If O is erased, M is erased or inline.
159159
* 1.9.2 If M or O are extension methods, they must both be extension methods.
160-
* 1.10.1. If O is inline, M must be inline
160+
* 1.10.1. If O is inline (and deferred, otherwise O would be final), M must be inline
161161
* 1.10.2. If M is inline, M must not be deferred
162162
* 1.11. If O is a Scala-2 macro, M must be a Scala-2 macro.
163163
* 2. Check that only abstract classes have deferred members
@@ -399,7 +399,7 @@ object RefChecks {
399399
else if (other.isAllOf(ExtensionMethod) && !member.isAllOf(ExtensionMethod)) // (1.9.2)
400400
overrideError("is a normal method, cannot override an extension method")
401401
else if other.isInlineMethod && !member.isInlineMethod then // (1.10.1)
402-
overrideError("is not inline, cannot override an inline method")
402+
overrideError("is not inline, cannot implement an inline method")
403403
else if member.isInlineMethod && member.is(Deferred) then // (1.10.2)
404404
overrideError("is inline method, cannot be an abstract override")
405405
else if (other.isScala2Macro && !member.isScala2Macro) // (1.11)

docs/docs/reference/metaprogramming/inline.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ assert(a.g() == 33)
167167
```
168168
The inlined invocations and the dynamically dispatched invocations give the same results.
169169

170-
2. Inline methods are final.
170+
2. Inline methods are effectively final.
171171

172172
3. Inline methods can also be abstract. An abstract inline method can be implemented only by other inline methods. It cannot be invoked directly:
173173
```scala

0 commit comments

Comments
 (0)