[FIR] Add mapping of primitive types to JVM signatures

This commit is contained in:
Dmitriy Novozhilov
2020-02-17 10:52:53 +03:00
parent 031952268a
commit d10e56c358
5 changed files with 39 additions and 1 deletions
@@ -71,7 +71,28 @@ private fun StringBuilder.appendErasedType(typeRef: FirTypeRef) {
}
}
private val PRIMITIVE_TYPE_SIGNATURE: Map<String, String> = mapOf(
"Boolean" to "Z",
"Byte" to "B",
"Char" to "C",
"Short" to "S",
"Int" to "I",
"Long" to "L",
"Float" to "F",
"Double" to "D",
)
private fun StringBuilder.appendConeType(coneType: ConeKotlinType) {
(coneType as? ConeClassLikeType)?.let {
val classId = it.lookupTag.classId
if (classId.packageFqName.toString() == "kotlin") {
PRIMITIVE_TYPE_SIGNATURE[classId.shortClassName.identifier]?.let {
append(it)
return
}
}
}
fun appendClassLikeType(type: ConeClassLikeType) {
append("L")
val classId = type.lookupTag.classId
@@ -0,0 +1,5 @@
// FULL_JDK
fun test(collection: MutableCollection<Boolean>) {
collection.removeIf { it }
}
@@ -0,0 +1,7 @@
FILE: removeIf.kt
public final fun test(collection: R|kotlin/collections/MutableCollection<kotlin/Boolean>|): R|kotlin/Unit| {
R|<local>/collection|.R|FakeOverride<java/util/Collection.removeIf: R|kotlin/Boolean|>|(<L> = removeIf@fun <anonymous>(it: R|ft<kotlin/Boolean, kotlin/Boolean?>!|): R|kotlin/Boolean| {
^ R|<local>/it|
}
)
}
@@ -198,6 +198,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
runTest("compiler/fir/resolve/testData/resolveWithStdlib/reflectionClass.kt");
}
@TestMetadata("removeIf.kt")
public void testRemoveIf() throws Exception {
runTest("compiler/fir/resolve/testData/resolveWithStdlib/removeIf.kt");
}
@TestMetadata("removeOnAbstractMap.kt")
public void testRemoveOnAbstractMap() throws Exception {
runTest("compiler/fir/resolve/testData/resolveWithStdlib/removeOnAbstractMap.kt");
@@ -7,6 +7,6 @@ interface A : MutableCollection<String> {
}
fun foo(x: MutableList<String>, y: A) {
x.<!UNRESOLVED_REFERENCE!>removeIf<!> { <!UNRESOLVED_REFERENCE!>it<!>.<!UNRESOLVED_REFERENCE!>length<!> > 0 }
x.removeIf { it.length > 0 }
y.removeIf { it.length > 0 }
}