File tree Expand file tree Collapse file tree
main/scala-3/com/softwaremill/quicklens
test/scala-3/com/softwaremill/quicklens/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -157,6 +157,8 @@ object QuicklensMacros {
157157 def poorMansLUB : TypeRepr = tpe match {
158158 case AndType (l, r) if l <:< r => l
159159 case AndType (l, r) if r <:< l => r
160+ case AndType (_, _) =>
161+ report.errorAndAbort(s " Implementation limitation: Cannot modify an & type with unrelated types. " )
160162 case _ => tpe
161163 }
162164
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ object ModifyAndTypeTest {
99 case class A (a : Int ) extends B
1010 trait B {
1111 def a : Int
12+ def b : Int = 0
1213 }
1314
1415 case class A1 (a : Int )
@@ -26,6 +27,7 @@ class ModifyAndTypeTest extends AnyFlatSpec with Matchers {
2627
2728 val modified = ab.modify(_.a).setTo(1 )
2829
30+ modified.b shouldBe 0
2931 modified.a shouldBe 1
3032 }
3133
@@ -34,22 +36,7 @@ class ModifyAndTypeTest extends AnyFlatSpec with Matchers {
3436
3537 val modified = ab.modify(_.a).setTo(1 )
3638
37- modified.a shouldBe 1
38- }
39-
40- it should " modify an & type object 2" in {
41- val ab : B & A1 = new A1 (0 ) with B
42-
43- val modified = ab.modify(_.a).setTo(1 )
44-
45- modified.a shouldBe 1
46- }
47-
48- it should " modify an & type object 3" in {
49- val ab : A1 & B = new A1 (0 ) with B
50-
51- val modified = ab.modify(_.a).setTo(1 )
52-
39+ modified.b shouldBe 0
5340 modified.a shouldBe 1
5441 }
5542
You can’t perform that action at this time.
0 commit comments