Fix tests: "infix modifier required" and "operator modifier required" errors
This commit is contained in:
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
class A() {
|
||||
|
||||
fun div(other: A) = "hooray"
|
||||
operator fun div(other: A) = "hooray"
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
|
||||
class A(t: Int) {
|
||||
var i = t
|
||||
fun compareTo(other: A) = (this.i - other.i)
|
||||
operator fun compareTo(other: A) = (this.i - other.i)
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
|
||||
class A(t: Int) {
|
||||
var i = t
|
||||
fun compareTo(other: A) = (this.i - other.i)
|
||||
infix operator fun compareTo(other: A) = (this.i - other.i)
|
||||
}
|
||||
|
||||
fun box(): Boolean =
|
||||
|
||||
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
class A() {
|
||||
|
||||
fun not() = "hooray"
|
||||
operator fun not() = "hooray"
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
class MyInt(i: Int) {
|
||||
var b = i
|
||||
fun inc(): MyInt {
|
||||
operator fun inc(): MyInt {
|
||||
b = b + 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class ArrayWrapper<T>() {
|
||||
contents.add(item)
|
||||
}
|
||||
|
||||
fun plusAssign(rhs: ArrayWrapper<T>) {
|
||||
operator fun plusAssign(rhs: ArrayWrapper<T>) {
|
||||
contents.addAll(rhs.contents)
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -8,7 +8,7 @@ class A<T>(val list: MutableList<T>) {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> A<T>.plusAssign(other: Collection<T>) {
|
||||
operator fun <T> A<T>.plusAssign(other: Collection<T>) {
|
||||
addAll(other)
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -3,10 +3,10 @@ package foo
|
||||
open class Foo<out T>(open val value: T)
|
||||
open class MutableFoo<T>(override var value: T): Foo<T>(value)
|
||||
|
||||
fun <T> Foo<T>.plus(x: T): Foo<T> = Foo(x)
|
||||
operator fun <T> Foo<T>.plus(x: T): Foo<T> = Foo(x)
|
||||
|
||||
// overloading:
|
||||
fun <T> MutableFoo<T>.plus(x: T): MutableFoo<T> = MutableFoo(x)
|
||||
operator fun <T> MutableFoo<T>.plus(x: T): MutableFoo<T> = MutableFoo(x)
|
||||
|
||||
|
||||
fun box(): Boolean {
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun <T> ArrayList<T>.plus(other: Collection<T>): List<T> {
|
||||
operator fun <T> ArrayList<T>.plus(other: Collection<T>): List<T> {
|
||||
val c = ArrayList<T>()
|
||||
c.addAll(this)
|
||||
c.addAll(other)
|
||||
|
||||
Vendored
+2
-2
@@ -4,8 +4,8 @@ class A(val c: Int) {
|
||||
}
|
||||
|
||||
|
||||
fun A.inc() = A(5)
|
||||
fun A.dec() = A(10)
|
||||
operator fun A.inc() = A(5)
|
||||
operator fun A.dec() = A(10)
|
||||
|
||||
fun box(): Boolean {
|
||||
var a = A(1)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ var a = MyInt()
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun inc(): MyInt {
|
||||
operator fun inc(): MyInt {
|
||||
val res = MyInt();
|
||||
res.b = b;
|
||||
res.b++;
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ package foo
|
||||
|
||||
class A() {
|
||||
|
||||
fun plus() = "hooray"
|
||||
fun minus() = "not really"
|
||||
operator fun unaryPlus() = "hooray"
|
||||
operator fun unaryMinus() = "not really"
|
||||
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package foo
|
||||
class A() {
|
||||
|
||||
var message = ""
|
||||
fun plusAssign(other: A) {
|
||||
operator fun plusAssign(other: A) {
|
||||
message = message + "!"
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
class myInt(a: Int) {
|
||||
val value = a;
|
||||
|
||||
fun plus(other: myInt): myInt = myInt(value + other.value)
|
||||
operator fun plus(other: myInt): myInt = myInt(value + other.value)
|
||||
}
|
||||
|
||||
fun box(): Boolean {
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun inc(): MyInt {
|
||||
operator fun inc(): MyInt {
|
||||
val res = MyInt()
|
||||
res.b++;
|
||||
return res;
|
||||
|
||||
@@ -5,7 +5,7 @@ var a = MyInt()
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun inc(): MyInt {
|
||||
operator fun inc(): MyInt {
|
||||
b = b + 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package foo
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun dec(): MyInt {
|
||||
operator fun dec(): MyInt {
|
||||
val res = MyInt()
|
||||
res.b++;
|
||||
return res;
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package foo
|
||||
class MyInt() {
|
||||
var b = 0
|
||||
|
||||
fun dec(): MyInt {
|
||||
operator fun dec(): MyInt {
|
||||
b = b + 1;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
class MyInt(i: Int) {
|
||||
var b = i
|
||||
fun inc(): MyInt {
|
||||
operator fun inc(): MyInt {
|
||||
b = b++;
|
||||
return this;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
class MyInt(i: Int) {
|
||||
var b = i
|
||||
fun inc(): MyInt {
|
||||
operator fun inc(): MyInt {
|
||||
b++;
|
||||
return this;
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package foo
|
||||
|
||||
class A() {
|
||||
var p = "yeah"
|
||||
fun mod(other: A): A {
|
||||
operator fun mod(other: A): A {
|
||||
return A();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user