@@ -120,11 +120,7 @@ open class KotlinFileExtractor(
120
120
}
121
121
122
122
private fun shouldExtractDecl (declaration : IrDeclaration , extractPrivateMembers : Boolean ) =
123
- extractPrivateMembers ||
124
- when (declaration) {
125
- is IrDeclarationWithVisibility -> declaration.visibility.let { it != DescriptorVisibilities .PRIVATE && it != DescriptorVisibilities .PRIVATE_TO_THIS }
126
- else -> true
127
- }
123
+ extractPrivateMembers || ! isPrivate(declaration)
128
124
129
125
fun extractDeclaration (declaration : IrDeclaration , extractPrivateMembers : Boolean , extractFunctionBodies : Boolean ) {
130
126
with (" declaration" , declaration) {
@@ -357,23 +353,37 @@ open class KotlinFileExtractor(
357
353
}
358
354
}
359
355
356
+ private fun makeTypeParamSubstitution (c : IrClass , argsIncludingOuterClasses : List <IrTypeArgument >? ) =
357
+ when (argsIncludingOuterClasses) {
358
+ null -> { x: IrType , _: TypeContext , _: IrPluginContext -> x.toRawType() }
359
+ else -> makeGenericSubstitutionFunction(c, argsIncludingOuterClasses)
360
+ }
361
+
362
+ fun extractDeclarationPrototype (d : IrDeclaration , parentId : Label <out DbReftype >, argsIncludingOuterClasses : List <IrTypeArgument >? , typeParamSubstitutionQ : TypeSubstitution ? = null) {
363
+ val typeParamSubstitution = typeParamSubstitutionQ ? :
364
+ when (val parent = d.parent) {
365
+ is IrClass -> makeTypeParamSubstitution(parent, argsIncludingOuterClasses)
366
+ else -> {
367
+ logger.warnElement(" Unable to extract prototype of local declaration" , d)
368
+ return
369
+ }
370
+ }
371
+ when (d) {
372
+ is IrFunction -> extractFunction(d, parentId, extractBody = false , extractMethodAndParameterTypeAccesses = false , typeParamSubstitution, argsIncludingOuterClasses)
373
+ is IrProperty -> extractProperty(d, parentId, extractBackingField = false , extractFunctionBodies = false , extractPrivateMembers = false , typeParamSubstitution, argsIncludingOuterClasses)
374
+ else -> {}
375
+ }
376
+ }
377
+
360
378
// `argsIncludingOuterClasses` can be null to describe a raw generic type.
361
379
// For non-generic types it will be zero-length list.
362
380
private fun extractNonPrivateMemberPrototypes (c : IrClass , argsIncludingOuterClasses : List <IrTypeArgument >? , id : Label <out DbClassorinterface >) {
363
381
with (" member prototypes" , c) {
364
- val typeParamSubstitution =
365
- when (argsIncludingOuterClasses) {
366
- null -> { x: IrType , _: TypeContext , _: IrPluginContext -> x.toRawType() }
367
- else -> makeGenericSubstitutionFunction(c, argsIncludingOuterClasses)
368
- }
382
+ val typeParamSubstitution = makeTypeParamSubstitution(c, argsIncludingOuterClasses)
369
383
370
384
c.declarations.map {
371
385
if (shouldExtractDecl(it, false )) {
372
- when (it) {
373
- is IrFunction -> extractFunction(it, id, extractBody = false , extractMethodAndParameterTypeAccesses = false , typeParamSubstitution, argsIncludingOuterClasses)
374
- is IrProperty -> extractProperty(it, id, extractBackingField = false , extractFunctionBodies = false , extractPrivateMembers = false , typeParamSubstitution, argsIncludingOuterClasses)
375
- else -> {}
376
- }
386
+ extractDeclarationPrototype(it, id, argsIncludingOuterClasses, typeParamSubstitution)
377
387
}
378
388
}
379
389
}
0 commit comments