@@ -653,9 +653,13 @@ open class KotlinFileExtractor(
653653 }
654654 }
655655
656- fun extractFunction (f : IrFunction , parentId : Label <out DbReftype >, extractBody : Boolean , extractMethodAndParameterTypeAccesses : Boolean , typeSubstitution : TypeSubstitution ? , classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? , idOverride : Label <DbMethod >? = null, locOverride : Label <DbLocation >? = null): Label <out DbCallable >? {
657- if (isFake(f)) return null
656+ fun extractFunction (f : IrFunction , parentId : Label <out DbReftype >, extractBody : Boolean , extractMethodAndParameterTypeAccesses : Boolean , typeSubstitution : TypeSubstitution ? , classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? , idOverride : Label <DbMethod >? = null, locOverride : Label <DbLocation >? = null) =
657+ if (isFake(f))
658+ null
659+ else
660+ forceExtractFunction(f, parentId, extractBody, extractMethodAndParameterTypeAccesses, typeSubstitution, classTypeArgsIncludingOuterClasses, idOverride, locOverride)
658661
662+ fun forceExtractFunction (f : IrFunction , parentId : Label <out DbReftype >, extractBody : Boolean , extractMethodAndParameterTypeAccesses : Boolean , typeSubstitution : TypeSubstitution ? , classTypeArgsIncludingOuterClasses : List <IrTypeArgument >? , idOverride : Label <DbMethod >? = null, locOverride : Label <DbLocation >? = null): Label <out DbCallable > {
659663 with (" function" , f) {
660664 DeclarationStackAdjuster (f).use {
661665
@@ -4034,7 +4038,15 @@ open class KotlinFileExtractor(
40344038
40354039 fun trySub (t : IrType , context : TypeContext ) = if (typeSub == null ) t else typeSub(t, context, pluginContext)
40364040
4037- extractFunction(samMember, classId, extractBody = false , extractMethodAndParameterTypeAccesses = true , typeSub, classTypeArgs, idOverride = ids.function, locOverride = tw.getLocation(e))
4041+ // Force extraction of this function even if this is a fake override --
4042+ // This happens in the case where a functional interface inherits its only abstract member,
4043+ // which usually we wouldn't extract, but in this case we're effectively using it as a template
4044+ // for the real function we're extracting that will implement this interface, and it serves fine
4045+ // for that purpose. By contrast if we looked through the fake to the underlying abstract method
4046+ // we would need to compose generic type substitutions -- for example, if we're implementing
4047+ // T UnaryOperator<T>.apply(T t) here, we would need to compose substitutions so we can implement
4048+ // the real underlying R Function<T, R>.apply(T t).
4049+ forceExtractFunction(samMember, classId, extractBody = false , extractMethodAndParameterTypeAccesses = true , typeSub, classTypeArgs, idOverride = ids.function, locOverride = tw.getLocation(e))
40384050
40394051 // body
40404052 val blockId = tw.getFreshIdLabel<DbBlock >()
0 commit comments