Skip to content

Commit

Permalink
Add test for wunused Inlined call
Browse files Browse the repository at this point in the history
  • Loading branch information
szymon-rd committed Mar 14, 2023
1 parent fab5e7b commit 7fed80e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/transform/CheckUnused.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class CheckUnused extends MiniPhase:
// ========== SETUP ============

override def prepareForUnit(tree: tpd.Tree)(using Context): Context =
println(tree)
val data = UnusedData()
val fresh = ctx.fresh.setProperty(_key, data)
fresh
Expand All @@ -76,7 +75,7 @@ class CheckUnused extends MiniPhase:
traverser.traverse(tree)
ctx

def prepareForInlined(tree: Inlined)(using Context): Context =
override def prepareForInlined(tree: tpd.Inlined)(using Context): Context =
traverser.traverse(tree.call)
ctx

Expand Down
22 changes: 21 additions & 1 deletion tests/neg-custom-args/fatal-warnings/i15503i.scala
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ package foo.test.i16925:
_ = println(i) // OK
} yield ()

package foo.test.i16679:
package foo.test.i16679a:
object myPackage:
trait CaseClassName[A]:
def name: String
Expand All @@ -225,3 +225,23 @@ package foo.test.i16679:
import myPackage.CaseClassName // OK
case class CoolClass(i: Int) derives CaseClassName.CaseClassByStringName
println(summon[CaseClassName[CoolClass]].name)

package foo.test.i16679b:
object myPackage:
trait CaseClassName[A]:
def name: String

object CaseClassName:
import scala.deriving.Mirror
inline final def derived[A](using inline A: Mirror.Of[A]): CaseClassName[A] =
new CaseClassName[A]:
def name: String = A.toString

object Foo:
given x: myPackage.CaseClassName[secondPackage.CoolClass] = null

object secondPackage:
import myPackage.CaseClassName // OK
import Foo.x
case class CoolClass(i: Int)
println(summon[myPackage.CaseClassName[CoolClass]])

0 comments on commit 7fed80e

Please sign in to comment.