IrDeclaration.transform(transformer, data) returns IrStatement.
Declaration containers assume that transformers maintain declaration structure.
This commit is contained in:
committed by
Dmitry Petrov
parent
65dcdaecfb
commit
e0129ef33b
@@ -25,8 +25,8 @@ interface IrDeclaration : IrStatement {
|
||||
val declarationKind: IrDeclarationKind
|
||||
val origin: IrDeclarationOrigin
|
||||
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrDeclaration =
|
||||
accept(transformer, data) as IrDeclaration
|
||||
override fun <D> transform(transformer: IrElementTransformer<D>, data: D): IrStatement =
|
||||
accept(transformer, data) as IrStatement
|
||||
}
|
||||
|
||||
enum class IrDeclarationKind {
|
||||
|
||||
@@ -57,7 +57,7 @@ class IrClassImpl(
|
||||
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
declarations.forEachIndexed { i, irDeclaration ->
|
||||
declarations[i] = irDeclaration.transform(transformer, data)
|
||||
declarations[i] = irDeclaration.transform(transformer, data) as IrDeclaration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class IrFileImpl(
|
||||
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
declarations.forEachIndexed { i, irDeclaration ->
|
||||
declarations[i] = irDeclaration.transform(transformer, data)
|
||||
declarations[i] = irDeclaration.transform(transformer, data) as IrDeclaration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.ir.visitors
|
||||
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
|
||||
@@ -36,7 +37,7 @@ interface IrElementTransformer<in D> : IrElementVisitor<IrElement, D> {
|
||||
return declaration
|
||||
}
|
||||
|
||||
override fun visitDeclaration(declaration: IrDeclaration, data: D): IrDeclaration {
|
||||
override fun visitDeclaration(declaration: IrDeclaration, data: D): IrStatement {
|
||||
declaration.transformChildren(this, data)
|
||||
return declaration
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user