[FIR] Add INAPPLICABLE_OPERATOR_MODIFIER diagnostic

This commit is contained in:
Andrey Zinovyev
2021-08-16 14:59:20 +03:00
committed by TeamCityServer
parent 16f41bd80c
commit 1cd321a90f
37 changed files with 388 additions and 238 deletions
@@ -1,7 +1,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class C {
operator fun compareTo(c: C): Int? = null
<!INAPPLICABLE_OPERATOR_MODIFIER!>operator<!> fun compareTo(c: C): Int? = null
}
fun test(c: C) {
@@ -9,4 +9,4 @@ fun test(c: C) {
c <= c
c >= c
c > c
}
}
@@ -1,35 +0,0 @@
//KT-1028 Wrong type checking for plusAssign
package kt1028
import java.util.*
class event<T>()
{
val callbacks = ArrayList< Function1<T, Unit> >() // Should be ArrayList<()->Unit>, bug posted
operator fun plusAssign(f : (T) -> Unit) = callbacks.add(f)
operator fun minusAssign(f : (T) -> Unit) = callbacks.remove(f)
fun call(value : T) { for(c in callbacks) c(value) }
}
class MouseMovedEventArgs()
{
public val X : Int = 0
}
class Control()
{
public val MouseMoved : event<MouseMovedEventArgs> = event<MouseMovedEventArgs>()
fun MoveMouse() = MouseMoved.call(MouseMovedEventArgs())
}
class Test()
{
fun test()
{
val control = Control()
control.MouseMoved <!ASSIGNMENT_OPERATOR_SHOULD_RETURN_UNIT!>+=<!> { it.X } // here
control.MouseMoved.plusAssign( { it.X } ) // ok
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
//KT-1028 Wrong type checking for plusAssign
package kt1028