[Metadata] Emit ModuleFragment for each part of package name
Some libraries (e.g. `klib contents`) expects this kind of behaviour.
This commit is contained in:
committed by
Sergey Bogolepov
parent
96e1fdd955
commit
da4b56e9d1
+15
-1
@@ -21,7 +21,21 @@ class StubIrMetadataEmitter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun emitModuleFragments(): List<KmModuleFragment> =
|
private fun emitModuleFragments(): List<KmModuleFragment> =
|
||||||
ModuleMetadataEmitter(context.configuration.pkgName, builderResult.stubs).emit().let(::listOf)
|
ModuleMetadataEmitter(
|
||||||
|
context.configuration.pkgName,
|
||||||
|
builderResult.stubs
|
||||||
|
).emit().let { kmModuleFragment ->
|
||||||
|
// We need to create module fragment for each part of package name.
|
||||||
|
val pkgName = context.configuration.pkgName
|
||||||
|
val fakePackages = pkgName.mapIndexedNotNull { idx, char ->
|
||||||
|
if (char == '.') idx else null
|
||||||
|
}.map { dotPosition ->
|
||||||
|
KmModuleFragment().also {
|
||||||
|
it.fqName = pkgName.substring(0, dotPosition)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fakePackages + kmModuleFragment
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+9
-1
@@ -88,6 +88,14 @@ class ChunkingWriteStrategy(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return classFragments + packageFragments
|
val result = classFragments + packageFragments
|
||||||
|
return if (result.isEmpty()) {
|
||||||
|
// We still need to emit empty packages because they may
|
||||||
|
// represent parts of package declaration (e.g. platform.[]).
|
||||||
|
// Tooling (e.g. `klib contents`) expects this kind of behavior.
|
||||||
|
parts
|
||||||
|
} else {
|
||||||
|
result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user