Skip to content

Commit bca861d

Browse files
szymon-rdKordyjan
authored andcommitted
Add test for wunused Inlined call
1 parent 8b09ca7 commit bca861d

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class CheckUnused extends MiniPhase:
5959
// ========== SETUP ============
6060

6161
override def prepareForUnit(tree: tpd.Tree)(using Context): Context =
62-
println(tree)
6362
val data = UnusedData()
6463
val fresh = ctx.fresh.setProperty(_key, data)
6564
fresh
@@ -76,7 +75,7 @@ class CheckUnused extends MiniPhase:
7675
traverser.traverse(tree)
7776
ctx
7877

79-
def prepareForInlined(tree: Inlined)(using Context): Context =
78+
override def prepareForInlined(tree: tpd.Inlined)(using Context): Context =
8079
traverser.traverse(tree.call)
8180
ctx
8281

tests/neg-custom-args/fatal-warnings/i15503i.scala

+21-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ package foo.test.i16925:
166166
_ = println(i) // OK
167167
} yield ()
168168

169-
package foo.test.i16679:
169+
package foo.test.i16679a:
170170
object myPackage:
171171
trait CaseClassName[A]:
172172
def name: String
@@ -182,3 +182,23 @@ package foo.test.i16679:
182182
import myPackage.CaseClassName // OK
183183
case class CoolClass(i: Int) derives CaseClassName.CaseClassByStringName
184184
println(summon[CaseClassName[CoolClass]].name)
185+
186+
package foo.test.i16679b:
187+
object myPackage:
188+
trait CaseClassName[A]:
189+
def name: String
190+
191+
object CaseClassName:
192+
import scala.deriving.Mirror
193+
inline final def derived[A](using inline A: Mirror.Of[A]): CaseClassName[A] =
194+
new CaseClassName[A]:
195+
def name: String = A.toString
196+
197+
object Foo:
198+
given x: myPackage.CaseClassName[secondPackage.CoolClass] = null
199+
200+
object secondPackage:
201+
import myPackage.CaseClassName // OK
202+
import Foo.x
203+
case class CoolClass(i: Int)
204+
println(summon[myPackage.CaseClassName[CoolClass]])

0 commit comments

Comments
 (0)