Fix tests: "infix modifier required" and "operator modifier required" errors
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
fun box(): String {
|
||||
val sb = StringBuilder()
|
||||
fun String.plus() {
|
||||
operator fun String.unaryPlus() {
|
||||
sb.append(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class A {
|
||||
private val sb: StringBuilder = StringBuilder()
|
||||
|
||||
fun String.plus() {
|
||||
operator fun String.unaryPlus() {
|
||||
sb.append(this)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ var result = ""
|
||||
fun result(r: String) { result = r }
|
||||
|
||||
object Foo {
|
||||
private fun String.plus() = "(" + this + ")"
|
||||
private operator fun String.unaryPlus() = "(" + this + ")"
|
||||
|
||||
fun foo() = { result(+"Stuff") }()
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ var result = "Fail"
|
||||
|
||||
class A
|
||||
|
||||
fun A.inc(s: String = "OK"): A {
|
||||
operator fun A.inc(s: String = "OK"): A {
|
||||
result = s
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ import java.util.*
|
||||
class Template() {
|
||||
val collected = ArrayList<String>()
|
||||
|
||||
fun String.plus() {
|
||||
collected.add(this@plus)
|
||||
operator fun String.unaryPlus() {
|
||||
collected.add(this@unaryPlus)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
fun <T> T.mustBe(t : T) {
|
||||
infix fun <T> T.mustBe(t : T) {
|
||||
assert("$this must be $t") {this == t}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user