Signature checks fixed for plus() and minus()
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
class Example {
|
class Example {
|
||||||
operator fun plus(): String = ""
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(): String = ""
|
||||||
operator fun unaryPlus(): Int = 0
|
operator fun unaryPlus(): Int = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
class ExampleDeprecated {
|
class ExampleDeprecated {
|
||||||
operator fun plus(): String = ""
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(): String = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
operator fun String.plus(): String = this
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun String.plus(): String = this
|
||||||
operator fun String.unaryPlus(): Int = 0
|
operator fun String.unaryPlus(): Int = 0
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
@@ -22,8 +22,8 @@ fun requireInt(n: Int) {}
|
|||||||
fun requireString(s: String) {}
|
fun requireString(s: String) {}
|
||||||
|
|
||||||
class Example2 {
|
class Example2 {
|
||||||
operator fun plus() = this
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus() = this
|
||||||
operator fun minus() = this
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun minus() = this
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
<!DEPRECATED_UNARY_PLUS_MINUS!>+this<!>
|
<!DEPRECATED_UNARY_PLUS_MINUS!>+this<!>
|
||||||
|
|||||||
+6
-2
@@ -5,6 +5,8 @@ interface Example {
|
|||||||
operator fun div(o: Example): Example
|
operator fun div(o: Example): Example
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(o: Example, s: String = ""): Example
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(o: Example, s: String = ""): Example
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun minus(vararg o: Example): Example
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun minus(vararg o: Example): Example
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(): Example
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun minus(): Example
|
||||||
|
|
||||||
operator fun unaryPlus(): Example
|
operator fun unaryPlus(): Example
|
||||||
operator fun unaryMinus(): Example
|
operator fun unaryMinus(): Example
|
||||||
@@ -94,10 +96,12 @@ interface Example3 {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
operator fun Example.plus(<!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
operator fun Example.plus(<!UNUSED_PARAMETER!>o<!>: Any): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
operator fun Example.div(<!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
operator fun Example.div(<!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun Example.plus(<!UNUSED_PARAMETER!>o<!>: Example, <!UNUSED_PARAMETER!>s<!>: String = ""): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun Example.plus(<!UNUSED_PARAMETER!>o<!>: Example, <!UNUSED_PARAMETER!>s<!>: String = ""): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun Example.minus(vararg <!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun Example.minus(vararg <!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun Example.plus(): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun Example.minus(): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
|
|
||||||
operator fun Example.unaryPlus(): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
operator fun Example.unaryPlus(): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
operator fun Example.unaryMinus(): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
operator fun Example.unaryMinus(): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
@@ -155,7 +159,7 @@ infix fun Example.i1(<!UNUSED_PARAMETER!>n<!>: Int) {}
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(<!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(<!UNUSED_PARAMETER!>o<!>: String): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun div(<!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun div(<!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(<!UNUSED_PARAMETER!>o<!>: Example, <!UNUSED_PARAMETER!>s<!>: String = ""): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun plus(<!UNUSED_PARAMETER!>o<!>: Example, <!UNUSED_PARAMETER!>s<!>: String = ""): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun minus(vararg <!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun minus(vararg <!UNUSED_PARAMETER!>o<!>: Example): Example {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||||
|
|||||||
+6
-2
@@ -27,8 +27,8 @@ public operator fun minusAssign(/*0*/ n: kotlin.Int): kotlin.String
|
|||||||
public operator fun modAssign(/*0*/ vararg n: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
public operator fun modAssign(/*0*/ vararg n: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
||||||
public operator fun next(): kotlin.String
|
public operator fun next(): kotlin.String
|
||||||
public operator fun next(/*0*/ n: kotlin.Int): kotlin.String
|
public operator fun next(/*0*/ n: kotlin.Int): kotlin.String
|
||||||
public operator fun plus(/*0*/ o: Example): Example
|
|
||||||
public operator fun plus(/*0*/ o: Example, /*1*/ s: kotlin.String = ...): Example
|
public operator fun plus(/*0*/ o: Example, /*1*/ s: kotlin.String = ...): Example
|
||||||
|
public operator fun plus(/*0*/ o: kotlin.String): Example
|
||||||
public operator fun plusAssign(/*0*/ n: kotlin.Int): kotlin.Unit
|
public operator fun plusAssign(/*0*/ n: kotlin.Int): kotlin.Unit
|
||||||
public operator fun rangeTo(/*0*/ vararg o: kotlin.String /*kotlin.Array<out kotlin.String>*/): kotlin.Unit
|
public operator fun rangeTo(/*0*/ vararg o: kotlin.String /*kotlin.Array<out kotlin.String>*/): kotlin.Unit
|
||||||
public operator fun rangeTo(/*0*/ o: kotlin.Int): kotlin.Unit
|
public operator fun rangeTo(/*0*/ o: kotlin.Int): kotlin.Unit
|
||||||
@@ -62,13 +62,15 @@ public operator fun Example.inc(): Example
|
|||||||
public operator fun Example.invoke(): kotlin.Unit
|
public operator fun Example.invoke(): kotlin.Unit
|
||||||
public operator fun Example.iterator(): kotlin.String
|
public operator fun Example.iterator(): kotlin.String
|
||||||
public operator fun Example.iterator(/*0*/ n: kotlin.Int): kotlin.String
|
public operator fun Example.iterator(/*0*/ n: kotlin.Int): kotlin.String
|
||||||
|
public operator fun Example.minus(): Example
|
||||||
public operator fun Example.minus(/*0*/ vararg o: Example /*kotlin.Array<out Example>*/): Example
|
public operator fun Example.minus(/*0*/ vararg o: Example /*kotlin.Array<out Example>*/): Example
|
||||||
public operator fun Example.minusAssign(/*0*/ n: kotlin.Int): kotlin.String
|
public operator fun Example.minusAssign(/*0*/ n: kotlin.Int): kotlin.String
|
||||||
public operator fun Example.modAssign(/*0*/ vararg n: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
public operator fun Example.modAssign(/*0*/ vararg n: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
||||||
public operator fun Example.next(): kotlin.String
|
public operator fun Example.next(): kotlin.String
|
||||||
public operator fun Example.next(/*0*/ n: kotlin.Int): kotlin.String
|
public operator fun Example.next(/*0*/ n: kotlin.Int): kotlin.String
|
||||||
public operator fun Example.plus(/*0*/ o: Example): Example
|
public operator fun Example.plus(): Example
|
||||||
public operator fun Example.plus(/*0*/ o: Example, /*1*/ s: kotlin.String = ...): Example
|
public operator fun Example.plus(/*0*/ o: Example, /*1*/ s: kotlin.String = ...): Example
|
||||||
|
public operator fun Example.plus(/*0*/ o: kotlin.Any): Example
|
||||||
public operator fun Example.plusAssign(/*0*/ n: kotlin.Int): kotlin.Unit
|
public operator fun Example.plusAssign(/*0*/ n: kotlin.Int): kotlin.Unit
|
||||||
public operator fun Example.rangeTo(/*0*/ vararg o: kotlin.String /*kotlin.Array<out kotlin.String>*/): kotlin.Unit
|
public operator fun Example.rangeTo(/*0*/ vararg o: kotlin.String /*kotlin.Array<out kotlin.String>*/): kotlin.Unit
|
||||||
public operator fun Example.rangeTo(/*0*/ o: kotlin.Int): kotlin.Unit
|
public operator fun Example.rangeTo(/*0*/ o: kotlin.Int): kotlin.Unit
|
||||||
@@ -119,11 +121,13 @@ public interface Example {
|
|||||||
public abstract operator fun invoke(): kotlin.Unit
|
public abstract operator fun invoke(): kotlin.Unit
|
||||||
public abstract operator fun iterator(): kotlin.String
|
public abstract operator fun iterator(): kotlin.String
|
||||||
public abstract operator fun iterator(/*0*/ n: kotlin.Int): kotlin.String
|
public abstract operator fun iterator(/*0*/ n: kotlin.Int): kotlin.String
|
||||||
|
public abstract operator fun minus(): Example
|
||||||
public abstract operator fun minus(/*0*/ vararg o: Example /*kotlin.Array<out Example>*/): Example
|
public abstract operator fun minus(/*0*/ vararg o: Example /*kotlin.Array<out Example>*/): Example
|
||||||
public abstract operator fun minusAssign(/*0*/ n: kotlin.Int): kotlin.String
|
public abstract operator fun minusAssign(/*0*/ n: kotlin.Int): kotlin.String
|
||||||
public abstract operator fun modAssign(/*0*/ vararg n: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
public abstract operator fun modAssign(/*0*/ vararg n: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
||||||
public abstract operator fun next(): kotlin.String
|
public abstract operator fun next(): kotlin.String
|
||||||
public abstract operator fun next(/*0*/ n: kotlin.Int): kotlin.String
|
public abstract operator fun next(/*0*/ n: kotlin.Int): kotlin.String
|
||||||
|
public abstract operator fun plus(): Example
|
||||||
public abstract operator fun plus(/*0*/ o: Example): Example
|
public abstract operator fun plus(/*0*/ o: Example): Example
|
||||||
public abstract operator fun plus(/*0*/ o: Example, /*1*/ s: kotlin.String = ...): Example
|
public abstract operator fun plus(/*0*/ o: Example, /*1*/ s: kotlin.String = ...): Example
|
||||||
public abstract operator fun plusAssign(/*0*/ n: kotlin.Int): kotlin.Unit
|
public abstract operator fun plusAssign(/*0*/ n: kotlin.Int): kotlin.Unit
|
||||||
|
|||||||
@@ -41,10 +41,8 @@ import org.jetbrains.kotlin.util.OperatorNameConventions.HAS_NEXT
|
|||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.INC
|
import org.jetbrains.kotlin.util.OperatorNameConventions.INC
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.INVOKE
|
import org.jetbrains.kotlin.util.OperatorNameConventions.INVOKE
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.ITERATOR
|
import org.jetbrains.kotlin.util.OperatorNameConventions.ITERATOR
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.MINUS
|
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.NEXT
|
import org.jetbrains.kotlin.util.OperatorNameConventions.NEXT
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.NOT
|
import org.jetbrains.kotlin.util.OperatorNameConventions.NOT
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.PLUS
|
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.RANGE_TO
|
import org.jetbrains.kotlin.util.OperatorNameConventions.RANGE_TO
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.SET
|
import org.jetbrains.kotlin.util.OperatorNameConventions.SET
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions.SET_VALUE
|
import org.jetbrains.kotlin.util.OperatorNameConventions.SET_VALUE
|
||||||
@@ -83,9 +81,9 @@ object OperatorChecks {
|
|||||||
}
|
}
|
||||||
COMPARE_TO == name -> returnsInt && singleValueParameter && noDefaultsAndVarargs
|
COMPARE_TO == name -> returnsInt && singleValueParameter && noDefaultsAndVarargs
|
||||||
|
|
||||||
BINARY_OPERATION_NAMES.any { it == name } && functionDescriptor.valueParameters.size == 1 ->
|
BINARY_OPERATION_NAMES.any { it == name } ->
|
||||||
singleValueParameter && noDefaultsAndVarargs
|
singleValueParameter && noDefaultsAndVarargs
|
||||||
(PLUS == name) || (MINUS == name) || (UNARY_PLUS == name) || (UNARY_MINUS == name) || (NOT == name) ->
|
(UNARY_PLUS == name) || (UNARY_MINUS == name) || (NOT == name) ->
|
||||||
noValueParameters
|
noValueParameters
|
||||||
(INC == name) || (DEC == name) -> {
|
(INC == name) || (DEC == name) -> {
|
||||||
val receiver = dispatchReceiverParameter ?: extensionReceiverParameter
|
val receiver = dispatchReceiverParameter ?: extensionReceiverParameter
|
||||||
|
|||||||
Reference in New Issue
Block a user