Skip to content

Commit 813a43b

Browse files
szymon-rdKordyjan
authored andcommitted
Add test for wunused Inlined call
1 parent 8bdef2f commit 813a43b

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ package foo.test.i16925:
209209
_ = println(i) // OK
210210
} yield ()
211211

212-
package foo.test.i16679:
212+
package foo.test.i16679a:
213213
object myPackage:
214214
trait CaseClassName[A]:
215215
def name: String
@@ -225,3 +225,23 @@ package foo.test.i16679:
225225
import myPackage.CaseClassName // OK
226226
case class CoolClass(i: Int) derives CaseClassName.CaseClassByStringName
227227
println(summon[CaseClassName[CoolClass]].name)
228+
229+
package foo.test.i16679b:
230+
object myPackage:
231+
trait CaseClassName[A]:
232+
def name: String
233+
234+
object CaseClassName:
235+
import scala.deriving.Mirror
236+
inline final def derived[A](using inline A: Mirror.Of[A]): CaseClassName[A] =
237+
new CaseClassName[A]:
238+
def name: String = A.toString
239+
240+
object Foo:
241+
given x: myPackage.CaseClassName[secondPackage.CoolClass] = null
242+
243+
object secondPackage:
244+
import myPackage.CaseClassName // OK
245+
import Foo.x
246+
case class CoolClass(i: Int)
247+
println(summon[myPackage.CaseClassName[CoolClass]])

0 commit comments

Comments
 (0)