Skip to content

Kotlin: Remove cast from extractRawMethodAccess #10273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions java/kotlin-extractor/src/main/kotlin/KotlinFileExtractor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1427,12 +1427,14 @@ open class KotlinFileExtractor(
// type arguments at index -2, -3, ...
extractTypeArguments(typeArguments, locId, id, enclosingCallable, enclosingStmt, -2, true)

val isFunctionInvoke = drType != null
&& drType is IrSimpleType
&& drType.isFunctionOrKFunction()
&& callTarget.name.asString() == OperatorNameConventions.INVOKE.asString()
val isBigArityFunctionInvoke = isFunctionInvoke
&& (drType as IrSimpleType).arguments.size > BuiltInFunctionArity.BIG_ARITY
val (isFunctionInvoke, isBigArityFunctionInvoke) =
if (drType is IrSimpleType &&
drType.isFunctionOrKFunction() &&
callTarget.name.asString() == OperatorNameConventions.INVOKE.asString()) {
Pair(true, drType.arguments.size > BuiltInFunctionArity.BIG_ARITY)
} else {
Pair(false, false)
}

if (callTarget.isLocalFunction()) {
val ids = getLocallyVisibleFunctionLabels(callTarget)
Expand All @@ -1443,7 +1445,7 @@ open class KotlinFileExtractor(
extractNewExprForLocalFunction(ids, id, locId, enclosingCallable, enclosingStmt)
} else {
val methodId =
if (drType != null && extractClassTypeArguments && drType is IrSimpleType && !isUnspecialised(drType)) {
if (extractClassTypeArguments && drType is IrSimpleType && !isUnspecialised(drType)) {

val extractionMethod = if (isFunctionInvoke) {
// For `kotlin.FunctionX` and `kotlin.reflect.KFunctionX` interfaces, we're making sure that we
Expand Down