[LL API] Ignore local functions in 'CodeFragmentDeclarationCollector'
In the old JVM backend, local functions were compiled as JVM classes, so there were an instance to pass around. Today, they are compiled to static functions in the containing class/facade, and calls to them compile natively.
This commit is contained in:
-6
@@ -85,12 +85,6 @@ public sealed class CodeFragmentCapturedValue(
|
||||
get() = "this@$name"
|
||||
}
|
||||
|
||||
/** Represents a captured named local function. */
|
||||
public class LocalFunction(
|
||||
name: Name,
|
||||
isCrossingInlineBounds: Boolean,
|
||||
) : CodeFragmentCapturedValue(name.asString(), isMutated = false, isCrossingInlineBounds)
|
||||
|
||||
/** Represents an externally provided value. */
|
||||
public class ForeignValue(
|
||||
name: Name,
|
||||
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
LocalFunction[name: call; isMutated: false; displayText: call]
|
||||
fun call(a: R|kotlin/Int|, b: R|kotlin/String|): R|kotlin/Unit|
|
||||
R|(kotlin/Int, kotlin/String) -> kotlin/Unit|
|
||||
Local[name: x; isMutated: false; displayText: x]
|
||||
lval x: R|kotlin/Int|
|
||||
R|kotlin/Int|
|
||||
|
||||
+6
-5
@@ -22,10 +22,11 @@ MODULE_FRAGMENT name:<Sources of main>
|
||||
CONSTRUCTOR visibility:public <> () returnType:<root>.CodeFragment [primary]
|
||||
BLOCK_BODY
|
||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
|
||||
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.Function2<kotlin.Int, kotlin.String, kotlin.Unit>, p1:kotlin.Int, p2:kotlin.String) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:p0 index:0 type:kotlin.Function2<kotlin.Int, kotlin.String, kotlin.Unit>
|
||||
VALUE_PARAMETER name:p1 index:1 type:kotlin.Int
|
||||
VALUE_PARAMETER name:p2 index:2 type:kotlin.String
|
||||
FUN name:run visibility:public modality:FINAL <> (p0:kotlin.Int, p1:kotlin.String) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:p0 index:0 type:kotlin.Int
|
||||
VALUE_PARAMETER name:p1 index:1 type:kotlin.String
|
||||
EXPRESSION_BODY
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
GET_VAR 'p0: kotlin.Function2<kotlin.Int, kotlin.String, kotlin.Unit> declared in <root>.CodeFragment.run' type=kotlin.Function2<kotlin.Int, kotlin.String, kotlin.Unit> origin=null
|
||||
CALL 'local final fun call (a: kotlin.Int, b: kotlin.String): kotlin.Unit declared in <root>.test' type=kotlin.Unit origin=null
|
||||
a: GET_VAR 'p0: kotlin.Int declared in <root>.CodeFragment.run' type=kotlin.Int origin=null
|
||||
b: GET_VAR 'p1: kotlin.String declared in <root>.CodeFragment.run' type=kotlin.String origin=null
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
public final class CodeFragment {
|
||||
// source: 'fragment.kt'
|
||||
public method <init>(): void
|
||||
public final static method run(p0: kotlin.jvm.functions.Function2, p1: int, p2: java.lang.String): void
|
||||
public final static method run(p0: int, p1: java.lang.String): void
|
||||
}
|
||||
|
||||
public final class LocalFunctionKt
|
||||
-8
@@ -27,14 +27,12 @@ import org.jetbrains.kotlin.fir.labelName
|
||||
import org.jetbrains.kotlin.fir.references.FirSuperReference
|
||||
import org.jetbrains.kotlin.fir.references.FirThisReference
|
||||
import org.jetbrains.kotlin.fir.references.toResolvedCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.constructFunctionType
|
||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.specialFunctionTypeKind
|
||||
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitorVoid
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.psi
|
||||
@@ -195,12 +193,6 @@ private class CodeFragmentCapturedValueVisitor(
|
||||
}
|
||||
is FirNamedFunctionSymbol -> {
|
||||
if (symbol.isLocal) {
|
||||
val isCrossingInlineBounds = isCrossingInlineBounds(element, symbol)
|
||||
val capturedValue = CodeFragmentCapturedValue.LocalFunction(symbol.name, isCrossingInlineBounds)
|
||||
val firFunction = symbol.fir
|
||||
val functionType = firFunction.constructFunctionType(firFunction.specialFunctionTypeKind(session))
|
||||
val typeRef = buildResolvedTypeRef { type = functionType }
|
||||
register(symbol, CodeFragmentCapturedSymbol(capturedValue, symbol, typeRef))
|
||||
registerFile(symbol)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user