Skip to content

Commit 47cc6f6

Browse files
Merge pull request #14250 from dotty-staging/disallow-erased-inline
Disallow erased inline definitions
2 parents 6565219 + 7e4fd6a commit 47cc6f6

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,9 @@ object Checking {
541541
checkCombination(Abstract, Override)
542542
checkCombination(Private, Override)
543543
checkCombination(Lazy, Inline)
544+
// The issue with `erased inline` is that the erased semantics get lost
545+
// as the code is inlined and the reference is removed before the erased usage check.
546+
checkCombination(Erased, Inline)
544547
checkNoConflict(Lazy, ParamAccessor, s"parameter may not be `lazy`")
545548
}
546549

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)