@@ -653,9 +653,13 @@ open class KotlinFileExtractor(
653
653
}
654
654
}
655
655
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)
658
661
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 > {
659
663
with (" function" , f) {
660
664
DeclarationStackAdjuster (f).use {
661
665
@@ -4034,7 +4038,15 @@ open class KotlinFileExtractor(
4034
4038
4035
4039
fun trySub (t : IrType , context : TypeContext ) = if (typeSub == null ) t else typeSub(t, context, pluginContext)
4036
4040
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))
4038
4050
4039
4051
// body
4040
4052
val blockId = tw.getFreshIdLabel<DbBlock >()
0 commit comments