IR: remove IrTerminalExpressionBase, Ir{Terminal,}DeclarationReferenceBase

Implement no-op acceptChildren/transformChildren in the base class
IrExpressionBase instead. This doesn't change behavior because all other
implementations of acceptChildren/transformChildren are not affected.
This commit is contained in:
Alexander Udalov
2020-07-22 18:04:22 +02:00
parent 868018f51f
commit 9aa7da44e2
15 changed files with 21 additions and 97 deletions
@@ -511,7 +511,7 @@ class FunctionInlining(
private class IrGetValueWithoutLocation(
override val symbol: IrValueSymbol,
override val origin: IrStatementOrigin? = null
) : IrTerminalDeclarationReferenceBase<IrValueSymbol>(), IrGetValue {
) : IrExpressionBase(), IrGetValue {
override val startOffset: Int get() = UNDEFINED_OFFSET
override val endOffset: Int get() = UNDEFINED_OFFSET
@@ -537,4 +537,4 @@ class InlinerExpressionLocationHint(val inlineAtSymbol: IrSymbol) : IrStatementO
private val functionNameOrDefaultToString: String
get() = (inlineAtSymbol as? IrFunction)?.name?.asString() ?: inlineAtSymbol.toString()
}
}
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.ir.symbols.IrEnumEntrySymbol
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
import org.jetbrains.kotlin.ir.symbols.IrSymbol
interface IrDeclarationReference : IrExpression {
val symbol: IrSymbol
}
@@ -18,6 +18,6 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrBreakContinue
abstract class IrBreakContinueBase : IrTerminalExpressionBase(), IrBreakContinue {
abstract class IrBreakContinueBase : IrExpressionBase(), IrBreakContinue {
override var label: String? = null
}
@@ -27,7 +27,7 @@ class IrClassReferenceImpl(
override val type: IrType,
override val symbol: IrClassifierSymbol,
override val classType: IrType
) : IrTerminalDeclarationReferenceBase<IrClassifierSymbol>(), IrClassReference {
) : IrExpressionBase(), IrClassReference {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitClassReference(this, data)
}
@@ -27,7 +27,7 @@ class IrConstImpl<T>(
override val type: IrType,
override val kind: IrConstKind<T>,
override val value: T
) : IrTerminalExpressionBase(), IrConst<T> {
) : IrExpressionBase(), IrConst<T> {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitConst(this, data)
@@ -1,24 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrDeclarationReference
import org.jetbrains.kotlin.ir.symbols.IrSymbol
abstract class IrDeclarationReferenceBase<out S : IrSymbol> : IrExpressionBase(), IrDeclarationReference {
abstract override val symbol: S
}
@@ -26,7 +26,7 @@ class IrErrorExpressionImpl(
override val endOffset: Int,
override val type: IrType,
override val description: String
) : IrTerminalExpressionBase(), IrExpressionWithCopy, IrErrorExpression {
) : IrExpressionBase(), IrExpressionWithCopy, IrErrorExpression {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitErrorExpression(this, data)
@@ -19,8 +19,18 @@ package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.IrElementBase
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrExpressionBase : IrElementBase(), IrExpression {
@Suppress("LeakingThis")
override var attributeOwnerId: IrAttributeContainer = this
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
// No children by default
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
// No children by default
}
}
@@ -26,7 +26,7 @@ class IrGetEnumValueImpl(
override val endOffset: Int,
override val type: IrType,
override val symbol: IrEnumEntrySymbol,
) : IrTerminalDeclarationReferenceBase<IrEnumEntrySymbol>(), IrGetEnumValue {
) : IrExpressionBase(), IrGetEnumValue {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitGetEnumValue(this, data)
}
@@ -26,7 +26,7 @@ class IrGetObjectValueImpl(
override val endOffset: Int,
override val type: IrType,
override val symbol: IrClassSymbol
) : IrTerminalDeclarationReferenceBase<IrClassSymbol>(), IrGetObjectValue {
) : IrExpressionBase(), IrGetObjectValue {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitGetObjectValue(this, data)
}
@@ -17,7 +17,7 @@ class IrGetValueImpl(
override val type: IrType,
override val symbol: IrValueSymbol,
override val origin: IrStatementOrigin? = null
) : IrTerminalDeclarationReferenceBase<IrValueSymbol>(), IrGetValue {
) : IrExpressionBase(), IrGetValue {
constructor(
startOffset: Int,
endOffset: Int,
@@ -26,7 +26,7 @@ class IrInstanceInitializerCallImpl(
override val endOffset: Int,
override val classSymbol: IrClassSymbol,
override val type: IrType,
) : IrTerminalExpressionBase(), IrInstanceInitializerCall {
) : IrExpressionBase(), IrInstanceInitializerCall {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitInstanceInitializerCall(this, data)
}
@@ -26,7 +26,7 @@ class IrRawFunctionReferenceImpl(
override val endOffset: Int,
override val type: IrType,
override val symbol: IrFunctionSymbol,
) : IrTerminalDeclarationReferenceBase<IrFunctionSymbol>(), IrRawFunctionReference {
) : IrExpressionBase(), IrRawFunctionReference {
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R {
return visitor.visitRawFunctionReference(this, data)
}
@@ -1,31 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrTerminalDeclarationReferenceBase<out S : IrSymbol> : IrDeclarationReferenceBase<S>() {
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
// No children
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
// No children
}
}
@@ -1,30 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrTerminalExpressionBase : IrExpressionBase() {
override fun <D> acceptChildren(visitor: IrElementVisitor<Unit, D>, data: D) {
// No children
}
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
// No children
}
}