Fix tests: "infix modifier required" and "operator modifier required" errors

This commit is contained in:
Yan Zhulanow
2015-11-26 15:56:56 +03:00
parent a3ff3ffc45
commit 9d1af5a17e
635 changed files with 1283 additions and 1617 deletions
+2 -2
View File
@@ -1,9 +1,9 @@
class MyList<T>() {
var value: T? = null
fun get(index: Int): T = value!!
operator fun get(index: Int): T = value!!
fun set(index: Int, value: T) { this.value = value }
operator fun set(index: Int, value: T) { this.value = value }
}
fun box(): String {
+2 -2
View File
@@ -1,9 +1,9 @@
class IntRange {
fun contains(a: Int) = (1..2).contains(a)
operator fun contains(a: Int) = (1..2).contains(a)
}
class C() {
fun rangeTo(i: Int) = IntRange()
operator fun rangeTo(i: Int) = IntRange()
}
+1 -1
View File
@@ -1,7 +1,7 @@
import java.util.HashMap
import java.io.*
fun <K, V> MutableMap<K, V>.set(key : K, value : V) = put(key, value)
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) = put(key, value)
fun box() : String {
+1 -1
View File
@@ -1,4 +1,4 @@
fun Int?.inc() : Int { if (this != null) return this.inc() else throw NullPointerException() }
operator fun Int?.inc() : Int { if (this != null) return this.inc() else throw NullPointerException() }
public fun box() : String {
var i : Int? = 10
+1 -1
View File
@@ -1,4 +1,4 @@
fun Int?.inc() = this!!.inc()
operator fun Int?.inc() = this!!.inc()
public fun box() : String {
var i : Int? = 10
+1 -1
View File
@@ -1,6 +1,6 @@
import java.util.ArrayList
fun Int.plus(a: Int?) = this + a!!
operator fun Int.plus(a: Int?) = this + a!!
public open class PerfectNumberFinder() {
open public fun isPerfect(number : Int) : Boolean {
@@ -7,7 +7,7 @@ class ArrayWrapper<T>() {
contents.add(item)
}
fun plus(b: ArrayWrapper<T>): ArrayWrapper<T> {
operator fun plus(b: ArrayWrapper<T>): ArrayWrapper<T> {
val result = ArrayWrapper<T>()
result.contents.addAll(contents)
result.contents.addAll(b.contents)
@@ -7,11 +7,11 @@ class ArrayWrapper<T>() {
contents.add(item)
}
fun plusAssign(rhs: ArrayWrapper<T>) {
operator fun plusAssign(rhs: ArrayWrapper<T>) {
contents.addAll(rhs.contents)
}
fun get(index: Int): T {
operator fun get(index: Int): T {
return contents.get(index)!!
}
}
@@ -7,14 +7,14 @@ class ArrayWrapper<T>() {
contents.add(item)
}
fun plus(rhs: ArrayWrapper<T>): ArrayWrapper<T> {
operator fun plus(rhs: ArrayWrapper<T>): ArrayWrapper<T> {
val result = ArrayWrapper<T>()
result.contents.addAll(contents)
result.contents.addAll(rhs.contents)
return result
}
fun get(index: Int): T {
operator fun get(index: Int): T {
return contents.get(index)!!
}
}
@@ -7,14 +7,14 @@ class ArrayWrapper<T>() {
contents.add(item)
}
fun plus(rhs: ArrayWrapper<T>): ArrayWrapper<T> {
operator fun plus(rhs: ArrayWrapper<T>): ArrayWrapper<T> {
val result = ArrayWrapper<T>()
result.contents.addAll(contents)
result.contents.addAll(rhs.contents)
return result
}
fun get(index: Int): T {
operator fun get(index: Int): T {
return contents.get(index)!!
}
}
@@ -7,14 +7,14 @@ class ArrayWrapper<T>() {
contents.add(item)
}
fun minus(): ArrayWrapper<T> {
operator fun unaryMinus(): ArrayWrapper<T> {
val result = ArrayWrapper<T>()
result.contents.addAll(contents)
Collections.reverse(result.contents)
return result
}
fun get(index: Int): T {
operator fun get(index: Int): T {
return contents.get(index)!!
}
}