Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b57d7f5

Browse files
committed
Kotlin: Extract fakeKotlinType for all kt_types
This allows us to make consistent Java+Kotlin databases in the short term.
1 parent 40976a9 commit b57d7f5

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

java/kotlin-extractor/src/main/kotlin/KotlinUsesExtractor.kt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ open class KotlinUsesExtractor(
169169
return res
170170
}
171171

172+
fun fakeKotlinType(): Label<out DbKt_type> {
173+
val fakeKotlinPackageId: Label<DbPackage> = tw.getLabelFor("@\"FakeKotlinPackage\"", {
174+
tw.writePackages(it, "fake.kotlin")
175+
})
176+
val fakeKotlinClassId: Label<DbClass> = tw.getLabelFor("@\"FakeKotlinClass\"", {
177+
tw.writeClasses(it, "FakeKotlinClass", fakeKotlinPackageId, it)
178+
})
179+
val fakeKotlinTypeId: Label<DbKt_nullable_type> = tw.getLabelFor("@\"FakeKotlinType\"", {
180+
tw.writeKt_nullable_types(it, fakeKotlinClassId)
181+
})
182+
return fakeKotlinTypeId
183+
}
184+
172185
fun useSimpleTypeClass(c: IrClass, args: List<IrTypeArgument>, hasQuestionMark: Boolean): TypeResults {
173186
if (c.isAnonymousObject) {
174187
if (args.isNotEmpty()) {
@@ -186,7 +199,8 @@ open class KotlinUsesExtractor(
186199
val kotlinQualClassName = getUnquotedClassLabel(c, args).classLabel
187200
// TODO: args ought to be substituted, so e.g. MutableList<MutableList<String>> gets the Java type List<List<String>>
188201
val javaResult = classInstanceResult.typeResult
189-
val kotlinResult = if (hasQuestionMark) {
202+
val kotlinResult = if (true) TypeResult(fakeKotlinType(), "TODO", "TODO") else
203+
if (hasQuestionMark) {
190204
val kotlinSignature = "$kotlinQualClassName?" // TODO: Is this right?
191205
val kotlinLabel = "@\"kt_type;nullable;$kotlinQualClassName\""
192206
val kotlinId: Label<DbKt_nullable_type> = tw.getLabelFor(kotlinLabel, {
@@ -313,7 +327,8 @@ open class KotlinUsesExtractor(
313327
addClassLabel(javaClass, listOf())
314328
}
315329
val kotlinClassId = useClassInstance(kotlinClass, listOf()).typeResult.id
316-
val kotlinResult = if (s.hasQuestionMark) {
330+
val kotlinResult = if (true) TypeResult(fakeKotlinType(), "TODO", "TODO") else
331+
if (s.hasQuestionMark) {
317332
val kotlinSignature = "$kotlinPackageName.$kotlinClassName?" // TODO: Is this right?
318333
val kotlinLabel = "@\"kt_type;nullable;$kotlinPackageName.$kotlinClassName\""
319334
val kotlinId: Label<DbKt_nullable_type> = tw.getLabelFor(kotlinLabel, {
@@ -401,7 +416,8 @@ class X {
401416
s.classifier.owner is IrTypeParameter -> {
402417
val javaResult = useTypeParameter(s.classifier.owner as IrTypeParameter)
403418
val aClassId = makeClass("kotlin", "TypeParam") // TODO: Wrong
404-
val kotlinResult = if (s.hasQuestionMark) {
419+
val kotlinResult = if (true) TypeResult(fakeKotlinType(), "TODO", "TODO") else
420+
if (s.hasQuestionMark) {
405421
val kotlinSignature = "${javaResult.signature}?" // TODO: Wrong
406422
val kotlinLabel = "@\"kt_type;nullable;type_param\"" // TODO: Wrong
407423
val kotlinId: Label<DbKt_nullable_type> = tw.getLabelFor(kotlinLabel, {

0 commit comments

Comments
 (0)