[FIR generator] Use TypeRef for denoting types
(instead of `Type` and `Importable`) 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
918cf183c1
commit
8798fdeb82
+4
-3
@@ -8,7 +8,8 @@ package org.jetbrains.kotlin.generators.tree
|
||||
/**
|
||||
* A common interface representing a FIR or IR tree element.
|
||||
*/
|
||||
interface AbstractElement<Element : AbstractElement<Element, Field>, Field : AbstractField> : FieldContainer, ImplementationKindOwner {
|
||||
interface AbstractElement<Element : AbstractElement<Element, Field>, Field : AbstractField> : FieldContainer, ImplementationKindOwner,
|
||||
TypeRef /* TODO: Replace with ElementOrRef */ {
|
||||
|
||||
val name: String
|
||||
|
||||
@@ -18,9 +19,9 @@ interface AbstractElement<Element : AbstractElement<Element, Field>, Field : Abs
|
||||
|
||||
val typeArguments: List<TypeArgument>
|
||||
|
||||
val parentsArguments: Map<Element, Map<Importable, Importable>>
|
||||
val parentsArguments: Map<Element, Map<TypeRef, TypeRef>>
|
||||
|
||||
val overridenFields: Map<Field, Map<Importable, Boolean>>
|
||||
val overridenFields: Map<Field, Map<Field, Boolean>>
|
||||
|
||||
val isSealed: Boolean
|
||||
get() = false
|
||||
|
||||
+4
-1
@@ -9,7 +9,10 @@ abstract class AbstractField : Importable {
|
||||
|
||||
abstract val name: String
|
||||
|
||||
open val arguments = mutableListOf<Importable>()
|
||||
val typeRef: TypeRef
|
||||
get() = type(packageName!!, type).withArgs(*arguments.toTypedArray()).copy(nullable = nullable)
|
||||
|
||||
open val arguments = mutableListOf<TypeRef>()
|
||||
|
||||
abstract val nullable: Boolean
|
||||
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* 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
|
||||
|
||||
object StandardTypes {
|
||||
val map = type<Map<*, *>>()
|
||||
}
|
||||
+4
-4
@@ -6,11 +6,11 @@
|
||||
package org.jetbrains.kotlin.generators.tree
|
||||
|
||||
sealed class TypeArgument(val name: String) {
|
||||
abstract val upperBounds: List<Importable>
|
||||
abstract val upperBounds: List<TypeRef>
|
||||
}
|
||||
|
||||
class SimpleTypeArgument(name: String, val upperBound: Importable?) : TypeArgument(name) {
|
||||
override val upperBounds: List<Importable> = listOfNotNull(upperBound)
|
||||
class SimpleTypeArgument(name: String, val upperBound: TypeRef?) : TypeArgument(name) {
|
||||
override val upperBounds: List<TypeRef> = listOfNotNull(upperBound)
|
||||
|
||||
override fun toString(): String {
|
||||
var result = name
|
||||
@@ -21,7 +21,7 @@ class SimpleTypeArgument(name: String, val upperBound: Importable?) : TypeArgume
|
||||
}
|
||||
}
|
||||
|
||||
class TypeArgumentWithMultipleUpperBounds(name: String, override val upperBounds: List<Importable>) : TypeArgument(name) {
|
||||
class TypeArgumentWithMultipleUpperBounds(name: String, override val upperBounds: List<TypeRef>) : TypeArgument(name) {
|
||||
override fun toString(): String {
|
||||
return name
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user