[FIR generator] Factor out TypeArgument to common module
This is a step towards commonizing the code generator between FIR and IR: KT-61970
This commit is contained in:
committed by
Space Team
parent
46cbec7260
commit
977e316489
+3
-1
@@ -5,4 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.generators.tree
|
||||
|
||||
data class ArbitraryImportable(override val packageName: String, override val type: String) : Importable
|
||||
data class ArbitraryImportable(override val packageName: String, override val type: String) : Importable {
|
||||
override fun getTypeWithArguments(notNull: Boolean): String = type
|
||||
}
|
||||
+5
-1
@@ -9,4 +9,8 @@ interface Importable {
|
||||
val type: String
|
||||
val packageName: String?
|
||||
val fullQualifiedName: String? get() = packageName?.let { "$it.${type.replace(Regex("<.+>"), "")}" }
|
||||
}
|
||||
|
||||
fun getTypeWithArguments(notNull: Boolean = false): String
|
||||
}
|
||||
|
||||
val Importable.typeWithArguments: String get() = getTypeWithArguments()
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.generators.tree
|
||||
|
||||
sealed class TypeArgument(val name: String) {
|
||||
abstract val upperBounds: List<Importable>
|
||||
}
|
||||
|
||||
class SimpleTypeArgument(name: String, val upperBound: Importable?) : TypeArgument(name) {
|
||||
override val upperBounds: List<Importable> = listOfNotNull(upperBound)
|
||||
|
||||
override fun toString(): String {
|
||||
var result = name
|
||||
if (upperBound != null) {
|
||||
result += " : ${upperBound.typeWithArguments}"
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
class TypeArgumentWithMultipleUpperBounds(name: String, override val upperBounds: List<Importable>) : TypeArgument(name) {
|
||||
override fun toString(): String {
|
||||
return name
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user