"Inapplicable operator modifier" and "Inapplicable infix modifier" are now errors
This commit is contained in:
+1
-1
@@ -46,7 +46,7 @@ fun Int.foo() = this
|
||||
val foo : Int = 0
|
||||
}
|
||||
|
||||
<warning>operator</warning> fun Any.equals(<warning>other</warning> : Any?) : Boolean = true
|
||||
<error>operator</error> fun Any.equals(<warning>other</warning> : Any?) : Boolean = true
|
||||
fun Any?.equals1(<warning>other</warning> : Any?) : Boolean = true
|
||||
fun Any.equals2(<warning>other</warning> : Any?) : Boolean = true
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ abstract class NotRange4() {
|
||||
}
|
||||
|
||||
abstract class ImproperIterator3 {
|
||||
abstract <warning>operator</warning> fun hasNext() : Int
|
||||
abstract <error>operator</error> fun hasNext() : Int
|
||||
abstract operator fun next() : Int
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -16,8 +16,8 @@ fun testIncDec() {
|
||||
}
|
||||
|
||||
class WrongIncDec() {
|
||||
<warning>operator</warning> fun inc() : Int = 1
|
||||
<warning>operator</warning> fun dec() : Int = 1
|
||||
<error>operator</error> fun inc() : Int = 1
|
||||
<error>operator</error> fun dec() : Int = 1
|
||||
}
|
||||
|
||||
fun testWrongIncDec() {
|
||||
@@ -29,8 +29,8 @@ fun testWrongIncDec() {
|
||||
}
|
||||
|
||||
class UnitIncDec() {
|
||||
<warning>operator</warning> fun inc() : Unit {}
|
||||
<warning>operator</warning> fun dec() : Unit {}
|
||||
<error>operator</error> fun inc() : Unit {}
|
||||
<error>operator</error> fun dec() : Unit {}
|
||||
}
|
||||
|
||||
fun testUnitIncDec() {
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(a: Int, vararg b: Int, c: Int = 0) : Int = 0
|
||||
}
|
||||
val test = Test()
|
||||
test.p<caret>lus(1)
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(a: Int, vararg b: Int, c: Int = 0) : Int = 0
|
||||
}
|
||||
val test = Test()
|
||||
test + 1
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(vararg b: Int, c: Int = 0) : Int = 0
|
||||
}
|
||||
val test = Test()
|
||||
test.p<caret>lus(1)
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(vararg b: Int, c: Int = 0) : Int = 0
|
||||
}
|
||||
val test = Test()
|
||||
test + 1
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(a: Int, b: Int=5): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.pl<caret>us(1)
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(a: Int, b: Int=5): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test + 1
|
||||
}
|
||||
idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/missingDefaultArgument.kt
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(a: Int=1, b: Int=2) : Int = 0
|
||||
|
||||
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun plus(a: Int, b: Int): Test = Test()
|
||||
|
||||
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(vararg b: Int, c: Int = 0): Int = 0
|
||||
|
||||
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun plus(vararg b: Int, c: Int = 0): Int = 0
|
||||
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun unaryPlus(vararg a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.unaryPl<caret>us()
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun unaryPlus(vararg a: Int): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
+test
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun unaryPlus(a: Int=1): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
test.unaryPl<caret>us()
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun unaryPlus(a: Int=1): Test = Test()
|
||||
}
|
||||
val test = Test()
|
||||
+test
|
||||
}
|
||||
idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator/functionLiteralArgument.kt
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have no value parameters
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun unaryPlus(fn: () -> Unit): Test = Test()
|
||||
|
||||
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have no value parameters
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun unaryPlus(a: Int): Test = Test()
|
||||
|
||||
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have no value parameters
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun unaryPlus(vararg a: Int): Test = Test()
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have no value parameters
|
||||
fun test() {
|
||||
class Test {
|
||||
operator fun unaryPlus(a: Int): Test = Test()
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(vararg a: Int, b: Int = 0): Boolean = true
|
||||
}
|
||||
val test = Test()
|
||||
test.contai<caret>ns(1)
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(vararg a: Int, b: Int = 0): Boolean = true
|
||||
}
|
||||
val test = Test()
|
||||
1 in test
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(c: Int, vararg a: Int, b: Int = 0): Boolean = true
|
||||
}
|
||||
val test = Test()
|
||||
test.contai<caret>ns(1)
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(c: Int, vararg a: Int, b: Int = 0): Boolean = true
|
||||
}
|
||||
val test = Test()
|
||||
1 in test
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(a: Int, b: Int=5) : Boolean = true
|
||||
}
|
||||
val test = Test()
|
||||
test.c<caret>ontains(1)
|
||||
}
|
||||
Vendored
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(a: Int, b: Int=5) : Boolean = true
|
||||
}
|
||||
val test = Test()
|
||||
1 in test
|
||||
}
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: Cannot find a parameter with this name: c
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(a: Int=1, b: Int=2): Boolean = true
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: No value passed for parameter b
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(a: Int, b: Int): Boolean = true
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(a: Int=1, b: Int=2) : Boolean = true
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(a: Int, b: Int) : Boolean = true
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(vararg b: Int, c: Int = 0): Boolean = true
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have a single value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(vararg b: Int, c: Int = 0): Boolean = true
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(a: Int=1, b: Int=2) : Boolean = true
|
||||
}
|
||||
val test = Test()
|
||||
test.c<caret>ontains(a=5)
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun contains(a: Int=1, b: Int=2) : Boolean = true
|
||||
}
|
||||
val test = Test()
|
||||
5 in test
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have at least 1 value parameter
|
||||
fun test() {
|
||||
class Test{
|
||||
operator fun get() : Int = 0
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must have at least 2 value parameters
|
||||
|
||||
class C {
|
||||
operator fun set(){}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: last parameter must not have a default value or be a vararg
|
||||
|
||||
class C {
|
||||
operator fun set(s: String, vararg value: Int): Boolean = true
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: operator modifier is inapplicable on this function: must be a member or an extension
|
||||
|
||||
package p
|
||||
|
||||
operator fun get(s: String) = s
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WARNING: 'infix' modifier is inapplicable on this function
|
||||
// ERROR: 'infix' modifier is inapplicable on this function
|
||||
interface Foo {
|
||||
infix fun foo(a: Int, b: Int)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: 'infix' modifier is inapplicable on this function
|
||||
fun foo(x: Foo) {
|
||||
x.<caret>foo(bar = x)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WARNING: 'infix' modifier is inapplicable on this function
|
||||
// ERROR: 'infix' modifier is inapplicable on this function
|
||||
package ppp
|
||||
|
||||
infix fun foo(p: String){}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: 'infix' modifier is inapplicable on this function
|
||||
|
||||
class Foo {
|
||||
infix fun foo(x: Int = 0, y: Int = 0) {
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WARNING: 'infix' modifier is inapplicable on this function
|
||||
// ERROR: 'infix' modifier is inapplicable on this function
|
||||
|
||||
fun foo(x: Foo) {
|
||||
x.<caret>foo(1) { it * 2 }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// WARNING: 'infix' modifier is inapplicable on this function
|
||||
// ERROR: 'infix' modifier is inapplicable on this function
|
||||
|
||||
package demo
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// "Replace with 'newFun(p, this)'" "true"
|
||||
// ERROR: 'infix' modifier is inapplicable on this function
|
||||
|
||||
@Deprecated("", ReplaceWith("newFun(p, this)"))
|
||||
infix fun String.oldFun(p: Int) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// "Replace with 'newFun(p, this)'" "true"
|
||||
// ERROR: 'infix' modifier is inapplicable on this function
|
||||
|
||||
@Deprecated("", ReplaceWith("newFun(p, this)"))
|
||||
infix fun String.oldFun(p: Int) {
|
||||
|
||||
Reference in New Issue
Block a user