@@ -1903,11 +1903,7 @@ open class KotlinFileExtractor(
19031903 tw.writeCallableBinding(id, methodLabel)
19041904 }
19051905
1906- private val defaultConstructorMarkerClass by lazy {
1907- val result = pluginContext.referenceClass(FqName (" kotlin.jvm.internal.DefaultConstructorMarker" ))?.owner
1908- result?.let { extractExternalClassLater(it) }
1909- result
1910- }
1906+ private val defaultConstructorMarkerClass by lazy { referenceExternalClass(" kotlin.jvm.internal.DefaultConstructorMarker" ) }
19111907
19121908 private val defaultConstructorMarkerType by lazy {
19131909 defaultConstructorMarkerClass?.typeWith()
@@ -2269,11 +2265,7 @@ open class KotlinFileExtractor(
22692265
22702266 private fun findFunction (cls : IrClass , name : String ): IrFunction ? = cls.declarations.findSubType<IrFunction > { it.name.asString() == name }
22712267
2272- val jvmIntrinsicsClass by lazy {
2273- val result = pluginContext.referenceClass(FqName (" kotlin.jvm.internal.Intrinsics" ))?.owner
2274- result?.let { extractExternalClassLater(it) }
2275- result
2276- }
2268+ val jvmIntrinsicsClass by lazy { referenceExternalClass(" kotlin.jvm.internal.Intrinsics" ) }
22772269
22782270 private fun findJdkIntrinsicOrWarn (name : String , warnAgainstElement : IrElement ): IrFunction ? {
22792271 val result = jvmIntrinsicsClass?.let { findFunction(it, name) }
@@ -2319,11 +2311,7 @@ open class KotlinFileExtractor(
23192311 return prop
23202312 }
23212313
2322- val javaLangString by lazy {
2323- val result = pluginContext.referenceClass(FqName (" java.lang.String" ))?.owner
2324- result?.let { extractExternalClassLater(it) }
2325- result
2326- }
2314+ val javaLangString by lazy { referenceExternalClass(" java.lang.String" ) }
23272315
23282316 val stringValueOfObjectMethod by lazy {
23292317 val result = javaLangString?.declarations?.findSubType<IrFunction > {
@@ -2347,11 +2335,7 @@ open class KotlinFileExtractor(
23472335 result
23482336 }
23492337
2350- val kotlinNoWhenBranchMatchedExn by lazy {
2351- val result = pluginContext.referenceClass(FqName (" kotlin.NoWhenBranchMatchedException" ))?.owner
2352- result?.let { extractExternalClassLater(it) }
2353- result
2354- }
2338+ val kotlinNoWhenBranchMatchedExn by lazy {referenceExternalClass(" kotlin.NoWhenBranchMatchedException" ) }
23552339
23562340 val kotlinNoWhenBranchMatchedConstructor by lazy {
23572341 val result = kotlinNoWhenBranchMatchedExn?.declarations?.findSubType<IrConstructor > {
@@ -2363,11 +2347,7 @@ open class KotlinFileExtractor(
23632347 result
23642348 }
23652349
2366- val javaUtilArrays by lazy {
2367- val result = pluginContext.referenceClass(FqName (" java.util.Arrays" ))?.owner
2368- result?.let { extractExternalClassLater(it) }
2369- result
2370- }
2350+ val javaUtilArrays by lazy { referenceExternalClass(" java.util.Arrays" ) }
23712351
23722352 private fun isFunction (target : IrFunction , pkgName : String , classNameLogged : String , classNamePredicate : (String ) -> Boolean , vararg fNames : String , isNullable : Boolean? = false) =
23732353 fNames.any { isFunction(target, pkgName, classNameLogged, classNamePredicate, it, isNullable) }
@@ -4633,6 +4613,8 @@ open class KotlinFileExtractor(
46334613 }
46344614 }
46354615
4616+ private val propertyRefType by lazy { referenceExternalClass(" kotlin.jvm.internal.PropertyReference" )?.typeWith() }
4617+
46364618 private fun extractPropertyReference (
46374619 exprKind : String ,
46384620 propertyReferenceExpr : IrCallableReference <out IrSymbol >,
@@ -4696,8 +4678,7 @@ open class KotlinFileExtractor(
46964678
46974679 val declarationParent = peekDeclStackAsDeclarationParent(propertyReferenceExpr) ? : return
46984680 // The base class could be `Any`. `PropertyReference` is used to keep symmetry with function references.
4699- val baseClass = pluginContext.referenceClass(FqName (" kotlin.jvm.internal.PropertyReference" ))?.owner?.typeWith()
4700- ? : pluginContext.irBuiltIns.anyType
4681+ val baseClass = propertyRefType ? : pluginContext.irBuiltIns.anyType
47014682
47024683 val classId = extractGeneratedClass(ids, listOf (baseClass, kPropertyType), locId, propertyReferenceExpr, declarationParent)
47034684
@@ -4791,6 +4772,8 @@ open class KotlinFileExtractor(
47914772 }
47924773 }
47934774
4775+ private val functionRefType by lazy { referenceExternalClass(" kotlin.jvm.internal.FunctionReference" )?.typeWith() }
4776+
47944777 private fun extractFunctionReference (
47954778 functionReferenceExpr : IrFunctionReference ,
47964779 parent : StmtExprParent ,
@@ -4905,8 +4888,7 @@ open class KotlinFileExtractor(
49054888 } else {
49064889 val declarationParent = peekDeclStackAsDeclarationParent(functionReferenceExpr) ? : return
49074890 // `FunctionReference` base class is required, because that's implementing `KFunction`.
4908- val baseClass = pluginContext.referenceClass(FqName (" kotlin.jvm.internal.FunctionReference" ))?.owner?.typeWith()
4909- ? : pluginContext.irBuiltIns.anyType
4891+ val baseClass = functionRefType ? : pluginContext.irBuiltIns.anyType
49104892
49114893 val classId = extractGeneratedClass(ids, listOf (baseClass, fnInterfaceType), locId, functionReferenceExpr, declarationParent, null , { it.valueParameters.size == 1 }) {
49124894 // The argument to FunctionReference's constructor is the function arity.
@@ -4952,34 +4934,14 @@ open class KotlinFileExtractor(
49524934 }
49534935 }
49544936
4955- private fun getFunctionalInterfaceType (functionNTypeArguments : List <IrType >): IrSimpleType ? {
4956- if (functionNTypeArguments.size > BuiltInFunctionArity .BIG_ARITY ) {
4957- val funName = " kotlin.jvm.functions.FunctionN"
4958- val theFun = pluginContext.referenceClass(FqName (funName))
4959- if (theFun == null ) {
4960- logger.warn(" Cannot find $funName for getFunctionalInterfaceType" )
4961- return null
4962- } else {
4963- return theFun.typeWith(functionNTypeArguments.last())
4964- }
4965- } else {
4966- return functionN(pluginContext)(functionNTypeArguments.size - 1 ).typeWith(functionNTypeArguments)
4967- }
4968- }
4937+ private fun getFunctionalInterfaceType (functionNTypeArguments : List <IrType >) =
4938+ getFunctionalInterfaceTypeWithTypeArgs(functionNTypeArguments.map { makeTypeProjection(it, Variance .INVARIANT ) })
49694939
4970- private fun getFunctionalInterfaceTypeWithTypeArgs (functionNTypeArguments : List <IrTypeArgument >): IrSimpleType ? =
4971- if (functionNTypeArguments.size > BuiltInFunctionArity .BIG_ARITY ) {
4972- val funName = " kotlin.jvm.functions.FunctionN"
4973- val theFun = pluginContext.referenceClass(FqName (funName))
4974- if (theFun == null ) {
4975- logger.warn(" Cannot find $funName for getFunctionalInterfaceTypeWithTypeArgs" )
4976- null
4977- } else {
4978- theFun.typeWithArguments(listOf (functionNTypeArguments.last()))
4979- }
4980- } else {
4940+ private fun getFunctionalInterfaceTypeWithTypeArgs (functionNTypeArguments : List <IrTypeArgument >) =
4941+ if (functionNTypeArguments.size > BuiltInFunctionArity .BIG_ARITY )
4942+ referenceExternalClass(" kotlin.jvm.functions.FunctionN" )?.symbol?.typeWithArguments(listOf (functionNTypeArguments.last()))
4943+ else
49814944 functionN(pluginContext)(functionNTypeArguments.size - 1 ).symbol.typeWithArguments(functionNTypeArguments)
4982- }
49834945
49844946 private data class FunctionLabels (
49854947 val methodId : Label <DbMethod >,
0 commit comments