@@ -654,9 +654,13 @@ open class KotlinFileExtractor(
654654 }
655655 }
656656
657- 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 >? {
658- if (isFake(f)) return null
657+ 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) =
658+ if (isFake(f))
659+ null
660+ else
661+ extractNonFakeFunction(f, parentId, extractBody, extractMethodAndParameterTypeAccesses, typeSubstitution, classTypeArgsIncludingOuterClasses, idOverride, locOverride)
659662
663+ fun extractNonFakeFunction (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 > {
660664 with (" function" , f) {
661665 DeclarationStackAdjuster (f).use {
662666
@@ -3997,7 +4001,15 @@ open class KotlinFileExtractor(
39974001
39984002 fun trySub (t : IrType , context : TypeContext ) = if (typeSub == null ) t else typeSub(t, context, pluginContext)
39994003
4000- extractFunction(samMember, classId, extractBody = false , extractMethodAndParameterTypeAccesses = true , typeSub, classTypeArgs, idOverride = ids.function, locOverride = tw.getLocation(e))
4004+ // Force extraction of this function even if this is a fake override --
4005+ // This happens in the case where a functional interface inherits its only abstract member,
4006+ // which usually we wouldn't extract, but in this case we're effectively using it as a template
4007+ // for the real function we're extracting that will implement this interface, and it serves fine
4008+ // for that purpose. By contrast if we looked through the fake to the underlying abstract method
4009+ // we would need to compose generic type substitutions -- for example, if we're implementing
4010+ // T UnaryOperator<T>.apply(T t) here, we would need to compose substitutions so we can implement
4011+ // the real underlying R Function<T, R>.apply(T t).
4012+ extractNonFakeFunction(samMember, classId, extractBody = false , extractMethodAndParameterTypeAccesses = true , typeSub, classTypeArgs, idOverride = ids.function, locOverride = tw.getLocation(e))
40014013
40024014 // body
40034015 val blockId = tw.getFreshIdLabel<DbBlock >()
0 commit comments