diff --git a/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt b/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt index 222d63bf0c2..ae10f57c2ec 100644 --- a/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt +++ b/java/kotlin-extractor2/src/main/kotlin/KotlinFileExtractor.kt @@ -1802,13 +1802,12 @@ OLD: KE1 typeSubstitution: TypeSubstitution?, classTypeArgsIncludingOuterClasses: List? */ - ) = - null // TODO + ): Label { /* OLD: KE1 if (isFake(f)) { - if (needsInterfaceForwarder(f)) - makeInterfaceForwarder( + if (needsInterfaceForwarder(f)) { + return makeInterfaceForwarder( f, parentId, extractBody, @@ -1816,27 +1815,32 @@ OLD: KE1 typeSubstitution, classTypeArgsIncludingOuterClasses ) - else null + } else { + return null + } } else { -*/ -/* -OLD: KE1 // Work around an apparent bug causing redeclarations of `fun toString(): String` // specifically in interfaces loaded from Java classes show up like fake overrides. val overriddenVisibility = if (f.isFakeOverride && isJavaBinaryObjectMethodRedeclaration(f)) OverriddenFunctionAttributes(visibility = DescriptorVisibilities.PUBLIC) else null - forceExtractFunction( +*/ + return forceExtractFunction( f, parentId, +/* +OLD: KE1 extractBody, extractMethodAndParameterTypeAccesses, extractAnnotations, typeSubstitution, classTypeArgsIncludingOuterClasses, overriddenAttributes = overriddenVisibility +*/ ) +/* +OLD: KE1 .also { // The defaults-forwarder function is a static utility, not a member, so we only // need to extract this for the unspecialised instance of this class. @@ -1857,8 +1861,8 @@ OLD: KE1 classTypeArgsIncludingOuterClasses ) } - } */ + } /* OLD: KE1 @@ -2413,10 +2417,13 @@ OLD: KE1 } } } +*/ private fun forceExtractFunction( - f: IrFunction, + f: KtFunction, parentId: Label, +/* +OLD: KE1 extractBody: Boolean, extractMethodAndParameterTypeAccesses: Boolean, extractAnnotations: Boolean, @@ -2424,8 +2431,11 @@ OLD: KE1 classTypeArgsIncludingOuterClasses: List?, extractOrigin: Boolean = true, overriddenAttributes: OverriddenFunctionAttributes? = null +*/ ): Label { with("function", f) { +/* +OLD: KE1 DeclarationStackAdjuster(f, overriddenAttributes).use { val javaCallable = getJavaCallable(f) getFunctionTypeParameters(f).mapIndexed { idx, tp -> @@ -2437,19 +2447,28 @@ OLD: KE1 ?.getOrNull(idx) ) } +*/ val id = +/* +OLD: KE1 overriddenAttributes?.id ?: // If this is a class that would ordinarily be replaced by a Java // equivalent (e.g. kotlin.Map -> java.util.Map), // don't replace here, really extract the Kotlin version: +*/ useFunction( f, parentId, +/* +OLD: KE1 classTypeArgsIncludingOuterClasses, noReplace = true +*/ ) +/* +OLD: KE1 val sourceDeclaration = overriddenAttributes?.sourceDeclarationId ?: if (typeSubstitution != null && overriddenAttributes?.id == null) { @@ -2612,12 +2631,18 @@ OLD: KE1 extractMethodAndParameterTypeAccesses ) } +*/ return id +/* +OLD: KE1 } +*/ } } +/* +OLD: KE1 private fun isStaticFunction(f: IrFunction): Boolean { return f.dispatchReceiverParameter == null // Has no dispatch receiver, && diff --git a/java/kotlin-extractor2/src/main/kotlin/KotlinUsesExtractor.kt b/java/kotlin-extractor2/src/main/kotlin/KotlinUsesExtractor.kt index 7670965a208..ed145357f93 100644 --- a/java/kotlin-extractor2/src/main/kotlin/KotlinUsesExtractor.kt +++ b/java/kotlin-extractor2/src/main/kotlin/KotlinUsesExtractor.kt @@ -1379,16 +1379,25 @@ OLD: KE1 * that omit one or more parameters that has a default value specified. */ @OptIn(ObsoleteDescriptorBasedAPI::class) +*/ fun getFunctionLabel( - f: IrFunction, + f: KtFunction, parentId: Label, +/* +OLD: KE1 classTypeArgsIncludingOuterClasses: List?, maybeParameterList: List? = null +*/ ): String = getFunctionLabel( +/* +OLD: KE1 f.parent, +*/ parentId, - getFunctionShortName(f).nameInDB, + f.getNameAsName()!!.asString(), // TODO: Remove the !! // OLD KE1: getFunctionShortName(f).nameInDB, +/* +OLD: KE1 (maybeParameterList ?: f.valueParameters).map { it.type }, getAdjustedReturnType(f), f.extensionReceiverParameter?.type, @@ -1397,8 +1406,11 @@ OLD: KE1 overridesCollectionsMethodWithAlteredParameterTypes(f), getJavaCallable(f), !getInnermostWildcardSupppressionAnnotation(f) +*/ ) +/* +OLD: KE1 /* * This function actually generates the label for a function. * Sometimes, a function is only generated by kotlinc when writing a @@ -1406,13 +1418,19 @@ OLD: KE1 * This function therefore takes all the constituent parts of a * function instead. */ +*/ fun getFunctionLabel( +/* +OLD: KE1 // The parent of the function; normally f.parent. parent: IrDeclarationParent, - // The ID of the function's parent, or null if we should work it out ourselves. +*/ + // OLD: KE1: The ID of the function's parent, or null if we should work it out ourselves. parentId: Label, - // The name of the function; normally f.name.asString(). + // OLD: KE1: The name of the function; normally f.name.asString(). name: String, +/* +OLD: KE1 // The types of the value parameters that the functions takes; normally // f.valueParameters.map { it.type }. parameterTypes: List, @@ -1440,7 +1458,10 @@ OLD: KE1 // The prefix used in the label. "callable", unless a property label is created, then it's // "property". prefix: String = "callable" +*/ ): String { +/* +OLD: KE1 val allParamTypes = if (extensionParamType == null) parameterTypes else listOf(extensionParamType) + parameterTypes @@ -1521,9 +1542,16 @@ OLD: KE1 ) "<${functionTypeParameters.size}>" else "" +*/ + val prefix = "x" // TODO + val paramTypeIds = "x" // TODO + val returnTypeId = "x" // TODO + val typeArgSuffix = "x" // TODO return "@\"$prefix;{$parentId}.$name($paramTypeIds){$returnTypeId}$typeArgSuffix\"" } +/* +OLD: KE1 val javaLangClass by lazy { referenceExternalClass("java.lang.Class") } fun kClassToJavaClass(t: IrType): IrType { @@ -1763,39 +1791,57 @@ OLD: KE1 } return useFunction(f, javaFun, parentId, classTypeArgsIncludingOuterClasses) } +*/ fun useFunction( - f: IrFunction, + f: KtFunction, parentId: Label, +/* +OLD: KE1 classTypeArgsIncludingOuterClasses: List?, noReplace: Boolean = false +*/ ): Label { +/* +OLD: KE1 if (f.isLocalFunction()) { val ids = getLocallyVisibleFunctionLabels(f) return ids.function.cast() } - val javaFun = kotlinFunctionToJavaEquivalent(f, noReplace) - return useFunction(f, javaFun, parentId, classTypeArgsIncludingOuterClasses) +*/ + val javaFun = f // TODO: kotlinFunctionToJavaEquivalent(f, noReplace) + return useFunction(f, javaFun, parentId /* TODO , classTypeArgsIncludingOuterClasses */) } private fun useFunction( - f: IrFunction, - javaFun: IrFunction, + f: KtFunction, + javaFun: KtFunction, parentId: Label, +/* +OLD: KE1 classTypeArgsIncludingOuterClasses: List? +*/ ): Label { - val label = getFunctionLabel(javaFun, parentId, classTypeArgsIncludingOuterClasses) + val label = getFunctionLabel(javaFun, parentId /* TODO , classTypeArgsIncludingOuterClasses */) val id: Label = tw.getLabelFor(label) { +/* +OLD: KE1 extractPrivateSpecialisedDeclaration(f, classTypeArgsIncludingOuterClasses) +*/ } +/* +OLD: KE1 if (isExternalDeclaration(javaFun)) { extractFunctionLaterIfExternalFileMember(javaFun) extractExternalEnclosingClassLater(javaFun) } +*/ return id } +/* +OLD: KE1 private fun extractPrivateSpecialisedDeclaration( d: IrDeclaration, classTypeArgsIncludingOuterClasses: List?