[Commonizer] Refactor CIR type representation

1. Drop CirClassifierId
2. Specialized classes for each kind of types (classes, TAs, type parameters, flexible types).
3. TypeCommonizer now returns commonized type. In case of TAs this could be a completely new type
   describing expect class or a new TA with the different underlying type.
This commit is contained in:
Dmitriy Dolovov
2020-10-19 20:33:23 +03:00
parent 2764550bbe
commit f5bb60f7cd
40 changed files with 818 additions and 340 deletions
@@ -1,5 +1,12 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
// fake class with the default constructor and no member scope
public abstract class CStructVar()
// fake classes with the default constructor and no member scope
abstract class CStructVar
class CPointer<T>
@Suppress("FINAL_UPPER_BOUND") class UByteVarOf<T : UByte>
class UByte
// fake typealiases
typealias CArrayPointer<T> = CPointer<T>
typealias UByteVar = UByteVarOf<UByte>
@@ -42,3 +42,9 @@ typealias Y = V // TA at the RHS with the different nullability of own RHS
// Supertypes:
expect class FILE : kotlinx.cinterop.CStructVar
typealias uuid_t = kotlinx.cinterop.CPointer<kotlinx.cinterop.UByteVarOf<kotlinx.cinterop.UByte>>
// ^^^ TODO: ideally, it should be CArrayPointer<UByteVar>
typealias __darwin_uuid_t = kotlinx.cinterop.CArrayPointer<kotlinx.cinterop.UByteVar>
expect val uuid: uuid_t
@@ -1,5 +1,12 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
// fake class with the default constructor and no member scope
public abstract class CStructVar()
// fake classes with the default constructor and no member scope
abstract class CStructVar
class CPointer<T>
@Suppress("FINAL_UPPER_BOUND") class UByteVarOf<T : UByte>
class UByte
// fake typealiases
typealias CArrayPointer<T> = CPointer<T>
typealias UByteVar = UByteVarOf<UByte>
@@ -20,3 +20,5 @@ typealias X = U? // different nullability of the RHS TA
// Supertypes:
actual typealias FILE = _IO_FILE
final class _IO_FILE : kotlinx.cinterop.CStructVar {}
actual val uuid: uuid_t get() = TODO()
@@ -1,5 +1,12 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
// fake class with the default constructor and no member scope
public abstract class CStructVar()
// fake classes with the default constructor and no member scope
abstract class CStructVar
class CPointer<T>
@Suppress("FINAL_UPPER_BOUND") class UByteVarOf<T : UByte>
class UByte
// fake typealiases
typealias CArrayPointer<T> = CPointer<T>
typealias UByteVar = UByteVarOf<UByte>
@@ -21,6 +21,8 @@ typealias X = U // different nullability of the RHS TA
actual typealias FILE = __sFILE
final class __sFILE : kotlinx.cinterop.CStructVar {}
actual val uuid: uuid_t get() = TODO()
// Type alias chain that is present in one target only:
class AA
typealias BB = AA
@@ -1,5 +1,12 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
// fake class with the default constructor and no member scope
public abstract class CStructVar()
// fake classes with the default constructor and no member scope
abstract class CStructVar
class CPointer<T>
@Suppress("FINAL_UPPER_BOUND") class UByteVarOf<T : UByte>
class UByte
// fake typealiases
typealias CArrayPointer<T> = CPointer<T>
typealias UByteVar = UByteVarOf<UByte>
@@ -51,3 +51,8 @@ typealias Y = V // TA at the RHS with the different nullability of own RHS
// Supertypes:
typealias FILE = _IO_FILE
final class _IO_FILE : kotlinx.cinterop.CStructVar {}
typealias uuid_t = __darwin_uuid_t
typealias __darwin_uuid_t = kotlinx.cinterop.CArrayPointer<kotlinx.cinterop.UByteVar>
val uuid: uuid_t get() = TODO()
@@ -1,5 +1,12 @@
// this is to avoid missing Kotlin/Native stdlib
package kotlinx.cinterop
// fake class with the default constructor and no member scope
public abstract class CStructVar()
// fake classes with the default constructor and no member scope
abstract class CStructVar
class CPointer<T>
@Suppress("FINAL_UPPER_BOUND") class UByteVarOf<T : UByte>
class UByte
// fake typealiases
typealias CArrayPointer<T> = CPointer<T>
typealias UByteVar = UByteVarOf<UByte>
@@ -52,6 +52,11 @@ typealias Y = V // TA at the RHS with the different nullability of own RHS
typealias FILE = __sFILE
final class __sFILE : kotlinx.cinterop.CStructVar {}
typealias uuid_t = __darwin_uuid_t
typealias __darwin_uuid_t = kotlinx.cinterop.CArrayPointer<kotlinx.cinterop.UByteVar>
val uuid: uuid_t get() = TODO()
// Type alias chain that is present in one target only:
class AA
typealias BB = AA