KT-7922 Added Boolean Companion Object
This commit is contained in:
@@ -48,15 +48,14 @@ fun box(): String {
|
|||||||
assertEquals(listOf("Entry"), nestedNames(MutableMap::class))
|
assertEquals(listOf("Entry"), nestedNames(MutableMap::class))
|
||||||
|
|
||||||
// Primitives
|
// Primitives
|
||||||
for (primitive in listOf(Byte::class, Double::class, Float::class, Int::class, Long::class, Short::class, Char::class)) {
|
for (primitive in listOf(Byte::class, Double::class, Float::class, Int::class, Long::class, Short::class, Char::class, Boolean::class)) {
|
||||||
assertEquals(listOf("Companion"), nestedNames(primitive))
|
assertEquals(listOf("Companion"), nestedNames(primitive))
|
||||||
}
|
}
|
||||||
assertEquals(emptyList<String>(), nestedNames(Boolean::class))
|
|
||||||
|
|
||||||
// Primitive arrays
|
// Primitive arrays
|
||||||
for (primitiveArray in listOf(
|
for (primitiveArray in listOf(
|
||||||
ByteArray::class, DoubleArray::class, FloatArray::class, IntArray::class,
|
ByteArray::class, DoubleArray::class, FloatArray::class, IntArray::class,
|
||||||
LongArray::class, ShortArray::class, CharArray::class, BooleanArray::class
|
LongArray::class, ShortArray::class, CharArray::class, BooleanArray::class
|
||||||
)) {
|
)) {
|
||||||
assertEquals(emptyList<String>(), nestedNames(primitiveArray))
|
assertEquals(emptyList<String>(), nestedNames(primitiveArray))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,5 +6,6 @@ public interface IntrinsicCompanionObject {
|
|||||||
void testInt(IntCompanionObject i);
|
void testInt(IntCompanionObject i);
|
||||||
void testChar(CharCompanionObject c);
|
void testChar(CharCompanionObject c);
|
||||||
void testString(StringCompanionObject s);
|
void testString(StringCompanionObject s);
|
||||||
|
void testBoolean(BooleanCompanionObject b);
|
||||||
void testEnum(EnumCompanionObject e);
|
void testEnum(EnumCompanionObject e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package test
|
package test
|
||||||
|
|
||||||
public interface IntrinsicCompanionObject {
|
public interface IntrinsicCompanionObject {
|
||||||
|
public abstract fun testBoolean(/*0*/ p0: kotlin.Boolean.Companion!): kotlin.Unit
|
||||||
public abstract fun testChar(/*0*/ p0: kotlin.Char.Companion!): kotlin.Unit
|
public abstract fun testChar(/*0*/ p0: kotlin.Char.Companion!): kotlin.Unit
|
||||||
public abstract fun testEnum(/*0*/ p0: kotlin.Enum.Companion!): kotlin.Unit
|
public abstract fun testEnum(/*0*/ p0: kotlin.Enum.Companion!): kotlin.Unit
|
||||||
public abstract fun testInt(/*0*/ p0: kotlin.Int.Companion!): kotlin.Unit
|
public abstract fun testInt(/*0*/ p0: kotlin.Int.Companion!): kotlin.Unit
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ package kotlin
|
|||||||
* represented as values of the primitive type `boolean`.
|
* represented as values of the primitive type `boolean`.
|
||||||
*/
|
*/
|
||||||
public class Boolean private constructor() : Comparable<Boolean> {
|
public class Boolean private constructor() : Comparable<Boolean> {
|
||||||
|
companion object {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the inverse of this boolean.
|
* Returns the inverse of this boolean.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -24,13 +24,14 @@ import java.util.*
|
|||||||
|
|
||||||
object CompanionObjectMapping {
|
object CompanionObjectMapping {
|
||||||
private val classIds =
|
private val classIds =
|
||||||
(PrimitiveType.NUMBER_TYPES.map(KotlinBuiltIns::getPrimitiveFqName) +
|
(PrimitiveType.NUMBER_TYPES.map(KotlinBuiltIns::getPrimitiveFqName) +
|
||||||
KotlinBuiltIns.FQ_NAMES.string.toSafe() +
|
KotlinBuiltIns.FQ_NAMES.string.toSafe() +
|
||||||
KotlinBuiltIns.FQ_NAMES._enum.toSafe()).mapTo(linkedSetOf<ClassId>(), ClassId::topLevel)
|
KotlinBuiltIns.FQ_NAMES._boolean.toSafe() +
|
||||||
|
KotlinBuiltIns.FQ_NAMES._enum.toSafe()).mapTo(linkedSetOf<ClassId>(), ClassId::topLevel)
|
||||||
|
|
||||||
fun allClassesWithIntrinsicCompanions(): Set<ClassId> =
|
fun allClassesWithIntrinsicCompanions(): Set<ClassId> =
|
||||||
Collections.unmodifiableSet(classIds)
|
Collections.unmodifiableSet(classIds)
|
||||||
|
|
||||||
fun isMappedIntrinsicCompanionObject(classDescriptor: ClassDescriptor): Boolean =
|
fun isMappedIntrinsicCompanionObject(classDescriptor: ClassDescriptor): Boolean =
|
||||||
DescriptorUtils.isCompanionObject(classDescriptor) && classDescriptor.classId?.outerClassId in classIds
|
DescriptorUtils.isCompanionObject(classDescriptor) && classDescriptor.classId?.outerClassId in classIds
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@ object ClassMapperLite {
|
|||||||
add("reflect/KFunction$i", "kotlin/reflect/KFunction")
|
add("reflect/KFunction$i", "kotlin/reflect/KFunction")
|
||||||
}
|
}
|
||||||
|
|
||||||
for (klass in listOf("Char", "Byte", "Short", "Int", "Float", "Long", "Double", "String", "Enum")) {
|
for (klass in listOf("Char", "Byte", "Short", "Int", "Float", "Long", "Double", "String", "Enum", "Boolean")) {
|
||||||
add("$klass.Companion", "kotlin/jvm/internal/${klass}CompanionObject")
|
add("$klass.Companion", "kotlin/jvm/internal/${klass}CompanionObject")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,3 +100,5 @@ private object CharCompanionObject {
|
|||||||
|
|
||||||
private object StringCompanionObject {}
|
private object StringCompanionObject {}
|
||||||
|
|
||||||
|
private object BooleanCompanionObject {}
|
||||||
|
|
||||||
|
|||||||
@@ -53,3 +53,4 @@ internal object CharCompanionObject {
|
|||||||
|
|
||||||
internal object StringCompanionObject {}
|
internal object StringCompanionObject {}
|
||||||
internal object EnumCompanionObject {}
|
internal object EnumCompanionObject {}
|
||||||
|
internal object BooleanCompanionObject {}
|
||||||
@@ -365,6 +365,10 @@ public final class kotlin/jvm/internal/ArrayIteratorsKt {
|
|||||||
public static final fun iterator ([Z)Lkotlin/collections/BooleanIterator;
|
public static final fun iterator ([Z)Lkotlin/collections/BooleanIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class kotlin/jvm/internal/BooleanCompanionObject {
|
||||||
|
public static final field INSTANCE Lkotlin/jvm/internal/BooleanCompanionObject;
|
||||||
|
}
|
||||||
|
|
||||||
public final class kotlin/jvm/internal/BooleanSpreadBuilder : kotlin/jvm/internal/PrimitiveSpreadBuilder {
|
public final class kotlin/jvm/internal/BooleanSpreadBuilder : kotlin/jvm/internal/PrimitiveSpreadBuilder {
|
||||||
public fun <init> (I)V
|
public fun <init> (I)V
|
||||||
public final fun add (Z)V
|
public final fun add (Z)V
|
||||||
|
|||||||
+4
@@ -3179,6 +3179,10 @@ public final class kotlin/jvm/internal/ArrayIteratorsKt {
|
|||||||
public static final fun iterator ([Z)Lkotlin/collections/BooleanIterator;
|
public static final fun iterator ([Z)Lkotlin/collections/BooleanIterator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final class kotlin/jvm/internal/BooleanCompanionObject {
|
||||||
|
public static final field INSTANCE Lkotlin/jvm/internal/BooleanCompanionObject;
|
||||||
|
}
|
||||||
|
|
||||||
public final class kotlin/jvm/internal/BooleanSpreadBuilder : kotlin/jvm/internal/PrimitiveSpreadBuilder {
|
public final class kotlin/jvm/internal/BooleanSpreadBuilder : kotlin/jvm/internal/PrimitiveSpreadBuilder {
|
||||||
public fun <init> (I)V
|
public fun <init> (I)V
|
||||||
public final fun add (Z)V
|
public final fun add (Z)V
|
||||||
|
|||||||
Reference in New Issue
Block a user