@@ -654,9 +654,13 @@ open class KotlinFileExtractor(
654
654
}
655
655
}
656
656
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)
659
662
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 > {
660
664
with (" function" , f) {
661
665
DeclarationStackAdjuster (f).use {
662
666
@@ -3997,7 +4001,15 @@ open class KotlinFileExtractor(
3997
4001
3998
4002
fun trySub (t : IrType , context : TypeContext ) = if (typeSub == null ) t else typeSub(t, context, pluginContext)
3999
4003
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))
4001
4013
4002
4014
// body
4003
4015
val blockId = tw.getFreshIdLabel<DbBlock >()
0 commit comments