By Pavel Talanov: KT-618 overloaded assignment operators should not allow for returning types other than Unit of Subtypes or the type where they are defined

This commit is contained in:
Andrey Breslav
2011-11-25 18:32:03 +03:00
parent ae6e87ef5a
commit a7eada71ce
2 changed files with 50 additions and 3 deletions
@@ -0,0 +1,28 @@
namespace lol
class B() {
fun plusAssign(other : B) : String {
return "s"
}
fun minusAssign(other : B) : String {
return "s"
}
fun modAssign(other : B) : String {
return "s"
}
fun divAssign(other : B) : String {
return "s"
}
fun timesAssign(other : B) : String {
return "s"
}
}
fun main(args : Array<String>) {
var c = B()
<!TYPE_MISMATCH!>c += B()<!>
<!TYPE_MISMATCH!>c *= B()<!>
<!TYPE_MISMATCH!>c /= B()<!>
<!TYPE_MISMATCH!>c -= B()<!>
<!TYPE_MISMATCH!>c %= B()<!>
}