IR: remove IrNoArgumentsCallableReferenceBase

To simplify transformation of IR element hierarchy to classes.
This commit is contained in:
Alexander Udalov
2020-07-22 16:04:58 +02:00
parent f270cd8d6e
commit e36d3ba4f6
3 changed files with 22 additions and 46 deletions
@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrLocalDelegatedPropertyReference
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrLocalDelegatedPropertySymbol
@@ -35,12 +36,21 @@ class IrLocalDelegatedPropertyReferenceImpl(
override val setter: IrSimpleFunctionSymbol?,
origin: IrStatementOrigin? = null
) :
IrNoArgumentsCallableReferenceBase<IrLocalDelegatedPropertySymbol>(startOffset, endOffset, type, 0, origin),
IrMemberAccessExpressionBase<IrLocalDelegatedPropertySymbol>(startOffset, endOffset, type, 0, 0, origin),
IrLocalDelegatedPropertyReference {
override val referencedName: Name
get() = symbol.owner.name
private fun throwNoValueArguments(): Nothing =
throw UnsupportedOperationException("Property reference $symbol has no value arguments")
override fun getValueArgument(index: Int): IrExpression? = throwNoValueArguments()
override fun putValueArgument(index: Int, valueArgument: IrExpression?): Unit = throwNoValueArguments()
override fun removeValueArgument(index: Int): Unit = throwNoValueArguments()
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitLocalDelegatedPropertyReference(this, data)
}
@@ -1,44 +0,0 @@
/*
* Copyright 2010-2017 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.IrCallableReference
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrSymbol
import org.jetbrains.kotlin.ir.types.IrType
abstract class IrNoArgumentsCallableReferenceBase<S : IrSymbol>(
startOffset: Int,
endOffset: Int,
type: IrType,
typeArgumentsCount: Int,
origin: IrStatementOrigin? = null
) :
IrMemberAccessExpressionBase<S>(startOffset, endOffset, type, typeArgumentsCount, 0, origin),
IrCallableReference<S> {
private fun throwNoValueArguments(): Nothing {
throw UnsupportedOperationException("Property reference $symbol has no value arguments")
}
override fun getValueArgument(index: Int): IrExpression? = throwNoValueArguments()
override fun putValueArgument(index: Int, valueArgument: IrExpression?) = throwNoValueArguments()
override fun removeValueArgument(index: Int) = throwNoValueArguments()
}
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.ir.expressions.impl
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrPropertyReference
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
@@ -38,7 +39,7 @@ class IrPropertyReferenceImpl(
override val setter: IrSimpleFunctionSymbol?,
origin: IrStatementOrigin? = null
) :
IrNoArgumentsCallableReferenceBase<IrPropertySymbol>(startOffset, endOffset, type, typeArgumentsCount, origin),
IrMemberAccessExpressionBase<IrPropertySymbol>(startOffset, endOffset, type, typeArgumentsCount, 0, origin),
IrPropertyReference {
@Deprecated(message = "Don't use descriptor-based API for IrPropertyReference", level = DeprecationLevel.WARNING)
@@ -61,6 +62,15 @@ class IrPropertyReferenceImpl(
override val referencedName: Name
get() = symbol.owner.name
private fun throwNoValueArguments(): Nothing =
throw UnsupportedOperationException("Property reference $symbol has no value arguments")
override fun getValueArgument(index: Int): IrExpression? = throwNoValueArguments()
override fun putValueArgument(index: Int, valueArgument: IrExpression?): Unit = throwNoValueArguments()
override fun removeValueArgument(index: Int): Unit = throwNoValueArguments()
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitPropertyReference(this, data)
}