Skip to content

Commit 7198063

Browse files
committed
Disallow erased inline definitions
The issue with the combination is that the `erased` semantics get lost as the code is inlined and the reference is removed. This implies that when we check for references to erased definitions we will not find it (exaclty as with inline alone).
1 parent db34814 commit 7198063

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ object Checking {
541541
checkCombination(Abstract, Override)
542542
checkCombination(Private, Override)
543543
checkCombination(Lazy, Inline)
544+
checkCombination(Erased, Inline)
544545
checkNoConflict(Lazy, ParamAccessor, s"parameter may not be `lazy`")
545546
}
546547

tests/pos-custom-args/erased/i7878.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ object Boom {
22
import scala.compiletime.*
33
trait Fail[A <: Int, B <: Int]
44

5-
erased transparent inline given fail[X <: Int, Y <: Int]: Fail[X, Y] = {
5+
transparent inline given fail[X <: Int, Y <: Int]: Fail[X, Y] = {
66
scala.compiletime.summonFrom {
77
case t: Fail[X, y] if constValue[y] < constValue[Y] => ???
88
}
@@ -12,4 +12,4 @@ object Boom {
1212
given ev1: Fail[a.type, 2] = null
1313

1414
summon[Fail[a.type, 3]]
15-
}
15+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import language.experimental.erasedDefinitions
2+
3+
erased inline def f: Unit = () // error: illegal combination of modifiers: `erased` and `inline` for: method f
4+
inline def g: Unit = ()

0 commit comments

Comments
 (0)