Fix tests: "infix modifier required" and "operator modifier required" errors
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
fun <T> T.compareTo(a: T): Int = 0
|
||||
operator fun <T> T.compareTo(a: T): Int = 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun <T> T.compareTo(a: T): Int = 0
|
||||
operator fun <T> T.compareTo(a: T): Int = 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun <T> T.compareTo(a: T): Int = 0
|
||||
operator fun <T> T.compareTo(a: T): Int = 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = "foo"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun String?.times(a: Int): Boolean = a == 0
|
||||
operator fun String?.times(a: Int): Boolean = a == 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String = "foo"
|
||||
|
||||
+4
-4
@@ -1,10 +1,10 @@
|
||||
fun doSomething<T>(a: T) {}
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryPlus(): Test = Test()
|
||||
fun plus(a: Test): Test = Test()
|
||||
fun unaryMinus(): Test = Test()
|
||||
operator fun unaryPlus(): Test = Test()
|
||||
operator fun plus(a: Test): Test = Test()
|
||||
operator fun unaryMinus(): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
doSomething((-((test + test).unaryPl<caret>us())).toString())
|
||||
|
||||
Vendored
+4
-4
@@ -1,10 +1,10 @@
|
||||
fun doSomething<T>(a: T) {}
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryPlus(): Test = Test()
|
||||
fun plus(a: Test): Test = Test()
|
||||
fun unaryMinus(): Test = Test()
|
||||
operator fun unaryPlus(): Test = Test()
|
||||
operator fun plus(a: Test): Test = Test()
|
||||
operator fun unaryMinus(): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
doSomething((-(+(test + test))).toString())
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
fun test() {
|
||||
class Test()
|
||||
|
||||
fun Test.unaryPlus(): Test = Test()
|
||||
operator fun Test.unaryPlus(): Test = Test()
|
||||
|
||||
val test = Test()
|
||||
test.unaryPl<caret>us()
|
||||
|
||||
idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/extensionFunction.kt.after
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
fun test() {
|
||||
class Test()
|
||||
|
||||
fun Test.unaryPlus(): Test = Test()
|
||||
operator fun Test.unaryPlus(): Test = Test()
|
||||
|
||||
val test = Test()
|
||||
+test
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// INTENTION_TEXT: Replace with '-' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryMinus(): Test = Test()
|
||||
operator fun unaryMinus(): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.unaryMin<caret>us()
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// INTENTION_TEXT: Replace with '-' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryMinus(): Test = Test()
|
||||
operator fun unaryMinus(): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
-test
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryPlus(): Test = Test()
|
||||
operator fun unaryPlus(): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
+test.unaryP<caret>lus()
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryPlus(): Test = Test()
|
||||
operator fun unaryPlus(): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
+(+test)
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// INTENTION_TEXT: Replace with '+' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryPlus(): Test = Test()
|
||||
operator fun unaryPlus(): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.unaryPl<caret>us()
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// INTENTION_TEXT: Replace with '+' operator
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryPlus(): Test = Test()
|
||||
operator fun unaryPlus(): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
+test
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class C {
|
||||
companion object {
|
||||
fun unaryMinus(): C = C()
|
||||
operator fun unaryMinus(): C = C()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
class C {
|
||||
companion object {
|
||||
fun unaryMinus(): C = C()
|
||||
operator fun unaryMinus(): C = C()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
open class Base {
|
||||
open fun unaryMinus() = this
|
||||
open operator fun unaryMinus() = this
|
||||
}
|
||||
|
||||
class C : Base() {
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun test() {
|
||||
class Test {
|
||||
fun unaryPlus<T>(): T? = this as? T
|
||||
operator fun <T> unaryPlus(): T? = this as? T
|
||||
}
|
||||
val test = Test()
|
||||
test.unaryP<caret>lus<Int>()
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
fun foo() {
|
||||
val x = 1..4
|
||||
|
||||
x <caret>forEach { a -> a }
|
||||
x.<caret>forEach { a -> a }
|
||||
}
|
||||
@@ -3,5 +3,5 @@
|
||||
fun foo() {
|
||||
val x = 1..4
|
||||
|
||||
<caret>x forEach { a -> a }
|
||||
<caret>x.forEach { a -> a }
|
||||
}
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
infix fun Int.upTo(other: Int) = this.rangeTo(other)
|
||||
|
||||
fun main() {
|
||||
(1 rangeTo 2).<caret>forEach { x -> x }
|
||||
(1 upTo 2).<caret>forEach { x -> x }
|
||||
}
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
infix fun Int.upTo(other: Int) = this.rangeTo(other)
|
||||
|
||||
fun main() {
|
||||
for (x in 1 rangeTo 2) {
|
||||
for (x in 1 upTo 2) {
|
||||
x
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
class A(val n: Int) {
|
||||
fun <caret>invoke(): Int = 1
|
||||
operator fun <caret>invoke(): Int = 1
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
class A(val n: Int) {
|
||||
fun <caret>iterator(): Iterator<Int> = throw Exception("")
|
||||
operator fun <caret>iterator(): Iterator<Int> = throw Exception("")
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
class A(val n: Int) {
|
||||
fun <caret>unaryMinus(): A = A(-n)
|
||||
operator fun <caret>unaryMinus(): A = A(-n)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun String.not(): Boolean {
|
||||
operator fun String.not(): Boolean {
|
||||
return length == 0
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun String.not(): Boolean {
|
||||
operator fun String.not(): Boolean {
|
||||
return length == 0
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun Boolean.plus(): Boolean {
|
||||
operator fun Boolean.unaryPlus(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
idea/testData/intentions/convertNegatedExpressionWithDemorgansLaw/nonstandardPrefixOperator.kt.after
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
fun Boolean.plus(): Boolean {
|
||||
operator fun Boolean.unaryPlus(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
fun main() {
|
||||
<caret>for (x in 1 rangeTo 2) {
|
||||
<caret>for (x in 1.rangeTo(2)) {
|
||||
x
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun main() {
|
||||
(1 rangeTo 2).forEach { x -> x }
|
||||
1.rangeTo(2).forEach { x -> x }
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
interface Foo {
|
||||
fun foo(f: (Int) -> Unit)
|
||||
infix fun foo(f: (Int) -> Unit)
|
||||
}
|
||||
fun foo(x: Foo) {
|
||||
x <caret>foo { it * 2 }
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
interface Foo {
|
||||
fun foo(f: (Int) -> Unit)
|
||||
infix fun foo(f: (Int) -> Unit)
|
||||
}
|
||||
fun foo(x: Foo) {
|
||||
x.foo { it * 2 }
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
infix fun String.compareTo(other: String) = 0
|
||||
|
||||
fun foo(x: String) {
|
||||
x!! <caret>compareTo "1"
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
infix fun String.compareTo(other: String) = 0
|
||||
|
||||
fun foo(x: String) {
|
||||
x!!.compareTo("1")
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
infix fun String.add(other: String) = ""
|
||||
|
||||
fun foo(x: String) {
|
||||
x plus<caret> ("1" + "2")
|
||||
x add<caret> ("1" + "2")
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
infix fun String.add(other: String) = ""
|
||||
|
||||
fun foo(x: String) {
|
||||
x.plus("1" + "2")
|
||||
x.add("1" + "2")
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
infix fun Int.compareTo(other: Int) = 0
|
||||
|
||||
fun foo(x: Int) {
|
||||
x <caret>compareTo 1
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
infix fun Int.compareTo(other: Int) = 0
|
||||
|
||||
fun foo(x: Int) {
|
||||
x.compareTo(1)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Bar {
|
||||
fun get(vararg args: Int) {}
|
||||
operator fun get(vararg args: Int) {}
|
||||
}
|
||||
|
||||
fun foo(a: Bar, i: Int) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Bar {
|
||||
fun get(vararg args: Int) {}
|
||||
operator fun get(vararg args: Int) {}
|
||||
}
|
||||
|
||||
fun foo(a: Bar, i: Int) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Bar {
|
||||
fun plusAssign(arg: Bar) {}
|
||||
operator fun plusAssign(arg: Bar) {}
|
||||
}
|
||||
|
||||
fun foo(b: Bar) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Bar {
|
||||
fun plusAssign(arg: Bar) {}
|
||||
operator fun plusAssign(arg: Bar) {}
|
||||
}
|
||||
|
||||
fun foo(b: Bar) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class bar() {
|
||||
fun invoke(i: Any?, j: Any?) : Boolean {
|
||||
operator fun invoke(i: Any?, j: Any?) : Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class bar() {
|
||||
fun invoke(i: Any?, j: Any?) : Boolean {
|
||||
operator fun invoke(i: Any?, j: Any?) : Boolean {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Mocha() {
|
||||
fun invoke(x: Int, y: String, f: (Int) -> String) {
|
||||
operator fun invoke(x: Int, y: String, f: (Int) -> String) {
|
||||
}
|
||||
}
|
||||
fun main() {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Mocha() {
|
||||
fun invoke(x: Int, y: String, f: (Int) -> String) {
|
||||
operator fun invoke(x: Int, y: String, f: (Int) -> String) {
|
||||
}
|
||||
}
|
||||
fun main() {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Mocha() {
|
||||
fun invoke(f: (Int) -> String) {}
|
||||
operator fun invoke(f: (Int) -> String) {}
|
||||
}
|
||||
fun main() {
|
||||
val mocha = Mocha()
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Mocha() {
|
||||
fun invoke(f: (Int) -> String) {}
|
||||
operator fun invoke(f: (Int) -> String) {}
|
||||
}
|
||||
fun main() {
|
||||
val mocha = Mocha()
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// IS_APPLICABLE: false
|
||||
interface Foo {
|
||||
fun get(x : Any) : Foo
|
||||
fun plus(x : Any) : Foo
|
||||
operator fun get(x : Any) : Foo
|
||||
operator fun plus(x : Any) : Foo
|
||||
}
|
||||
fun foo(x: Foo) {
|
||||
<caret>(x + x)[x]
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
interface Foo {
|
||||
fun get(x : Any) : Foo
|
||||
operator fun get(x : Any) : Foo
|
||||
}
|
||||
fun foo(x: Foo) {
|
||||
<caret>(x[x])[x]
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
interface Foo {
|
||||
fun get(x : Any) : Foo
|
||||
operator fun get(x : Any) : Foo
|
||||
}
|
||||
fun foo(x: Foo) {
|
||||
x[x][x]
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
interface Foo {
|
||||
fun inc() : Foo
|
||||
fun not() : Foo
|
||||
operator fun inc() : Foo
|
||||
operator fun not() : Foo
|
||||
}
|
||||
fun foo(x: Foo) {
|
||||
!(<caret>x.inc())
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
interface Foo {
|
||||
fun inc() : Foo
|
||||
fun not() : Foo
|
||||
operator fun inc() : Foo
|
||||
operator fun not() : Foo
|
||||
}
|
||||
fun foo(x: Foo) {
|
||||
!x.inc()
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class C() {
|
||||
fun get(i: Int) = i + 1
|
||||
operator fun get(i: Int) = i + 1
|
||||
|
||||
// KT-4513: Unnecessary parenthesis around 'this'
|
||||
val foo = (this<caret>)[41]
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
class C() {
|
||||
fun get(i: Int) = i + 1
|
||||
operator fun get(i: Int) = i + 1
|
||||
|
||||
// KT-4513: Unnecessary parenthesis around 'this'
|
||||
val foo = this[41]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// INTENTION_TEXT: Simplify negated 'in' expression to '!in'
|
||||
class A(val e: Int) {
|
||||
fun contains(i: Int): Boolean = e == i
|
||||
operator fun contains(i: Int): Boolean = e == i
|
||||
}
|
||||
|
||||
fun test(n: Int) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// INTENTION_TEXT: Simplify negated 'in' expression to '!in'
|
||||
class A(val e: Int) {
|
||||
fun contains(i: Int): Boolean = e == i
|
||||
operator fun contains(i: Int): Boolean = e == i
|
||||
}
|
||||
|
||||
fun test(n: Int) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun Int.lt(b: Int): Boolean = this < b
|
||||
infix fun Int.lt(b: Int): Boolean = this < b
|
||||
fun test(n: Int) {
|
||||
<caret>!(1 lt 2)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// INTENTION_TEXT: Simplify negated '!in' expression to 'in'
|
||||
class A(val e: Int) {
|
||||
fun contains(i: Int): Boolean = e == i
|
||||
operator fun contains(i: Int): Boolean = e == i
|
||||
}
|
||||
|
||||
fun test(n: Int) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// INTENTION_TEXT: Simplify negated '!in' expression to 'in'
|
||||
class A(val e: Int) {
|
||||
fun contains(i: Int): Boolean = e == i
|
||||
operator fun contains(i: Int): Boolean = e == i
|
||||
}
|
||||
|
||||
fun test(n: Int) {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main() {
|
||||
val testing = 5 compareTo 10
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main() {
|
||||
val test = 5<caret> div 2
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun neq(a: Int, b: Int) {
|
||||
if (a equals<caret> b) {}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun neq(a: Int, b: Int) {
|
||||
if (b equals a) {}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun neq(a: Int, b: Int) {
|
||||
if (a identityEquals<caret> b) {}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun neq(a: Int, b: Int) {
|
||||
if (b identityEquals a) {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
class Foo() {
|
||||
fun cat(x: Int): Int {return x}
|
||||
infix fun cat(x: Int): Int {return x}
|
||||
}
|
||||
|
||||
fun main() {
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun new(x: Int, y: Int): Int {
|
||||
return y <caret>minus x
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun test(a: Int, b: Int): Int {
|
||||
return a <caret>plus b
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun test(a: Int, b: Int): Int {
|
||||
return b plus a
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun doSomething<T>(a: T) {}
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun main() {
|
||||
for (i in 1<caret>..10) {
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun doSomething<T>(a: T) {}
|
||||
|
||||
fun main() {
|
||||
for (i in 1<caret> rangeTo 10) {
|
||||
doSomething("Hello World")
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun test(a: Int, b: Int): Int {
|
||||
return a <caret>times b
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fun test(a: Int, b: Int): Int {
|
||||
return b times a
|
||||
}
|
||||
Reference in New Issue
Block a user