Skip to content

Commit b0929f2

Browse files
committed
Disallow transparent inline given .. with ..
1 parent 9b3cdc2 commit b0929f2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,9 @@ object desugar {
809809
Nil
810810
}
811811
}
812-
val classMods = if mods.is(Given) then mods &~ Inline | Synthetic else mods
812+
if mods.isAllOf(Given | Inline | Transparent) then
813+
report.error("inline non-alias given cannot be trasparent", cdef)
814+
val classMods = if mods.is(Given) then mods &~ (Inline | Transparent) | Synthetic else mods
813815
cpy.TypeDef(cdef: TypeDef)(
814816
name = className,
815817
rhs = cpy.Template(impl)(constr, parents1, clsDerived, self1,

tests/neg/i14177c.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class T
2+
3+
transparent inline given fail1: T with // error
4+
val cs = scala.compiletime.summonAll[EmptyTuple]
5+
transparent inline given fail2[X]: T with // error
6+
val cs = scala.compiletime.summonAll[EmptyTuple]
7+
transparent inline given fail3(using DummyImplicit): T with // error
8+
val cs = scala.compiletime.summonAll[EmptyTuple]
9+
10+
transparent inline given ok1: T = new T:
11+
val cs = scala.compiletime.summonAll[EmptyTuple]
12+
transparent inline given ok2[X]: T = new T:
13+
val cs = scala.compiletime.summonAll[EmptyTuple]
14+
transparent inline given ok3(using DummyImplicit): T = new T:
15+
val cs = scala.compiletime.summonAll[EmptyTuple]

0 commit comments

Comments
 (0)