[FIR] Mark more calls origin as OPERATOR
This commit is contained in:
committed by
TeamCityServer
parent
0a45b3a50b
commit
07a8ae7e71
+3
-1
@@ -388,10 +388,11 @@ class ExpressionsConverter(
|
||||
buildFunctionCall {
|
||||
source = unaryExpression.toFirSourceElement()
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
source = this@buildFunctionCall.source
|
||||
source = operationReference?.toFirSourceElement() ?: this@buildFunctionCall.source
|
||||
name = conventionCallName
|
||||
}
|
||||
explicitReceiver = receiver
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
else -> throw IllegalStateException("Unexpected expression: ${unaryExpression.asText}")
|
||||
@@ -843,6 +844,7 @@ class ExpressionsConverter(
|
||||
arguments += indices
|
||||
getArgument?.let { arguments += it }
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1968,6 +1968,7 @@ open class RawFirBuilder(
|
||||
name = conventionCallName
|
||||
}
|
||||
explicitReceiver = receiver
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
else -> throw IllegalStateException("Unexpected expression: ${expression.text}")
|
||||
@@ -2064,6 +2065,7 @@ open class RawFirBuilder(
|
||||
arguments += getArgument
|
||||
}
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -520,6 +520,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
} else {
|
||||
generateResolvedAccessExpression(desugaredSource, initialValueVar)
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
|
||||
// resultVar is only used for prefix increment/decrement.
|
||||
@@ -643,6 +644,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
} else {
|
||||
generateResolvedAccessExpression(desugaredSource, initialValueVar)
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
|
||||
// resultVar is only used for prefix increment/decrement.
|
||||
@@ -759,6 +761,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
arguments += generateResolvedAccessExpression(indexVar.source, indexVar)
|
||||
}
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
|
||||
// initialValueVar is only used for postfix increment/decrement (stores the argument value before increment/decrement).
|
||||
@@ -781,6 +784,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
} else {
|
||||
generateResolvedAccessExpression(desugaredSource, initialValueVar)
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
|
||||
// resultVar is only used for prefix increment/decrement.
|
||||
@@ -809,6 +813,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
resultInitializer
|
||||
}
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
|
||||
@@ -979,6 +984,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
ConeSimpleDiagnostic("No value for array set", DiagnosticKind.Syntax)
|
||||
)
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,6 +1027,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
name = OperatorNameConventions.SET
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
argumentList = buildArgumentList {
|
||||
for (indexVariable in indexVariables) {
|
||||
arguments += indexVariable.toQualifiedAccess()
|
||||
@@ -1036,6 +1043,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
arguments += indexVariable.toQualifiedAccess()
|
||||
}
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
|
||||
val operatorCall = buildFunctionCall {
|
||||
@@ -1052,6 +1060,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
)
|
||||
)
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
arguments += operatorCall
|
||||
}
|
||||
|
||||
+5
@@ -193,6 +193,7 @@ fun FirExpression.generateContainsOperation(
|
||||
name = OperatorNameConventions.NOT
|
||||
}
|
||||
explicitReceiver = containsCall
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +243,7 @@ private fun FirExpression.createConventionCall(
|
||||
}
|
||||
explicitReceiver = this@createConventionCall
|
||||
argumentList = buildUnaryArgumentList(argument)
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,6 +398,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate(
|
||||
name = PROVIDE_DELEGATE
|
||||
}
|
||||
argumentList = buildBinaryArgumentList(thisRef(forDispatchReceiver = true), propertyRef())
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
delegate = delegateBuilder.build()
|
||||
if (stubMode) return
|
||||
@@ -421,6 +424,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate(
|
||||
name = GET_VALUE
|
||||
}
|
||||
argumentList = buildBinaryArgumentList(thisRef(), propertyRef())
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
target = returnTarget
|
||||
}
|
||||
@@ -473,6 +477,7 @@ fun FirPropertyBuilder.generateAccessorsByDelegate(
|
||||
}
|
||||
}
|
||||
}
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
)
|
||||
if (annotations != null) {
|
||||
|
||||
@@ -276,6 +276,8 @@ internal object CheckCallModifiers : CheckerStage() {
|
||||
sink.reportDiagnostic(InfixCallOfNonInfixFunction(functionSymbol))
|
||||
callInfo.callSite.origin == FirFunctionCallOrigin.OPERATOR && !functionSymbol.fir.isOperator ->
|
||||
sink.reportDiagnostic(OperatorCallOfNonOperatorFunction(functionSymbol))
|
||||
callInfo.isImplicitInvoke && !functionSymbol.fir.isOperator ->
|
||||
sink.reportDiagnostic(OperatorCallOfNonOperatorFunction(functionSymbol))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -51,6 +51,7 @@ private class ConeConditionalEffectToFirVisitor(
|
||||
return buildFunctionCall {
|
||||
calleeReference = buildSimpleNamedReference { name = OperatorNameConventions.NOT }
|
||||
this.explicitReceiver = explicitReceiver
|
||||
origin = FirFunctionCallOrigin.OPERATOR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ internal class FirImplicitInvokeCallImpl(
|
||||
override var calleeReference: FirNamedReference,
|
||||
) : FirImplicitInvokeCall() {
|
||||
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
|
||||
override val origin: FirFunctionCallOrigin = FirFunctionCallOrigin.REGULAR
|
||||
override val origin: FirFunctionCallOrigin = FirFunctionCallOrigin.OPERATOR
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
typeRef.accept(visitor, data)
|
||||
|
||||
+2
-6
@@ -153,16 +153,12 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
kind = OpenClass
|
||||
}
|
||||
|
||||
fun ImplementationContext.defaultFunctionOrigin() {
|
||||
default("origin", "FirFunctionCallOrigin.REGULAR")
|
||||
}
|
||||
|
||||
impl(implicitInvokeCall) {
|
||||
defaultFunctionOrigin()
|
||||
default("origin", "FirFunctionCallOrigin.OPERATOR")
|
||||
}
|
||||
|
||||
impl(componentCall) {
|
||||
defaultFunctionOrigin()
|
||||
default("origin", "FirFunctionCallOrigin.REGULAR")
|
||||
}
|
||||
|
||||
impl(qualifiedAccessExpression)
|
||||
|
||||
+10
-10
@@ -53,10 +53,10 @@ fun test() {
|
||||
|
||||
a <!OPERATOR_MODIFIER_REQUIRED!>+<!> b
|
||||
a - b
|
||||
a[1]
|
||||
<!OPERATOR_MODIFIER_REQUIRED!>a[1]<!>
|
||||
a["str"]
|
||||
|
||||
a[1] = "A"
|
||||
<!OPERATOR_MODIFIER_REQUIRED!>a[1]<!> = "A"
|
||||
a["str"] = "str"
|
||||
|
||||
a.plus(b)
|
||||
@@ -73,25 +73,25 @@ fun test() {
|
||||
Example()<!OPERATOR_MODIFIER_REQUIRED!>..<!>Example()
|
||||
Example2()..Example2()
|
||||
|
||||
a < b
|
||||
a >= b
|
||||
a <!OPERATOR_MODIFIER_REQUIRED!><<!> b
|
||||
a <!OPERATOR_MODIFIER_REQUIRED!>>=<!> b
|
||||
c > d
|
||||
|
||||
a in b
|
||||
a <!OPERATOR_MODIFIER_REQUIRED!>in<!> b
|
||||
c in d
|
||||
|
||||
a++
|
||||
a--
|
||||
a<!OPERATOR_MODIFIER_REQUIRED!>++<!>
|
||||
a<!OPERATOR_MODIFIER_REQUIRED!>--<!>
|
||||
c++
|
||||
c--
|
||||
|
||||
!a
|
||||
<!OPERATOR_MODIFIER_REQUIRED!>!<!>a
|
||||
!c
|
||||
|
||||
a()
|
||||
<!OPERATOR_MODIFIER_REQUIRED!>a<!>()
|
||||
c()
|
||||
|
||||
Example()()
|
||||
<!OPERATOR_MODIFIER_REQUIRED!>Example()()<!>
|
||||
Example2()()
|
||||
}
|
||||
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
import kotlin.reflect.KProperty0
|
||||
|
||||
val a: Int by A()
|
||||
|
||||
class A {
|
||||
fun getValue(t: Any?, p: KProperty0<*>): Int = 1
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import kotlin.reflect.KProperty0
|
||||
|
||||
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE!>A()<!>
|
||||
|
||||
+1
-1
@@ -13,6 +13,6 @@ fun String.provideDelegate(a: Any?, p: KProperty<*>) = StringDelegate(this)
|
||||
operator fun String.getValue(a: Any?, p: KProperty<*>) = this
|
||||
|
||||
val test1: String by "OK"
|
||||
val test2: Int by "OK"
|
||||
val test2: Int by <!DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH!>"OK"<!>
|
||||
val test3 by "OK"
|
||||
|
||||
|
||||
Vendored
+2
-1
@@ -99,7 +99,8 @@ public class A extends AImpl implements List<String> {
|
||||
|
||||
fun main() {
|
||||
val x = X()
|
||||
x[0]
|
||||
//todo get only one candidate - AImpl.get, no kotlin.collection.List for some reason
|
||||
<!OPERATOR_MODIFIER_REQUIRED!>x[0]<!>
|
||||
x.size
|
||||
x.remove("")
|
||||
x.remove(1)
|
||||
|
||||
@@ -28,18 +28,18 @@ fun test() {
|
||||
var a = Example()
|
||||
val b = Example()
|
||||
|
||||
consumeString(<!ARGUMENT_TYPE_MISMATCH!>a()<!>)
|
||||
consumeString(<!ARGUMENT_TYPE_MISMATCH!>a[1]<!>)
|
||||
consumeString(a())
|
||||
consumeString(a[1])
|
||||
|
||||
val (x, y) = Example()
|
||||
consumeString(<!ARGUMENT_TYPE_MISMATCH!>x<!>)
|
||||
consumeString(<!ARGUMENT_TYPE_MISMATCH!>y<!>)
|
||||
|
||||
consumeExample2(<!ARGUMENT_TYPE_MISMATCH!>++a<!>)
|
||||
consumeExample2(++a)
|
||||
|
||||
consumeString(a plus b)
|
||||
}
|
||||
|
||||
fun consumeInt(i: Int) {}
|
||||
fun consumeString(s: String) {}
|
||||
fun consumeExample2(e: Example2) {}
|
||||
fun consumeExample2(e: Example2) {}
|
||||
|
||||
@@ -7,7 +7,9 @@ class A {
|
||||
|
||||
fun main() {
|
||||
val a = A()
|
||||
a[1]++
|
||||
a[1] += 3
|
||||
a[1] = a[1] + 3
|
||||
<!OPERATOR_MODIFIER_REQUIRED!>a[1]<!>++
|
||||
//fir prefers plusAssign call if neither get+set nor plusAssign resolverd
|
||||
//hence UNRESOLVED_REFERENCE here
|
||||
a[1] <!UNRESOLVED_REFERENCE!>+=<!> 3
|
||||
<!OPERATOR_MODIFIER_REQUIRED!>a[1]<!> = a[1] + 3
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: a.kt
|
||||
|
||||
package foo
|
||||
|
||||
operator fun Int.invoke() = null
|
||||
fun Int.foo() = null
|
||||
|
||||
// FILE: b.kt
|
||||
|
||||
package bar
|
||||
|
||||
import foo.foo as invoke
|
||||
import foo.invoke
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>42<!>()
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: a.kt
|
||||
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ fun Int.invoke(i: Int, a: Any) {}
|
||||
fun Int.invoke(a: Any, i: Int) {}
|
||||
|
||||
fun foo(i: Int) {
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>i<!>(1, 1)
|
||||
<!NONE_APPLICABLE!>i<!>(1, 1)
|
||||
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>5<!>(1, 2)
|
||||
<!NONE_APPLICABLE!>5<!>(1, 2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user