[NI] Support implicit invoke calls on parenthesized receivers
This commit is contained in:
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.referenceExpression
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.CallTransformer
|
||||
import org.jetbrains.kotlin.resolve.calls.KotlinCallResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.isBinaryRemOperator
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.createLookupLocation
|
||||
@@ -66,7 +67,8 @@ class PSICallResolver(
|
||||
|
||||
val defaultResolutionKinds = setOf(
|
||||
NewResolutionOldInference.ResolutionKind.Function,
|
||||
NewResolutionOldInference.ResolutionKind.Variable
|
||||
NewResolutionOldInference.ResolutionKind.Variable,
|
||||
NewResolutionOldInference.ResolutionKind.Invoke
|
||||
)
|
||||
|
||||
fun <D : CallableDescriptor> runResolutionAndInference(
|
||||
@@ -78,23 +80,23 @@ class PSICallResolver(
|
||||
val isBinaryRemOperator = isBinaryRemOperator(context.call)
|
||||
val refinedName = refineNameForRemOperator(isBinaryRemOperator, name)
|
||||
|
||||
val kotlinCall = toKotlinCall(context, resolutionKind.toKotlinCallKind(), context.call, refinedName, tracingStrategy)
|
||||
val kotlinCallKind = resolutionKind.toKotlinCallKind()
|
||||
val kotlinCall = toKotlinCall(context, kotlinCallKind, context.call, refinedName, tracingStrategy)
|
||||
val scopeTower = ASTScopeTower(context)
|
||||
val resolutionCallbacks = createResolutionCallbacks(context)
|
||||
|
||||
val factoryProviderForInvoke = FactoryProviderForInvoke(context, scopeTower, kotlinCall)
|
||||
|
||||
val expectedType = calculateExpectedType(context)
|
||||
var result = kotlinCallResolver.resolveCall(
|
||||
scopeTower, resolutionCallbacks, kotlinCall, expectedType, factoryProviderForInvoke, context.collectAllCandidates
|
||||
)
|
||||
var result =
|
||||
kotlinCallResolver.resolveCall(scopeTower, resolutionCallbacks, kotlinCall, expectedType, context.collectAllCandidates) {
|
||||
FactoryProviderForInvoke(context, scopeTower, kotlinCall)
|
||||
}
|
||||
|
||||
val shouldUseOperatorRem = languageVersionSettings.supportsFeature(LanguageFeature.OperatorRem)
|
||||
if (isBinaryRemOperator && shouldUseOperatorRem && (result.isEmpty() || result.areAllInapplicable())) {
|
||||
result = resolveToDeprecatedMod(name, context, resolutionKind, tracingStrategy, scopeTower, resolutionCallbacks, expectedType)
|
||||
result = resolveToDeprecatedMod(name, context, kotlinCallKind, tracingStrategy, scopeTower, resolutionCallbacks, expectedType)
|
||||
}
|
||||
|
||||
if (result.isEmpty() && reportAdditionalDiagnosticIfNoCandidates(context, scopeTower, resolutionKind, kotlinCall)) {
|
||||
if (result.isEmpty() && reportAdditionalDiagnosticIfNoCandidates(context, scopeTower, kotlinCallKind, kotlinCall)) {
|
||||
return OverloadResolutionResultsImpl.nameNotFound()
|
||||
}
|
||||
|
||||
@@ -126,25 +128,24 @@ class PSICallResolver(
|
||||
scopeTower, resolutionCallbacks, kotlinCall, calculateExpectedType(context), givenCandidates, context.collectAllCandidates
|
||||
)
|
||||
return convertToOverloadResolutionResults(context, result, tracingStrategy)
|
||||
|
||||
}
|
||||
|
||||
private fun resolveToDeprecatedMod(
|
||||
remOperatorName: Name,
|
||||
context: BasicCallResolutionContext,
|
||||
resolutionKind: NewResolutionOldInference.ResolutionKind,
|
||||
kotlinCallKind: KotlinCallKind,
|
||||
tracingStrategy: TracingStrategy,
|
||||
scopeTower: ImplicitScopeTower,
|
||||
resolutionCallbacks: KotlinResolutionCallbacksImpl,
|
||||
expectedType: UnwrappedType?
|
||||
): CallResolutionResult {
|
||||
val deprecatedName = OperatorConventions.REM_TO_MOD_OPERATION_NAMES[remOperatorName]!!
|
||||
val callWithDeprecatedName = toKotlinCall(context, resolutionKind.toKotlinCallKind(), context.call, deprecatedName, tracingStrategy)
|
||||
val refinedProviderForInvokeFactory = FactoryProviderForInvoke(context, scopeTower, callWithDeprecatedName)
|
||||
val callWithDeprecatedName = toKotlinCall(context, kotlinCallKind, context.call, deprecatedName, tracingStrategy)
|
||||
return kotlinCallResolver.resolveCall(
|
||||
scopeTower, resolutionCallbacks, callWithDeprecatedName, expectedType,
|
||||
refinedProviderForInvokeFactory, context.collectAllCandidates
|
||||
)
|
||||
scopeTower, resolutionCallbacks, callWithDeprecatedName, expectedType, context.collectAllCandidates
|
||||
) {
|
||||
FactoryProviderForInvoke(context, scopeTower, callWithDeprecatedName)
|
||||
}
|
||||
}
|
||||
|
||||
private fun refineNameForRemOperator(isBinaryRemOperator: Boolean, name: Name): Name {
|
||||
@@ -303,7 +304,7 @@ class PSICallResolver(
|
||||
private fun reportAdditionalDiagnosticIfNoCandidates(
|
||||
context: BasicCallResolutionContext,
|
||||
scopeTower: ImplicitScopeTower,
|
||||
kind: NewResolutionOldInference.ResolutionKind,
|
||||
kind: KotlinCallKind,
|
||||
kotlinCall: KotlinCall
|
||||
): Boolean {
|
||||
val reference = context.call.calleeExpression as? KtReferenceExpression ?: return false
|
||||
@@ -451,15 +452,14 @@ class PSICallResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private fun NewResolutionOldInference.ResolutionKind.toKotlinCallKind(): KotlinCallKind {
|
||||
return when (this) {
|
||||
private fun NewResolutionOldInference.ResolutionKind.toKotlinCallKind(): KotlinCallKind =
|
||||
when (this) {
|
||||
is NewResolutionOldInference.ResolutionKind.Function -> KotlinCallKind.FUNCTION
|
||||
is NewResolutionOldInference.ResolutionKind.Variable -> KotlinCallKind.VARIABLE
|
||||
is NewResolutionOldInference.ResolutionKind.Invoke -> KotlinCallKind.UNSUPPORTED
|
||||
is NewResolutionOldInference.ResolutionKind.Invoke -> KotlinCallKind.INVOKE
|
||||
is NewResolutionOldInference.ResolutionKind.CallableReference -> KotlinCallKind.UNSUPPORTED
|
||||
is NewResolutionOldInference.ResolutionKind.GivenCandidates -> KotlinCallKind.UNSUPPORTED
|
||||
}
|
||||
}
|
||||
|
||||
private fun toKotlinCall(
|
||||
context: BasicCallResolutionContext,
|
||||
@@ -469,8 +469,11 @@ class PSICallResolver(
|
||||
tracingStrategy: TracingStrategy,
|
||||
forcedExplicitReceiver: Receiver? = null
|
||||
): PSIKotlinCallImpl {
|
||||
val resolvedExplicitReceiver =
|
||||
resolveExplicitReceiver(context, forcedExplicitReceiver ?: oldCall.explicitReceiver, oldCall.isSafeCall())
|
||||
val resolvedExplicitReceiver = resolveReceiver(
|
||||
context, forcedExplicitReceiver ?: oldCall.explicitReceiver, oldCall.isSafeCall(), isVariableReceiverForInvoke = false
|
||||
)
|
||||
val dispatchReceiverForInvoke = resolveDispatchReceiverForInvoke(context, kotlinCallKind, oldCall)
|
||||
|
||||
val resolvedTypeArguments = resolveTypeArguments(context, oldCall.typeArguments)
|
||||
|
||||
val argumentsInParenthesis = if (oldCall.callType != Call.CallType.ARRAY_SET_METHOD && oldCall.functionLiteralArguments.isEmpty()) {
|
||||
@@ -510,15 +513,30 @@ class PSICallResolver(
|
||||
astExternalArgument?.setResultDataFlowInfoIfRelevant(resultDataFlowInfo)
|
||||
|
||||
return PSIKotlinCallImpl(
|
||||
kotlinCallKind, oldCall, tracingStrategy, resolvedExplicitReceiver, name, resolvedTypeArguments,
|
||||
resolvedArgumentsInParenthesis, astExternalArgument, context.dataFlowInfo, resultDataFlowInfo, context.dataFlowInfoForArguments
|
||||
kotlinCallKind, oldCall, tracingStrategy, resolvedExplicitReceiver, dispatchReceiverForInvoke, name,
|
||||
resolvedTypeArguments, resolvedArgumentsInParenthesis, astExternalArgument, context.dataFlowInfo, resultDataFlowInfo,
|
||||
context.dataFlowInfoForArguments
|
||||
)
|
||||
}
|
||||
|
||||
private fun resolveExplicitReceiver(
|
||||
private fun resolveDispatchReceiverForInvoke(
|
||||
context: BasicCallResolutionContext,
|
||||
kotlinCallKind: KotlinCallKind,
|
||||
oldCall: Call
|
||||
): ReceiverKotlinCallArgument? {
|
||||
if (kotlinCallKind != KotlinCallKind.INVOKE) return null
|
||||
|
||||
require(oldCall is CallTransformer.CallForImplicitInvoke) { "Call should be CallForImplicitInvoke, but it is: $oldCall" }
|
||||
|
||||
val dispatchReceiver = oldCall.dispatchReceiver!! // dispatch receiver from CallForImplicitInvoke is always not null
|
||||
return resolveReceiver(context, dispatchReceiver, isSafeCall = false, isVariableReceiverForInvoke = true)
|
||||
}
|
||||
|
||||
private fun resolveReceiver(
|
||||
context: BasicCallResolutionContext,
|
||||
oldReceiver: Receiver?,
|
||||
isSafeCall: Boolean
|
||||
isSafeCall: Boolean,
|
||||
isVariableReceiverForInvoke: Boolean
|
||||
): ReceiverKotlinCallArgument? =
|
||||
when (oldReceiver) {
|
||||
null -> null
|
||||
@@ -546,7 +564,7 @@ class PSICallResolver(
|
||||
}
|
||||
}
|
||||
|
||||
subCallArgument ?: ReceiverExpressionKotlinCallArgument(detailedReceiver, isSafeCall)
|
||||
subCallArgument ?: ReceiverExpressionKotlinCallArgument(detailedReceiver, isSafeCall, isVariableReceiverForInvoke)
|
||||
}
|
||||
else -> error("Incorrect receiver: $oldReceiver")
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class PSIKotlinCallImpl(
|
||||
override val psiCall: Call,
|
||||
override val tracingStrategy: TracingStrategy,
|
||||
override val explicitReceiver: ReceiverKotlinCallArgument?,
|
||||
override val dispatchReceiverForInvokeExtension: ReceiverKotlinCallArgument?,
|
||||
override val name: Name,
|
||||
override val typeArguments: List<TypeArgument>,
|
||||
override val argumentsInParenthesis: List<KotlinCallArgument>,
|
||||
|
||||
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.resolve.calls.components.NewOverloadingConflictResol
|
||||
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode
|
||||
import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import java.lang.UnsupportedOperationException
|
||||
|
||||
@@ -39,8 +40,8 @@ class KotlinCallResolver(
|
||||
resolutionCallbacks: KotlinResolutionCallbacks,
|
||||
kotlinCall: KotlinCall,
|
||||
expectedType: UnwrappedType?,
|
||||
factoryProviderForInvoke: CandidateFactoryProviderForInvoke<KotlinResolutionCandidate>,
|
||||
collectAllCandidates: Boolean
|
||||
collectAllCandidates: Boolean,
|
||||
createFactoryProviderForInvoke: () -> CandidateFactoryProviderForInvoke<KotlinResolutionCandidate>
|
||||
): CallResolutionResult {
|
||||
kotlinCall.checkCallInvariants()
|
||||
|
||||
@@ -54,10 +55,20 @@ class KotlinCallResolver(
|
||||
scopeTower,
|
||||
kotlinCall.name,
|
||||
candidateFactory,
|
||||
factoryProviderForInvoke,
|
||||
createFactoryProviderForInvoke(),
|
||||
kotlinCall.explicitReceiver?.receiver
|
||||
)
|
||||
}
|
||||
KotlinCallKind.INVOKE -> {
|
||||
createProcessorWithReceiverValueOrEmpty(kotlinCall.explicitReceiver?.receiver) {
|
||||
createCallTowerProcessorForExplicitInvoke(
|
||||
scopeTower,
|
||||
candidateFactory,
|
||||
kotlinCall.dispatchReceiverForInvokeExtension?.receiver as ReceiverValueWithSmartCastInfo,
|
||||
it
|
||||
)
|
||||
}
|
||||
}
|
||||
KotlinCallKind.UNSUPPORTED -> throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -205,7 +205,11 @@ internal object CheckExplicitReceiverKindConsistency : ResolutionPart() {
|
||||
override fun KotlinResolutionCandidate.process(workIndex: Int) {
|
||||
when (resolvedCall.explicitReceiverKind) {
|
||||
NO_EXPLICIT_RECEIVER -> if (kotlinCall.explicitReceiver is SimpleKotlinCallArgument || kotlinCall.dispatchReceiverForInvokeExtension != null) hasError()
|
||||
DISPATCH_RECEIVER, EXTENSION_RECEIVER -> if (kotlinCall.explicitReceiver == null || kotlinCall.dispatchReceiverForInvokeExtension != null) hasError()
|
||||
DISPATCH_RECEIVER, EXTENSION_RECEIVER ->
|
||||
if (kotlinCall.callKind == KotlinCallKind.INVOKE && kotlinCall.dispatchReceiverForInvokeExtension == null ||
|
||||
kotlinCall.callKind != KotlinCallKind.INVOKE &&
|
||||
(kotlinCall.explicitReceiver == null || kotlinCall.dispatchReceiverForInvokeExtension != null)
|
||||
) hasError()
|
||||
BOTH_RECEIVERS -> if (kotlinCall.explicitReceiver == null || kotlinCall.dispatchReceiverForInvokeExtension == null) hasError()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.model
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.prepareReceiverRegardingCaptureTypes
|
||||
|
||||
|
||||
|
||||
@@ -43,27 +43,32 @@ fun KotlinCall.checkCallInvariants() {
|
||||
explicitReceiver.safeAs<SimpleKotlinCallArgument>()?.checkReceiverInvariants()
|
||||
dispatchReceiverForInvokeExtension.safeAs<SimpleKotlinCallArgument>()?.checkReceiverInvariants()
|
||||
|
||||
if (callKind != KotlinCallKind.FUNCTION) {
|
||||
assert(externalArgument == null) {
|
||||
"External argument is not allowed not for function call: $externalArgument."
|
||||
}
|
||||
assert(argumentsInParenthesis.isEmpty()) {
|
||||
"Arguments in parenthesis should be empty for not function call: $this "
|
||||
}
|
||||
assert(dispatchReceiverForInvokeExtension == null) {
|
||||
"Dispatch receiver for invoke should be null for not function call: $dispatchReceiverForInvokeExtension"
|
||||
}
|
||||
} else {
|
||||
assert(externalArgument == null || !externalArgument!!.isSpread) {
|
||||
"External argument cannot nave spread element: $externalArgument"
|
||||
when (callKind) {
|
||||
KotlinCallKind.FUNCTION, KotlinCallKind.INVOKE -> {
|
||||
assert(externalArgument == null || !externalArgument!!.isSpread) {
|
||||
"External argument cannot nave spread element: $externalArgument"
|
||||
}
|
||||
assert(externalArgument?.argumentName == null) {
|
||||
"Illegal external argument with name: $externalArgument"
|
||||
}
|
||||
assert(dispatchReceiverForInvokeExtension == null || !dispatchReceiverForInvokeExtension!!.isSafeCall) {
|
||||
"Dispatch receiver for invoke cannot be safe: $dispatchReceiverForInvokeExtension"
|
||||
}
|
||||
}
|
||||
|
||||
assert(externalArgument?.argumentName == null) {
|
||||
"Illegal external argument with name: $externalArgument"
|
||||
KotlinCallKind.VARIABLE -> {
|
||||
assert(externalArgument == null) {
|
||||
"External argument is not allowed not for function call: $externalArgument."
|
||||
}
|
||||
assert(argumentsInParenthesis.isEmpty()) {
|
||||
"Arguments in parenthesis should be empty for not function call: $this "
|
||||
}
|
||||
assert(dispatchReceiverForInvokeExtension == null) {
|
||||
"Dispatch receiver for invoke should be null for not function call: $dispatchReceiverForInvokeExtension"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
assert(dispatchReceiverForInvokeExtension == null || !dispatchReceiverForInvokeExtension!!.isSafeCall) {
|
||||
"Dispatch receiver for invoke cannot be safe: $dispatchReceiverForInvokeExtension"
|
||||
}
|
||||
KotlinCallKind.UNSUPPORTED -> error("Call with UNSUPPORTED kind")
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -207,6 +207,7 @@ enum class KotlinCallKind(vararg resolutionPart: ResolutionPart) {
|
||||
CheckArguments,
|
||||
CheckExternalArgument
|
||||
),
|
||||
INVOKE(*FUNCTION.resolutionSequence.toTypedArray()),
|
||||
UNSUPPORTED();
|
||||
|
||||
val resolutionSequence = resolutionPart.asList()
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// WITH_RUNTIME
|
||||
|
||||
object A {
|
||||
var result = "not ok"
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
run {
|
||||
(A) {
|
||||
A.result = "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object B
|
||||
|
||||
operator fun A.invoke(x: () -> Unit) {
|
||||
x()
|
||||
}
|
||||
|
||||
operator fun <K, V> Pair<K, V>.invoke(f: (x: K, y: V) -> Boolean): Boolean = f(this.first, this.second)
|
||||
inline fun <reified T> Any.isType(): Boolean = this is T
|
||||
|
||||
fun test2(): Boolean {
|
||||
return (A to B) { k, v -> k.isType<A>() && v.isType<B>() }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
test1()
|
||||
if (A.result != "OK") return "fail1: ${A.result}"
|
||||
|
||||
if (!test2()) return "fail2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
@@ -37,8 +37,8 @@ fun main(args : Array<String>) {
|
||||
foo2()({})
|
||||
foo2()<!TOO_MANY_ARGUMENTS!>{}<!>
|
||||
(foo2()){}
|
||||
(foo2()){<!EXPECTED_PARAMETERS_NUMBER_MISMATCH, CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> }
|
||||
foo2()({<!EXPECTED_PARAMETERS_NUMBER_MISMATCH, CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> })
|
||||
(foo2())<!NI;TYPE_MISMATCH!>{<!OI;CANNOT_INFER_PARAMETER_TYPE, OI;EXPECTED_PARAMETERS_NUMBER_MISMATCH, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> }<!>
|
||||
foo2()(<!NI;TYPE_MISMATCH!>{<!OI;CANNOT_INFER_PARAMETER_TYPE, OI;EXPECTED_PARAMETERS_NUMBER_MISMATCH, UNUSED_ANONYMOUS_PARAMETER!>x<!> -> }<!>)
|
||||
|
||||
val a = fooT1(1)()
|
||||
checkSubtype<Int>(a)
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ fun test4() {
|
||||
// should be an error on receiver, shouldn't be thrown away
|
||||
|
||||
fun test5() {
|
||||
<!TYPE_MISMATCH!>1<!>.(fun String.()=1)()
|
||||
<!OI;TYPE_MISMATCH!>1<!>.<!NI;FUNCTION_EXPECTED!>(fun String.()=1)<!>()
|
||||
}
|
||||
|
||||
fun <R: Any> R?.sure() : R = this!!
|
||||
|
||||
+1
-1
@@ -33,4 +33,4 @@ fun bar() {
|
||||
Inner()
|
||||
Inner(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -10,5 +10,5 @@ fun foo(s: String, ai: A<Int>) {
|
||||
|
||||
<!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>s<!>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>ai<!>)
|
||||
|
||||
<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>""<!>(ai)
|
||||
<!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>""<!>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>ai<!>)
|
||||
}
|
||||
|
||||
Vendored
+7
-5
@@ -1,15 +1,17 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
fun test1() {
|
||||
<!TYPE_MISMATCH!>1<!>. (fun String.(i: Int) = i )(1)
|
||||
<!TYPE_MISMATCH!>1<!>.(label@ fun String.(i: Int) = i )(1)
|
||||
<!OI;TYPE_MISMATCH!>1<!>. <!NI;FUNCTION_EXPECTED!>(fun String.(i: Int) = i )<!>(1)
|
||||
<!OI;TYPE_MISMATCH!>1<!>.<!NI;FUNCTION_EXPECTED!>(label@ fun String.(i: Int) = i )<!>(1)
|
||||
}
|
||||
|
||||
fun test2(f: String.(Int) -> Unit) {
|
||||
<!TYPE_MISMATCH!>11<!>.(f)(1)
|
||||
<!TYPE_MISMATCH!>11<!>.(f)(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
<!OI;TYPE_MISMATCH!>11<!>.<!NI;FUNCTION_EXPECTED!>(f)<!>(1)
|
||||
<!OI;TYPE_MISMATCH!>11<!>.<!NI;FUNCTION_EXPECTED!>(f)<!>(<!OI;NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
fun foo(): String.(Int) -> Unit = {}
|
||||
|
||||
<!TYPE_MISMATCH!>1<!>.(foo())(1)
|
||||
<!OI;TYPE_MISMATCH!>1<!>.<!NI;FUNCTION_EXPECTED!>(foo())<!>(1)
|
||||
}
|
||||
@@ -9,11 +9,11 @@ fun test(a: A) {
|
||||
}
|
||||
"".<!UNSAFE_IMPLICIT_INVOKE_CALL!>(a.x)<!>()
|
||||
a<!NI;UNSAFE_CALL!>.<!><!OI;UNSAFE_IMPLICIT_INVOKE_CALL!>x<!>("")
|
||||
<!UNSAFE_IMPLICIT_INVOKE_CALL!>(a.x)<!>("")
|
||||
<!NI;UNSAFE_CALL, OI;UNSAFE_IMPLICIT_INVOKE_CALL!>(a.x)<!>("")
|
||||
|
||||
with("") {
|
||||
a<!NI;UNSAFE_CALL!>.<!><!OI;UNSAFE_IMPLICIT_INVOKE_CALL!>x<!>(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
<!UNSAFE_IMPLICIT_INVOKE_CALL!>(a.x)<!>()
|
||||
<!NI;UNSAFE_CALL, OI;UNSAFE_IMPLICIT_INVOKE_CALL!>(a.x)<!>()
|
||||
if (a.x != null) {
|
||||
a<!NI;UNSAFE_CALL!>.<!><!OI;UNSAFE_IMPLICIT_INVOKE_CALL!>x<!>(<!NO_VALUE_FOR_PARAMETER!>)<!> // todo
|
||||
<!DEBUG_INFO_SMARTCAST!>(a.x)<!>()
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class A {
|
||||
operator fun invoke() {}
|
||||
operator fun invoke(f: () -> Unit) {}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
fun bar() {
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>()
|
||||
(<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>)()
|
||||
<!SUPER_IS_NOT_AN_EXPRESSION!>super<!> {}
|
||||
(<!SUPER_IS_NOT_AN_EXPRESSION!>super<!>) {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final operator fun invoke(): kotlin.Unit
|
||||
public final operator fun invoke(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class B : A {
|
||||
public constructor B()
|
||||
public final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun invoke(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ fun invoke(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
Generated
+6
@@ -3274,6 +3274,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/closures"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousObjectAsLastExpressionInLambda.kt")
|
||||
public void testAnonymousObjectAsLastExpressionInLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/anonymousObjectAsLastExpressionInLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("captureExtensionReceiver.kt")
|
||||
public void testCaptureExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/captureExtensionReceiver.kt");
|
||||
|
||||
@@ -20989,6 +20989,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/thisAndSuper/genericQualifiedSuperOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("implicitInvokeOnSuper.kt")
|
||||
public void testImplicitInvokeOnSuper() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/implicitInvokeOnSuper.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("notAccessibleSuperInTrait.kt")
|
||||
public void testNotAccessibleSuperInTrait() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/thisAndSuper/notAccessibleSuperInTrait.kt");
|
||||
|
||||
Generated
+6
@@ -20989,6 +20989,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/thisAndSuper/genericQualifiedSuperOverridden.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("implicitInvokeOnSuper.kt")
|
||||
public void testImplicitInvokeOnSuper() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/thisAndSuper/implicitInvokeOnSuper.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("notAccessibleSuperInTrait.kt")
|
||||
public void testNotAccessibleSuperInTrait() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/thisAndSuper/notAccessibleSuperInTrait.kt");
|
||||
|
||||
+6
@@ -3274,6 +3274,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/closures"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousObjectAsLastExpressionInLambda.kt")
|
||||
public void testAnonymousObjectAsLastExpressionInLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/anonymousObjectAsLastExpressionInLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("captureExtensionReceiver.kt")
|
||||
public void testCaptureExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/captureExtensionReceiver.kt");
|
||||
|
||||
+6
@@ -3274,6 +3274,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/closures"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousObjectAsLastExpressionInLambda.kt")
|
||||
public void testAnonymousObjectAsLastExpressionInLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/anonymousObjectAsLastExpressionInLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("captureExtensionReceiver.kt")
|
||||
public void testCaptureExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/captureExtensionReceiver.kt");
|
||||
|
||||
+6
@@ -3189,6 +3189,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/closures"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("anonymousObjectAsLastExpressionInLambda.kt")
|
||||
public void testAnonymousObjectAsLastExpressionInLambda() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/closures/anonymousObjectAsLastExpressionInLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("captureExtensionReceiver.kt")
|
||||
public void testCaptureExtensionReceiver() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/closures/captureExtensionReceiver.kt");
|
||||
|
||||
Reference in New Issue
Block a user