Skip to content

Commit

Permalink
Add test for #258
Browse files Browse the repository at this point in the history
  • Loading branch information
OndrejSpanel committed Dec 4, 2024
1 parent 6e5670c commit 2d6d7ba
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ class ExplicitCopyTest extends AnyFlatSpec with Matchers {
accessed shouldEqual 0
}

it should "not compile when modifying a field which is not present as a copy parameter" in {
"""
case class Content(x: String)
class A(val c: Content) {
def copy(x: String = c.x): A = new A(Content(x))
}
val a = new A(Content("A"))
val am = a.modify(_.c).setTo(Content("B"))
""" shouldNot compile
}

// TODO: Would be nice to be able to handle this case. Based on the types, it
// is obvious, that the explicit copy should be picked, but I'm not sure if we
// can get that information
Expand Down

0 comments on commit 2d6d7ba

Please sign in to comment.