scalacheat icon indicating copy to clipboard operation
scalacheat copied to clipboard

class C(x: R) not the same as class C(private val x: R)

Open aryairani opened this issue 11 years ago • 1 comments

scala> class C(private val x: Int) { def add(c: C) = x + c.x }
defined class C
scala> class C(x: Int) { def add(c: C) = x + c.x }
 error: type mismatch;
 found   : c.type (with underlying type C)
 required: ?{val x: ?}

I agree they are similar in other cases though. :-)

aryairani avatar Oct 29 '12 02:10 aryairani