object Test { import inc._ case class Foo(i: Int, s: String) case class Bar(f: Int, a: Foo, n: Int) val res = Bar(0, Foo(1, "hello"), 2).incBy(2) //res0: Test.Bar = Bar(2,Foo(3,hello),4) }