[IR] Mark IrConstructorCall as AnnotationMarker
IrConstructorCall is already used to represent both regular constructor call and annotations. Implementing AnnotationMarker avoids 'casting' it to this type later on in IrTypeSystemContext, which was done with a new IrElement implementation. We'd like to avoid such implementations, e.g. as so to make the IR hierarchy sealed. #KT-65773 In Progress
This commit is contained in:
committed by
Space Team
parent
bfbc33e3f6
commit
1c17219a7b
@@ -11,11 +11,12 @@ package org.jetbrains.kotlin.ir.expressions
|
|||||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
|
import org.jetbrains.kotlin.types.model.AnnotationMarker
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated from: [org.jetbrains.kotlin.ir.generator.IrTree.constructorCall]
|
* Generated from: [org.jetbrains.kotlin.ir.generator.IrTree.constructorCall]
|
||||||
*/
|
*/
|
||||||
abstract class IrConstructorCall : IrFunctionAccessExpression() {
|
abstract class IrConstructorCall : IrFunctionAccessExpression(), AnnotationMarker {
|
||||||
abstract override var symbol: IrConstructorSymbol
|
abstract override var symbol: IrConstructorSymbol
|
||||||
|
|
||||||
abstract var source: SourceElement
|
abstract var source: SourceElement
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* that can be found in the license/LICENSE.txt file.
|
* 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.ir.types
|
package org.jetbrains.kotlin.ir.types
|
||||||
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
|||||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.ir.IrBuiltIns
|
import org.jetbrains.kotlin.ir.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
@@ -411,7 +410,7 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
|||||||
|
|
||||||
override fun KotlinTypeMarker.getAttributes(): List<AnnotationMarker> {
|
override fun KotlinTypeMarker.getAttributes(): List<AnnotationMarker> {
|
||||||
require(this is IrType)
|
require(this is IrType)
|
||||||
return this.annotations.memoryOptimizedMap { object : AnnotationMarker, IrElement by it {} }
|
return this.annotations
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun KotlinTypeMarker.hasCustomAttributes(): Boolean {
|
override fun KotlinTypeMarker.hasCustomAttributes(): Boolean {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
import org.jetbrains.kotlin.types.model.AnnotationMarker
|
||||||
import org.jetbrains.kotlin.utils.withIndent
|
import org.jetbrains.kotlin.utils.withIndent
|
||||||
|
|
||||||
// Note the style of the DSL to describe IR elements, which is these things in the following order:
|
// Note the style of the DSL to describe IR elements, which is these things in the following order:
|
||||||
@@ -800,6 +801,7 @@ object IrTree : AbstractTreeBuilder() {
|
|||||||
transformerReturnType = rootElement
|
transformerReturnType = rootElement
|
||||||
|
|
||||||
parent(functionAccessExpression)
|
parent(functionAccessExpression)
|
||||||
|
parent(type<AnnotationMarker>())
|
||||||
|
|
||||||
+symbol(constructorSymbolType, mutable = true)
|
+symbol(constructorSymbolType, mutable = true)
|
||||||
+field("source", type<SourceElement>()) {
|
+field("source", type<SourceElement>()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user