[FIR] Replace FIR tree with generated implementation
This commit is contained in:
@@ -18,8 +18,8 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.*
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.symbols.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
@@ -268,7 +268,7 @@ class MultiModuleHtmlFirDump(private val outputRoot: File) {
|
||||
require(inModule)
|
||||
|
||||
val dumpOutput = index.files[file] ?: error("No location for ${file.name}")
|
||||
val dumper = HtmlFirDump(LinkResolver(dumpOutput), file.fileSession)
|
||||
val dumper = HtmlFirDump(LinkResolver(dumpOutput), file.session)
|
||||
val builder = StringBuilder()
|
||||
dumper.generate(file, builder)
|
||||
|
||||
@@ -338,9 +338,9 @@ class MultiModuleHtmlFirDump(private val outputRoot: File) {
|
||||
visitElement(valueParameter)
|
||||
}
|
||||
|
||||
override fun visitNamedFunction(namedFunction: FirNamedFunction) {
|
||||
indexDeclaration(namedFunction)
|
||||
visitElement(namedFunction)
|
||||
override fun visitSimpleFunction(simpleFunction: FirSimpleFunction) {
|
||||
indexDeclaration(simpleFunction)
|
||||
visitElement(simpleFunction)
|
||||
}
|
||||
|
||||
override fun visitTypeParameter(typeParameter: FirTypeParameter) {
|
||||
@@ -576,7 +576,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
}
|
||||
}
|
||||
|
||||
generateDeclarations(klass)
|
||||
generateDeclarations(klass.declarations)
|
||||
br
|
||||
|
||||
}
|
||||
@@ -773,14 +773,14 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
private fun FlowContent.generate(memberDeclaration: FirMemberDeclaration) {
|
||||
when (memberDeclaration) {
|
||||
is FirRegularClass -> generate(memberDeclaration)
|
||||
is FirNamedFunction -> generate(memberDeclaration)
|
||||
is FirProperty -> generate(memberDeclaration)
|
||||
is FirSimpleFunction -> generate(memberDeclaration)
|
||||
is FirProperty -> if (memberDeclaration.isLocal) generate(memberDeclaration as FirVariable<*>) else generate(memberDeclaration)
|
||||
is FirConstructor -> generate(memberDeclaration)
|
||||
else -> unsupported(memberDeclaration)
|
||||
}
|
||||
}
|
||||
|
||||
private fun FlowContent.generateTypeParameters(typeParameterContainer: FirTypeParameterContainer) {
|
||||
private fun FlowContent.generateTypeParameters(typeParameterContainer: FirTypeParametersOwner) {
|
||||
if (typeParameterContainer.typeParameters.isEmpty()) return
|
||||
+"<"
|
||||
generateList(typeParameterContainer.typeParameters) {
|
||||
@@ -873,7 +873,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
|
||||
private fun FlowContent.generate(statement: FirStatement) {
|
||||
when (statement) {
|
||||
is FirNamedFunction -> generate(statement)
|
||||
is FirSimpleFunction -> generate(statement)
|
||||
is FirAnonymousObject -> generate(statement, isStatement = true)
|
||||
is FirAnonymousFunction -> generate(statement, isStatement = true)
|
||||
is FirWhileLoop -> generate(statement)
|
||||
@@ -1074,7 +1074,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
|
||||
private fun FlowContent.generate(whileLoop: FirWhileLoop) {
|
||||
iline {
|
||||
generateLabel(whileLoop)
|
||||
generateLabel(whileLoop.label)
|
||||
keyword("while ")
|
||||
+"("
|
||||
generate(whileLoop.condition)
|
||||
@@ -1153,8 +1153,8 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
}
|
||||
}
|
||||
|
||||
private fun FlowContent.generateLabel(labeledElement: FirLabeledElement) {
|
||||
val label = labeledElement.label ?: return
|
||||
private fun FlowContent.generateLabel(label: FirLabel?) {
|
||||
if (label == null) return
|
||||
span("label") {
|
||||
+label.name
|
||||
+"@"
|
||||
@@ -1301,30 +1301,29 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
generate(it)
|
||||
}
|
||||
}
|
||||
generateDeclarations(anonymousObject)
|
||||
generateDeclarations(anonymousObject.declarations)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun FlowContent.generateDeclarations(declarationContainer: FirDeclarationContainer) {
|
||||
if (declarationContainer.declarations.isNotEmpty()) {
|
||||
private fun FlowContent.generateDeclarations(declarations: List<FirDeclaration>) {
|
||||
if (declarations.isNotEmpty()) {
|
||||
+" {"
|
||||
br
|
||||
|
||||
withIdentLevel {
|
||||
for (declaration in declarationContainer.declarations) {
|
||||
for (declaration in declarations) {
|
||||
generate(declaration)
|
||||
line {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inl()
|
||||
+"}"
|
||||
}
|
||||
}
|
||||
|
||||
private fun FlowContent.generate(function: FirNamedFunction) {
|
||||
private fun FlowContent.generate(function: FirSimpleFunction) {
|
||||
generateMultiLineExpression(isStatement = true) {
|
||||
iline {
|
||||
declarationStatus(function.status)
|
||||
@@ -1365,7 +1364,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
|
||||
private fun FlowContent.generate(anonymousFunction: FirAnonymousFunction, isStatement: Boolean) {
|
||||
generateMultiLineExpression(isStatement) {
|
||||
iline {
|
||||
generateLabel(anonymousFunction)
|
||||
generateLabel(anonymousFunction.label)
|
||||
keyword("fun ")
|
||||
generateReceiver(anonymousFunction.receiverTypeRef)
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ package org.jetbrains.kotlin.fir.backend
|
||||
|
||||
import com.intellij.psi.PsiCompiledElement
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.references.FirThisReference
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
@@ -117,7 +120,7 @@ fun FirReference.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbo
|
||||
private fun AbstractFirBasedSymbol<*>.toSymbol(declarationStorage: Fir2IrDeclarationStorage): IrSymbol? = when (this) {
|
||||
is FirClassSymbol -> toClassSymbol(declarationStorage)
|
||||
is FirFunctionSymbol<*> -> toFunctionSymbol(declarationStorage)
|
||||
is FirPropertySymbol -> toPropertyOrFieldSymbol(declarationStorage)
|
||||
is FirPropertySymbol -> if (fir.isLocal) toValueSymbol(declarationStorage) else toPropertyOrFieldSymbol(declarationStorage)
|
||||
is FirFieldSymbol -> toPropertyOrFieldSymbol(declarationStorage)
|
||||
is FirBackingFieldSymbol -> toBackingFieldSymbol(declarationStorage)
|
||||
is FirDelegateFieldSymbol<*> -> toBackingFieldSymbol(declarationStorage)
|
||||
|
||||
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.fir.backend
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
@@ -44,7 +43,7 @@ class Fir2IrCallableCache {
|
||||
fun getLocalFunction(localFunction: FirFunction<*>): IrSimpleFunction? = localFunctionCache[localFunction]
|
||||
|
||||
fun putLocalFunction(localFunction: FirFunction<*>, irFunction: IrSimpleFunction) {
|
||||
require(localFunction !is FirNamedFunction || localFunction.visibility == Visibilities.LOCAL)
|
||||
require(localFunction !is FirSimpleFunction || localFunction.visibility == Visibilities.LOCAL)
|
||||
localFunctionCache[localFunction] = irFunction
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter
|
||||
import org.jetbrains.kotlin.fir.descriptors.FirModuleDescriptor
|
||||
import org.jetbrains.kotlin.fir.descriptors.FirPackageFragmentDescriptor
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
@@ -52,7 +51,7 @@ class Fir2IrDeclarationStorage(
|
||||
|
||||
private val typeParameterCache = mutableMapOf<FirTypeParameter, IrTypeParameter>()
|
||||
|
||||
private val functionCache = mutableMapOf<FirNamedFunction, IrSimpleFunction>()
|
||||
private val functionCache = mutableMapOf<FirSimpleFunction, IrSimpleFunction>()
|
||||
|
||||
private val constructorCache = mutableMapOf<FirConstructor, IrConstructor>()
|
||||
|
||||
@@ -273,7 +272,7 @@ class Fir2IrDeclarationStorage(
|
||||
}
|
||||
if (function !is FirConstructor) {
|
||||
val thisOrigin = IrDeclarationOrigin.DEFINED
|
||||
if (function is FirNamedFunction) {
|
||||
if (function is FirSimpleFunction) {
|
||||
val receiverTypeRef = function.receiverTypeRef
|
||||
if (receiverTypeRef != null) {
|
||||
extensionReceiverParameter = receiverTypeRef.convertWithOffsets { startOffset, endOffset ->
|
||||
@@ -337,7 +336,7 @@ class Fir2IrDeclarationStorage(
|
||||
}
|
||||
|
||||
fun getIrFunction(
|
||||
function: FirNamedFunction,
|
||||
function: FirSimpleFunction,
|
||||
irParent: IrDeclarationParent? = null,
|
||||
shouldLeaveScope: Boolean = false,
|
||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED
|
||||
@@ -611,7 +610,7 @@ class Fir2IrDeclarationStorage(
|
||||
val firDeclaration = firFunctionSymbol.fir
|
||||
val irParent = (firDeclaration as? FirCallableMemberDeclaration<*>)?.let { findIrParent(it) }
|
||||
return when (firDeclaration) {
|
||||
is FirNamedFunction -> {
|
||||
is FirSimpleFunction -> {
|
||||
val irDeclaration = getIrFunction(firDeclaration, irParent, shouldLeaveScope = true).apply {
|
||||
setAndModifyParent(irParent)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.fir.backend
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
||||
import org.jetbrains.kotlin.fir.declarations.FirVariable
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
|
||||
@@ -16,7 +16,9 @@ import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirPropertyFromParameterCallableReference
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterCallableReference
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.SyntheticPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||
@@ -164,7 +166,7 @@ class Fir2IrVisitor(
|
||||
is FirClassSymbol -> {
|
||||
val superClass = superSymbol.fir
|
||||
for (declaration in superClass.declarations) {
|
||||
if (declaration is FirMemberDeclaration && (declaration is FirNamedFunction || declaration is FirProperty)) {
|
||||
if (declaration is FirMemberDeclaration && (declaration is FirSimpleFunction || declaration is FirProperty)) {
|
||||
result += declaration.name
|
||||
}
|
||||
}
|
||||
@@ -270,7 +272,7 @@ class Fir2IrVisitor(
|
||||
if (it !is FirConstructor || !it.isPrimary) {
|
||||
val irDeclaration = it.toIrDeclaration() ?: return@forEach
|
||||
declarations += irDeclaration
|
||||
if (it is FirMemberDeclaration && (it is FirNamedFunction || it is FirProperty)) {
|
||||
if (it is FirMemberDeclaration && (it is FirSimpleFunction || it is FirProperty)) {
|
||||
processedCallableNames += it.name
|
||||
}
|
||||
}
|
||||
@@ -317,12 +319,12 @@ class Fir2IrVisitor(
|
||||
): T {
|
||||
setParentByParentStack()
|
||||
withParent {
|
||||
if (firFunction is FirNamedFunction) {
|
||||
if (firFunction is FirSimpleFunction) {
|
||||
for ((index, typeParameter) in firFunction.typeParameters.withIndex()) {
|
||||
typeParameters += declarationStorage.getIrTypeParameter(typeParameter, index).setParentByParentStack()
|
||||
}
|
||||
}
|
||||
val firFunctionSymbol = (firFunction as? FirNamedFunction)?.symbol
|
||||
val firFunctionSymbol = (firFunction as? FirSimpleFunction)?.symbol
|
||||
val lastClass = classStack.lastOrNull()
|
||||
val containingClass = if (firOverriddenSymbol == null || firFunctionSymbol == null) {
|
||||
lastClass
|
||||
@@ -449,12 +451,12 @@ class Fir2IrVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitNamedFunction(namedFunction: FirNamedFunction, data: Any?): IrElement {
|
||||
override fun visitSimpleFunction(simpleFunction: FirSimpleFunction, data: Any?): IrElement {
|
||||
val irFunction = declarationStorage.getIrFunction(
|
||||
namedFunction, irParent = parentStack.last() as? IrClass
|
||||
simpleFunction, irParent = parentStack.last() as? IrClass
|
||||
)
|
||||
return irFunction.setParentByParentStack().withFunction {
|
||||
setFunctionContent(irFunction.descriptor, namedFunction)
|
||||
setFunctionContent(irFunction.descriptor, simpleFunction)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -477,7 +479,8 @@ class Fir2IrVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun <F : FirVariable<F>> visitVariable(variable: FirVariable<F>, data: Any?): IrElement {
|
||||
private fun visitLocalVariable(variable: FirProperty, data: Any?): IrElement {
|
||||
assert(variable.isLocal)
|
||||
val irVariable = declarationStorage.createAndSaveIrVariable(variable)
|
||||
return irVariable.setParentByParentStack().apply {
|
||||
val initializer = variable.initializer
|
||||
@@ -569,7 +572,8 @@ class Fir2IrVisitor(
|
||||
return this
|
||||
}
|
||||
|
||||
override fun visitProperty(property: FirProperty, data: Any?): IrProperty {
|
||||
override fun visitProperty(property: FirProperty, data: Any?): IrElement {
|
||||
if (property.isLocal) return visitLocalVariable(property, data)
|
||||
val irProperty = declarationStorage.getIrProperty(property, irParent = parentStack.last() as? IrClass)
|
||||
return irProperty.setParentByParentStack().withProperty { setPropertyContent(irProperty.descriptor, property) }
|
||||
}
|
||||
@@ -634,7 +638,7 @@ class Fir2IrVisitor(
|
||||
var irTarget = functionStack.last()
|
||||
for (potentialTarget in functionStack.asReversed()) {
|
||||
// TODO: remove comparison by name
|
||||
if (potentialTarget.name == (firTarget as? FirNamedFunction)?.name) {
|
||||
if (potentialTarget.name == (firTarget as? FirSimpleFunction)?.name) {
|
||||
irTarget = potentialTarget
|
||||
break
|
||||
}
|
||||
@@ -649,11 +653,6 @@ class Fir2IrVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitUncheckedNotNullCast(uncheckedNotNullCast: FirUncheckedNotNullCast, data: Any?): IrElement {
|
||||
// TODO: Ensure correct
|
||||
return uncheckedNotNullCast.expression.toIrExpression()
|
||||
}
|
||||
|
||||
override fun visitWrappedArgumentExpression(wrappedArgumentExpression: FirWrappedArgumentExpression, data: Any?): IrElement {
|
||||
// TODO: change this temporary hack to something correct
|
||||
return wrappedArgumentExpression.expression.toIrExpression()
|
||||
@@ -799,6 +798,14 @@ class Fir2IrVisitor(
|
||||
return qualifiedAccessExpression.toIrExpression(qualifiedAccessExpression.typeRef).applyReceivers(qualifiedAccessExpression)
|
||||
}
|
||||
|
||||
override fun visitThisReceiverExpression(thisReceiverExpression: FirThisReceiverExpression, data: Any?): IrElement {
|
||||
return visitQualifiedAccessExpression(thisReceiverExpression, data)
|
||||
}
|
||||
|
||||
override fun visitExpressionWithSmartcast(expressionWithSmartcast: FirExpressionWithSmartcast, data: Any?): IrElement {
|
||||
return visitQualifiedAccessExpression(expressionWithSmartcast, data)
|
||||
}
|
||||
|
||||
override fun visitCallableReferenceAccess(callableReferenceAccess: FirCallableReferenceAccess, data: Any?): IrElement {
|
||||
val symbol = callableReferenceAccess.calleeReference.toSymbol(declarationStorage)
|
||||
val type = callableReferenceAccess.typeRef.toIrType(this@Fir2IrVisitor.session, declarationStorage)
|
||||
@@ -1255,13 +1262,13 @@ class Fir2IrVisitor(
|
||||
val leftOperand = binaryLogicExpression.leftOperand.accept(this, data) as IrExpression
|
||||
val rightOperand = binaryLogicExpression.rightOperand.accept(this, data) as IrExpression
|
||||
when (binaryLogicExpression.kind) {
|
||||
FirBinaryLogicExpression.OperationKind.AND -> {
|
||||
LogicOperationKind.AND -> {
|
||||
IrIfThenElseImpl(startOffset, endOffset, irBuiltIns.booleanType, IrStatementOrigin.ANDAND).apply {
|
||||
branches.add(IrBranchImpl(leftOperand, rightOperand))
|
||||
branches.add(elseBranch(constFalse(rightOperand.startOffset, rightOperand.endOffset)))
|
||||
}
|
||||
}
|
||||
FirBinaryLogicExpression.OperationKind.OR -> {
|
||||
LogicOperationKind.OR -> {
|
||||
IrIfThenElseImpl(startOffset, endOffset, irBuiltIns.booleanType, IrStatementOrigin.OROR).apply {
|
||||
branches.add(IrBranchImpl(leftOperand, constTrue(leftOperand.startOffset, leftOperand.endOffset)))
|
||||
branches.add(elseBranch(rightOperand))
|
||||
|
||||
@@ -22,10 +22,8 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.classId
|
||||
import org.jetbrains.kotlin.fir.declarations.superConeTypes
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.directExpansionType
|
||||
import org.jetbrains.kotlin.fir.resolve.firProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
@@ -96,7 +94,7 @@ class FirJavaElementFinder(
|
||||
firClass.typeParameters.map { Pair(it.name.asString(), arrayOf(CommonClassNames.JAVA_LANG_OBJECT)) }
|
||||
)
|
||||
|
||||
if (firClass.supertypesComputationStatus != FirClassLikeDeclaration.SupertypesComputationStatus.COMPUTED) {
|
||||
if (firClass.supertypesComputationStatus != SupertypesComputationStatus.COMPUTED) {
|
||||
val firForSuperClassFile = firProvider.getFirClassifierContainerFile(classId)
|
||||
FirSupertypeResolverTransformer().apply {
|
||||
initFromFile(firForSuperClassFile)
|
||||
@@ -137,7 +135,7 @@ private fun FirRegularClass.packFlags(): Int {
|
||||
}
|
||||
|
||||
private fun PsiClassStubImpl<*>.addSupertypesReferencesLists(firRegularClass: FirRegularClass, session: FirSession) {
|
||||
if (firRegularClass.supertypesComputationStatus == FirClassLikeDeclaration.SupertypesComputationStatus.COMPUTING) return
|
||||
if (firRegularClass.supertypesComputationStatus == SupertypesComputationStatus.COMPUTING) return
|
||||
require(firRegularClass.superTypeRefs.all { it is FirResolvedTypeRef }) {
|
||||
"Supertypes for light class $qualifiedName are being added too early"
|
||||
}
|
||||
|
||||
@@ -22,10 +22,8 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.classId
|
||||
import org.jetbrains.kotlin.fir.declarations.superConeTypes
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.directExpansionType
|
||||
import org.jetbrains.kotlin.fir.resolve.firProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
@@ -96,7 +94,7 @@ class FirJavaElementFinder(
|
||||
firClass.typeParameters.map { Pair(it.name.asString(), arrayOf(CommonClassNames.JAVA_LANG_OBJECT)) }
|
||||
)
|
||||
|
||||
if (firClass.supertypesComputationStatus != FirClassLikeDeclaration.SupertypesComputationStatus.COMPUTED) {
|
||||
if (firClass.supertypesComputationStatus != SupertypesComputationStatus.COMPUTED) {
|
||||
val firForSuperClassFile = firProvider.getFirClassifierContainerFile(classId)
|
||||
FirSupertypeResolverTransformer().apply {
|
||||
initFromFile(firForSuperClassFile)
|
||||
@@ -137,7 +135,7 @@ private fun FirRegularClass.packFlags(): Int {
|
||||
}
|
||||
|
||||
private fun PsiClassStubImpl<*>.addSupertypesReferencesLists(firRegularClass: FirRegularClass, session: FirSession) {
|
||||
if (firRegularClass.supertypesComputationStatus == FirClassLikeDeclaration.SupertypesComputationStatus.COMPUTING) return
|
||||
if (firRegularClass.supertypesComputationStatus == SupertypesComputationStatus.COMPUTING) return
|
||||
require(firRegularClass.superTypeRefs.all { it is FirResolvedTypeRef }) {
|
||||
"Supertypes for light class $qualifiedName are being added too early"
|
||||
}
|
||||
|
||||
@@ -9,12 +9,15 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.addDefaultBoundIfNecessary
|
||||
import org.jetbrains.kotlin.fir.declarations.visibility
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaConstructor
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaField
|
||||
@@ -116,7 +119,14 @@ class JavaSymbolProvider(
|
||||
val stored = javaTypeParameterStack.safeGet(this)
|
||||
if (stored != null) return stored.fir
|
||||
val firSymbol = FirTypeParameterSymbol()
|
||||
val result = FirTypeParameterImpl(session, null, firSymbol, name, variance = INVARIANT, isReified = false)
|
||||
val result = FirTypeParameterImpl(
|
||||
null,
|
||||
session,
|
||||
name,
|
||||
firSymbol,
|
||||
variance = INVARIANT,
|
||||
isReified = false
|
||||
)
|
||||
javaTypeParameterStack.add(this, result)
|
||||
return result
|
||||
}
|
||||
@@ -167,7 +177,7 @@ class JavaSymbolProvider(
|
||||
}
|
||||
}
|
||||
FirJavaClass(
|
||||
session, (javaClass as? JavaElementImpl<*>)?.psi,
|
||||
(javaClass as? JavaElementImpl<*>)?.psi, session,
|
||||
firSymbol as FirClassSymbol, javaClass.name,
|
||||
javaClass.visibility, javaClass.modality,
|
||||
javaClass.classKind, isTopLevel = isTopLevel,
|
||||
@@ -187,7 +197,7 @@ class JavaSymbolProvider(
|
||||
val fieldSymbol = FirFieldSymbol(fieldId)
|
||||
val returnType = javaField.type
|
||||
val firJavaField = FirJavaField(
|
||||
this@JavaSymbolProvider.session, (javaField as? JavaElementImpl<*>)?.psi,
|
||||
(javaField as? JavaElementImpl<*>)?.psi, this@JavaSymbolProvider.session,
|
||||
fieldSymbol, fieldName,
|
||||
javaField.visibility, javaField.modality,
|
||||
returnTypeRef = returnType.toFirJavaTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack),
|
||||
@@ -231,10 +241,13 @@ class JavaSymbolProvider(
|
||||
val constructorSymbol = FirConstructorSymbol(constructorId)
|
||||
val classTypeParameters = javaClass.typeParameters.convertTypeParameters(javaTypeParameterStack)
|
||||
val firJavaConstructor = FirJavaConstructor(
|
||||
this@JavaSymbolProvider.session, psi,
|
||||
constructorSymbol, visibility, isPrimary,
|
||||
psi,
|
||||
this@JavaSymbolProvider.session,
|
||||
constructorSymbol,
|
||||
visibility,
|
||||
isPrimary,
|
||||
isInner = !javaClass.isStatic,
|
||||
delegatedSelfTypeRef = FirResolvedTypeRefImpl(
|
||||
returnTypeRef = FirResolvedTypeRefImpl(
|
||||
null,
|
||||
firSymbol.constructType(
|
||||
classTypeParameters.map { ConeTypeParameterTypeImpl(it.symbol.toLookupTag(), false) }.toTypedArray(),
|
||||
|
||||
@@ -15,11 +15,13 @@ import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaValueParameter
|
||||
import org.jetbrains.kotlin.fir.java.enhancement.readOnlyToMutable
|
||||
import org.jetbrains.kotlin.fir.java.types.FirJavaTypeRef
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.constructClassType
|
||||
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.getClassDeclaredCallableSymbols
|
||||
@@ -91,9 +93,10 @@ internal fun JavaClassifierType.toFirResolvedTypeRef(
|
||||
): FirResolvedTypeRef {
|
||||
val coneType = this.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false)
|
||||
return FirResolvedTypeRefImpl(
|
||||
psi = null, type = coneType,
|
||||
annotations = annotations.map { it.toFirAnnotationCall(session, javaTypeParameterStack) }
|
||||
)
|
||||
psi = null, type = coneType
|
||||
).apply {
|
||||
annotations += this@toFirResolvedTypeRef.annotations.map { it.toFirAnnotationCall(session, javaTypeParameterStack) }
|
||||
}
|
||||
}
|
||||
|
||||
internal fun JavaType?.toConeKotlinTypeWithNullability(
|
||||
@@ -173,8 +176,7 @@ internal fun JavaAnnotation.toFirAnnotationCall(
|
||||
psi = null, useSiteTarget = null,
|
||||
annotationTypeRef = FirResolvedTypeRefImpl(
|
||||
psi = null,
|
||||
type = ConeClassTypeImpl(FirClassSymbol(classId!!).toLookupTag(), emptyArray(), isNullable = false),
|
||||
annotations = emptyList()
|
||||
type = ConeClassTypeImpl(FirClassSymbol(classId!!).toLookupTag(), emptyArray(), isNullable = false)
|
||||
)
|
||||
).apply {
|
||||
for (argument in this@toFirAnnotationCall.arguments) {
|
||||
@@ -256,7 +258,7 @@ private fun JavaAnnotationArgument.toFirExpression(
|
||||
null
|
||||
}
|
||||
this.calleeReference = calleeReference
|
||||
?: FirErrorNamedReference(null, "Strange Java enum value: $classId.$entryName")
|
||||
?: FirErrorNamedReferenceImpl(null, "Strange Java enum value: $classId.$entryName")
|
||||
}
|
||||
}
|
||||
is JavaClassObjectAnnotationArgument -> FirGetClassCallImpl(null).apply {
|
||||
@@ -309,8 +311,7 @@ private fun JavaType.toFirResolvedTypeRef(
|
||||
): FirResolvedTypeRef {
|
||||
if (this is JavaClassifierType) return toFirResolvedTypeRef(session, javaTypeParameterStack)
|
||||
return FirResolvedTypeRefImpl(
|
||||
psi = null, type = ConeClassErrorType("Unexpected JavaType: $this"),
|
||||
annotations = emptyList()
|
||||
psi = null, type = ConeClassErrorType("Unexpected JavaType: $this")
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -10,42 +10,45 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirClassLikeDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirAbstractMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableClass
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.fir.visitors.transformInplace
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirJavaClass internal constructor(
|
||||
session: FirSession,
|
||||
psi: PsiElement?,
|
||||
override val psi: PsiElement?,
|
||||
override val session: FirSession,
|
||||
override val symbol: FirClassSymbol,
|
||||
name: Name,
|
||||
override val name: Name,
|
||||
visibility: Visibility,
|
||||
modality: Modality?,
|
||||
override val classKind: ClassKind,
|
||||
isTopLevel: Boolean,
|
||||
isStatic: Boolean,
|
||||
internal val javaTypeParameterStack: JavaTypeParameterStack
|
||||
) : FirAbstractMemberDeclaration(
|
||||
session, psi, name,
|
||||
visibility, modality,
|
||||
isExpect = false, isActual = false
|
||||
), FirRegularClass, FirModifiableClass {
|
||||
) : FirRegularClass, FirModifiableClass {
|
||||
override var status: FirDeclarationStatusImpl = FirDeclarationStatusImpl(visibility, modality)
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override val typeParameters: MutableList<FirTypeParameter> = mutableListOf()
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
status.isInner = !isTopLevel && !isStatic
|
||||
status.isCompanion = false
|
||||
status.isData = false
|
||||
status.isInline = false
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
}
|
||||
|
||||
override var resolvePhase: FirResolvePhase = FirResolvePhase.DECLARATIONS
|
||||
|
||||
override val superTypeRefs = mutableListOf<FirTypeRef>()
|
||||
|
||||
override val declarations = mutableListOf<FirDeclaration>()
|
||||
@@ -53,11 +56,31 @@ class FirJavaClass internal constructor(
|
||||
override val companionObject: FirRegularClass?
|
||||
get() = null
|
||||
|
||||
override fun replaceSupertypes(newSupertypes: List<FirTypeRef>): FirRegularClass {
|
||||
override fun replaceSuperTypeRefs(newSuperTypeRefs: List<FirTypeRef>) {
|
||||
superTypeRefs.clear()
|
||||
superTypeRefs.addAll(newSupertypes)
|
||||
return this
|
||||
superTypeRefs.addAll(newSuperTypeRefs)
|
||||
}
|
||||
|
||||
override var supertypesComputationStatus = FirClassLikeDeclaration.SupertypesComputationStatus.NOT_COMPUTED
|
||||
override var supertypesComputationStatus = SupertypesComputationStatus.NOT_COMPUTED
|
||||
|
||||
override fun replaceSupertypesComputationStatus(newSupertypesComputationStatus: SupertypesComputationStatus) {
|
||||
supertypesComputationStatus = newSupertypesComputationStatus
|
||||
}
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
declarations.forEach { it.accept(visitor, data) }
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
typeParameters.forEach { it.accept(visitor, data) }
|
||||
status.accept(visitor, data)
|
||||
superTypeRefs.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirModifiableClass {
|
||||
declarations.transformInplace(transformer, data)
|
||||
annotations.transformInplace(transformer, data)
|
||||
typeParameters.transformInplace(transformer, data)
|
||||
status = status.transformSingle(transformer, data)
|
||||
superTypeRefs.transformInplace(transformer, data)
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
+61
-24
@@ -8,44 +8,51 @@ package org.jetbrains.kotlin.fir.java.declarations
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.CONSTRUCTOR_NAME
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirAbstractCallableMember
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirConstructorImpl.Companion.NAME
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirConstructorSymbol
|
||||
import org.jetbrains.kotlin.fir.transformInplace
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.fir.visitors.transformInplace
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
class FirJavaConstructor(
|
||||
session: FirSession,
|
||||
psi: PsiElement?,
|
||||
override val psi: PsiElement?,
|
||||
override val session: FirSession,
|
||||
override val symbol: FirConstructorSymbol,
|
||||
visibility: Visibility,
|
||||
override val isPrimary: Boolean,
|
||||
override val isInner: Boolean,
|
||||
delegatedSelfTypeRef: FirTypeRef
|
||||
) : FirAbstractCallableMember<FirConstructor>(
|
||||
session,
|
||||
psi,
|
||||
name = NAME,
|
||||
visibility = visibility,
|
||||
modality = Modality.FINAL,
|
||||
isExpect = false,
|
||||
isActual = false,
|
||||
isOverride = false,
|
||||
receiverTypeRef = null,
|
||||
returnTypeRef = delegatedSelfTypeRef
|
||||
), FirConstructor {
|
||||
isInner: Boolean,
|
||||
override var returnTypeRef : FirTypeRef
|
||||
) : FirAbstractAnnotatedElement, FirConstructor {
|
||||
override val receiverTypeRef: FirTypeRef? get() = null
|
||||
override val typeParameters: MutableList<FirTypeParameter> = mutableListOf()
|
||||
override val name: Name get() = CONSTRUCTOR_NAME
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
|
||||
override var status: FirDeclarationStatus = FirDeclarationStatusImpl(visibility, Modality.FINAL).apply {
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
this.isInner = isInner
|
||||
}
|
||||
|
||||
override var resolvePhase: FirResolvePhase = FirResolvePhase.DECLARATIONS
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
}
|
||||
|
||||
override val delegatedConstructor: FirDelegatedConstructorCall?
|
||||
@@ -56,7 +63,7 @@ class FirJavaConstructor(
|
||||
|
||||
override val valueParameters = mutableListOf<FirValueParameter>()
|
||||
|
||||
override val controlFlowGraphReference: FirControlFlowGraphReference? get() = null
|
||||
override val controlFlowGraphReference: FirControlFlowGraphReference get() = FirEmptyControlFlowGraphReference()
|
||||
|
||||
override fun <D> transformValueParameters(transformer: FirTransformer<D>, data: D): FirJavaConstructor {
|
||||
valueParameters.transformInplace(transformer, data)
|
||||
@@ -66,4 +73,34 @@ class FirJavaConstructor(
|
||||
override fun <D> transformControlFlowGraphReference(transformer: FirTransformer<D>, data: D): FirJavaConstructor {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirConstructor {
|
||||
returnTypeRef = returnTypeRef.transformSingle(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) {
|
||||
resolvePhase = newResolvePhase
|
||||
}
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
returnTypeRef.accept(visitor, data)
|
||||
controlFlowGraphReference.accept(visitor, data)
|
||||
typeParameters.forEach { it.accept(visitor, data) }
|
||||
valueParameters.forEach { it.accept(visitor, data) }
|
||||
status.accept(visitor, data)
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirJavaConstructor {
|
||||
transformReturnTypeRef(transformer, data)
|
||||
transformControlFlowGraphReference(transformer, data)
|
||||
typeParameters.transformInplace(transformer, data)
|
||||
transformValueParameters(transformer, data)
|
||||
status = status.transformSingle(transformer, data)
|
||||
annotations.transformInplace(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override var containerSource: DeserializedContainerSource? = null
|
||||
}
|
||||
@@ -8,36 +8,86 @@ package org.jetbrains.kotlin.fir.java.declarations
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirAnnotationContainer
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirField
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirAbstractCallableMember
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirDelegateFieldSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFieldSymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.fir.visitors.transformInplace
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
|
||||
|
||||
class FirJavaField(
|
||||
session: FirSession,
|
||||
psi: PsiElement?,
|
||||
override val psi: PsiElement?,
|
||||
override val session: FirSession,
|
||||
override val symbol: FirFieldSymbol,
|
||||
name: Name,
|
||||
override val name: Name,
|
||||
visibility: Visibility,
|
||||
modality: Modality?,
|
||||
returnTypeRef: FirTypeRef,
|
||||
override var returnTypeRef: FirTypeRef,
|
||||
override val isVar: Boolean,
|
||||
isStatic: Boolean
|
||||
) : FirAbstractCallableMember<FirField>(
|
||||
session, psi, name,
|
||||
visibility, modality,
|
||||
isExpect = false, isActual = false, isOverride = false,
|
||||
receiverTypeRef = null, returnTypeRef = returnTypeRef
|
||||
), FirField {
|
||||
) : FirAbstractAnnotatedElement, FirField {
|
||||
init {
|
||||
symbol.bind(this)
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
}
|
||||
|
||||
override var status: FirDeclarationStatus = FirDeclarationStatusImpl(visibility, modality).apply {
|
||||
this.isStatic = isStatic
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
}
|
||||
override val receiverTypeRef: FirTypeRef? get() = null
|
||||
override var resolvePhase: FirResolvePhase = FirResolvePhase.DECLARATIONS
|
||||
override val isVal: Boolean = true
|
||||
override val getter: FirPropertyAccessor? get() = null
|
||||
override val setter: FirPropertyAccessor? get() = null
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override val typeParameters: MutableList<FirTypeParameter> = mutableListOf()
|
||||
|
||||
override fun <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirField {
|
||||
returnTypeRef = returnTypeRef.transformSingle(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformGetter(transformer: FirTransformer<D>, data: D): FirField {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformSetter(transformer: FirTransformer<D>, data: D): FirField {
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformOtherChildren(transformer: FirTransformer<D>, data: D): FirField {
|
||||
annotations.transformInplace(transformer, data)
|
||||
typeParameters.transformInplace(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun replaceResolvePhase(newResolvePhase: FirResolvePhase) {
|
||||
resolvePhase = newResolvePhase
|
||||
}
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
returnTypeRef.accept(visitor, data)
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
typeParameters.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirJavaField {
|
||||
transformReturnTypeRef(transformer, data)
|
||||
transformOtherChildren(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override val delegate: FirExpression?
|
||||
@@ -49,11 +99,5 @@ class FirJavaField(
|
||||
override val delegateFieldSymbol: FirDelegateFieldSymbol<FirField>?
|
||||
get() = null
|
||||
|
||||
init {
|
||||
status.isStatic = isStatic
|
||||
}
|
||||
|
||||
override fun <D> transformChildrenWithoutAccessors(transformer: FirTransformer<D>, data: D) {
|
||||
transformChildren(transformer, data)
|
||||
}
|
||||
override var containerSource: DeserializedContainerSource? = null
|
||||
}
|
||||
@@ -10,7 +10,8 @@ import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirMemberFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.java.types.FirJavaTypeRef
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -24,17 +25,27 @@ class FirJavaMethod(
|
||||
modality: Modality?,
|
||||
returnTypeRef: FirJavaTypeRef,
|
||||
isStatic: Boolean
|
||||
) : FirMemberFunctionImpl(
|
||||
session, psi, symbol, name,
|
||||
visibility, modality,
|
||||
false, isActual = false,
|
||||
isOverride = false,
|
||||
isOperator = true, // All Java methods with name that allows to use it in operator form are considered operators
|
||||
isInfix = false, isInline = false, isTailRec = false, isExternal = false, isSuspend = false,
|
||||
receiverTypeRef = null, returnTypeRef = returnTypeRef
|
||||
) : FirSimpleFunctionImpl(
|
||||
psi,
|
||||
session,
|
||||
returnTypeRef,
|
||||
null,
|
||||
name,
|
||||
FirDeclarationStatusImpl(visibility, modality).apply {
|
||||
this.isStatic = isStatic
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
isOperator = true // All Java methods with name that allows to use it in operator form are considered operators
|
||||
isInfix = false
|
||||
isInline = false
|
||||
isTailRec = false
|
||||
isExternal = false
|
||||
isSuspend = false
|
||||
},
|
||||
symbol
|
||||
) {
|
||||
init {
|
||||
status.isStatic = isStatic
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
}
|
||||
}
|
||||
+10
-2
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.java.types.FirJavaTypeRef
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirJavaValueParameter(
|
||||
@@ -19,8 +20,15 @@ class FirJavaValueParameter(
|
||||
returnTypeRef: FirJavaTypeRef,
|
||||
isVararg: Boolean
|
||||
) : FirValueParameterImpl(
|
||||
session, psi, name, returnTypeRef,
|
||||
defaultValue = null, isCrossinline = false, isNoinline = false, isVararg = isVararg
|
||||
psi,
|
||||
session,
|
||||
returnTypeRef,
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
defaultValue = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isVararg = isVararg
|
||||
) {
|
||||
init {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
|
||||
+10
-9
@@ -10,19 +10,21 @@ import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirMemberFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirMemberPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext
|
||||
import org.jetbrains.kotlin.fir.deserialization.deserializeClassToSymbol
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirClassReferenceExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.java.JavaSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.java.createConstant
|
||||
import org.jetbrains.kotlin.fir.java.topLevelName
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.declaredMemberScope
|
||||
@@ -171,8 +173,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
private fun FirClassifierSymbol<*>?.toDefaultResolvedTypeRef(classId: ClassId): FirResolvedTypeRef {
|
||||
return this?.let {
|
||||
FirResolvedTypeRefImpl(
|
||||
null, it.constructType(emptyList(), isNullable = false),
|
||||
annotations = emptyList()
|
||||
null, it.constructType(emptyList(), isNullable = false)
|
||||
)
|
||||
} ?: FirErrorTypeRefImpl(null, "Symbol not found for $classId")
|
||||
|
||||
@@ -224,7 +225,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
FirErrorNamedReference(
|
||||
FirErrorNamedReferenceImpl(
|
||||
null,
|
||||
errorReason = "Strange deserialized enum value: ${this@toEnumEntryReferenceExpression}.$name"
|
||||
)
|
||||
@@ -282,7 +283,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
result += FirAnnotationCallImpl(null, null, symbol.toDefaultResolvedTypeRef(annotationClassId)).apply {
|
||||
for ((name, expression) in argumentMap) {
|
||||
arguments += FirNamedArgumentExpressionImpl(
|
||||
null, name, false, expression
|
||||
null, expression, false, name
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -357,7 +358,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
val functionIds = part.topLevelFunctionNameIndex[name] ?: return emptyList()
|
||||
return functionIds.map { part.proto.getFunction(it) }
|
||||
.map {
|
||||
val firNamedFunction = part.context.memberDeserializer.loadFunction(it) as FirMemberFunctionImpl
|
||||
val firNamedFunction = part.context.memberDeserializer.loadFunction(it) as FirSimpleFunctionImpl
|
||||
firNamedFunction.containerSource = part.source
|
||||
firNamedFunction.symbol
|
||||
}
|
||||
@@ -367,7 +368,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
val propertyIds = part.topLevelPropertyNameIndex[name] ?: return emptyList()
|
||||
return propertyIds.map { part.proto.getProperty(it) }
|
||||
.map {
|
||||
val firProperty = part.context.memberDeserializer.loadProperty(it) as FirMemberPropertyImpl
|
||||
val firProperty = part.context.memberDeserializer.loadProperty(it) as FirPropertyImpl
|
||||
firProperty.containerSource = part.source
|
||||
firProperty.symbol
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,10 +6,10 @@
|
||||
package org.jetbrains.kotlin.fir.java.enhancement
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.fir.FirAnnotationContainer
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationContainer
|
||||
import org.jetbrains.kotlin.fir.expressions.resolvedFqName
|
||||
import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack
|
||||
import org.jetbrains.kotlin.fir.java.toConeKotlinTypeWithNullability
|
||||
|
||||
@@ -19,8 +19,8 @@ import org.jetbrains.kotlin.fir.java.declarations.FirJavaField
|
||||
import org.jetbrains.kotlin.fir.java.toConeProjection
|
||||
import org.jetbrains.kotlin.fir.java.toNotNullConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.java.types.FirJavaTypeRef
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.constructType
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.resolve.toTypeProjection
|
||||
@@ -85,13 +85,16 @@ private fun JavaType?.enhancePossiblyFlexible(
|
||||
|
||||
FirResolvedTypeRefImpl(
|
||||
psi = null,
|
||||
type = coneFlexibleOrSimpleType(session, lowerResult, upperResult),
|
||||
annotations = annotations
|
||||
)
|
||||
type = coneFlexibleOrSimpleType(session, lowerResult, upperResult)
|
||||
).apply {
|
||||
this.annotations += annotations
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
val enhanced = type.toNotNullConeKotlinType(session, javaTypeParameterStack)
|
||||
FirResolvedTypeRefImpl(psi = null, type = enhanced, annotations = annotations)
|
||||
FirResolvedTypeRefImpl(psi = null, type = enhanced).apply {
|
||||
this.annotations += annotations
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,7 +252,7 @@ internal fun ConeKotlinType.lexicalCastFrom(session: FirSession, value: String):
|
||||
|
||||
return if (firEnumEntry != null) FirQualifiedAccessExpressionImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(
|
||||
null, name // TODO: , firEnumEntry.symbol
|
||||
null, name, null // TODO: , firEnumEntry.symbol
|
||||
)
|
||||
} else if (firElement is FirJavaClass) {
|
||||
val firStaticProperty = firElement.declarations.filterIsInstance<FirJavaField>().find {
|
||||
|
||||
+35
-22
@@ -5,12 +5,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.java.scopes
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirAnnotationContainer
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationContainer
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirConstExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack
|
||||
import org.jetbrains.kotlin.fir.java.declarations.*
|
||||
import org.jetbrains.kotlin.fir.java.enhancement.*
|
||||
@@ -84,8 +87,8 @@ class JavaClassEnhancementScope(
|
||||
val symbol = FirFieldSymbol(original.callableId)
|
||||
with(firElement) {
|
||||
FirJavaField(
|
||||
this@JavaClassEnhancementScope.session,
|
||||
firElement.psi,
|
||||
this@JavaClassEnhancementScope.session,
|
||||
symbol,
|
||||
name,
|
||||
visibility,
|
||||
@@ -172,8 +175,9 @@ class JavaClassEnhancementScope(
|
||||
val (newTypeRef, newDefaultValue) = newInfo
|
||||
with(valueParameter) {
|
||||
FirValueParameterImpl(
|
||||
this@JavaClassEnhancementScope.session, psi,
|
||||
this.name, newTypeRef,
|
||||
psi, this@JavaClassEnhancementScope.session,
|
||||
newTypeRef, this.name,
|
||||
FirVariableSymbol(this.name),
|
||||
defaultValue ?: newDefaultValue, isCrossinline, isNoinline, isVararg
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
@@ -181,23 +185,31 @@ class JavaClassEnhancementScope(
|
||||
}
|
||||
}
|
||||
}
|
||||
val function: FirMemberFunction<*> = when (firMethod) {
|
||||
val function = when (firMethod) {
|
||||
is FirJavaConstructor -> {
|
||||
val symbol = FirConstructorSymbol(methodId)
|
||||
val status = FirDeclarationStatusImpl(firMethod.visibility, Modality.FINAL).apply {
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isInner = firMethod.isInner
|
||||
}
|
||||
if (firMethod.isPrimary) {
|
||||
FirPrimaryConstructorImpl(
|
||||
this@JavaClassEnhancementScope.session, firMethod.psi, symbol,
|
||||
firMethod.visibility,
|
||||
isExpect = false,
|
||||
isActual = false,
|
||||
isInner = firMethod.isInner,
|
||||
delegatedSelfTypeRef = newReturnTypeRef,
|
||||
delegatedConstructor = null
|
||||
firMethod.psi,
|
||||
this@JavaClassEnhancementScope.session,
|
||||
newReturnTypeRef,
|
||||
null,
|
||||
status,
|
||||
symbol
|
||||
)
|
||||
} else {
|
||||
FirConstructorImpl(
|
||||
this@JavaClassEnhancementScope.session, firMethod.psi, symbol,
|
||||
newReceiverTypeRef, newReturnTypeRef
|
||||
firMethod.psi,
|
||||
this@JavaClassEnhancementScope.session,
|
||||
newReturnTypeRef,
|
||||
newReceiverTypeRef,
|
||||
firMethod.status,
|
||||
symbol
|
||||
)
|
||||
}.apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
@@ -205,21 +217,22 @@ class JavaClassEnhancementScope(
|
||||
this.typeParameters += firMethod.typeParameters
|
||||
}
|
||||
}
|
||||
else -> FirMemberFunctionImpl(
|
||||
this@JavaClassEnhancementScope.session, firMethod.psi,
|
||||
else -> FirSimpleFunctionImpl(
|
||||
firMethod.psi,
|
||||
this@JavaClassEnhancementScope.session,
|
||||
newReturnTypeRef,
|
||||
newReceiverTypeRef,
|
||||
name,
|
||||
firMethod.status,
|
||||
if (!isAccessor) FirNamedFunctionSymbol(methodId)
|
||||
else FirAccessorSymbol(callableId = propertyId!!, accessorId = methodId),
|
||||
name, newReceiverTypeRef, newReturnTypeRef
|
||||
else FirAccessorSymbol(callableId = propertyId!!, accessorId = methodId)
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
this.valueParameters += newValueParameters
|
||||
this.typeParameters += firMethod.typeParameters
|
||||
}
|
||||
}
|
||||
(function as FirAbstractCallableMember<*>).apply {
|
||||
status = firMethod.status as FirDeclarationStatusImpl
|
||||
annotations += firMethod.annotations
|
||||
}
|
||||
function.annotations += firMethod.annotations
|
||||
return function.symbol
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class JavaClassUseSiteScope(
|
||||
substitutor
|
||||
)
|
||||
|
||||
private fun isOverriddenFunCheck(overriddenInJava: FirNamedFunction, base: FirNamedFunction): Boolean {
|
||||
private fun isOverriddenFunCheck(overriddenInJava: FirSimpleFunction, base: FirSimpleFunction): Boolean {
|
||||
val receiverTypeRef = base.receiverTypeRef
|
||||
val baseParameterTypes = listOfNotNull(receiverTypeRef) + base.valueParameters.map { it.returnTypeRef }
|
||||
|
||||
@@ -83,7 +83,7 @@ class JavaClassUseSiteScope(
|
||||
}
|
||||
}
|
||||
|
||||
private fun isOverriddenPropertyCheck(overriddenInJava: FirNamedFunction, base: FirProperty): Boolean {
|
||||
private fun isOverriddenPropertyCheck(overriddenInJava: FirSimpleFunction, base: FirProperty): Boolean {
|
||||
val receiverTypeRef = base.receiverTypeRef
|
||||
if (receiverTypeRef == null) {
|
||||
// TODO: setters
|
||||
|
||||
+22
-10
@@ -10,20 +10,25 @@ import com.intellij.psi.tree.IElementType
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import org.jetbrains.kotlin.KtNodeType
|
||||
import org.jetbrains.kotlin.KtNodeTypes.*
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.builder.generateResolvedAccessExpression
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameterContainer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirVariable
|
||||
import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirVariableImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.addDefaultBoundIfNecessary
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirBlockImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirCallWithArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirComponentCallImpl
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.DestructuringDeclaration
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.TypeConstraint
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -72,7 +77,7 @@ fun LighterASTNode.isExpression(): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
fun FirTypeParameterContainer.joinTypeParameters(typeConstraints: List<TypeConstraint>) {
|
||||
fun FirTypeParametersOwner.joinTypeParameters(typeConstraints: List<TypeConstraint>) {
|
||||
typeConstraints.forEach { typeConstraint ->
|
||||
this.typeParameters.forEach { typeParameter ->
|
||||
if (typeConstraint.identifier == typeParameter.name.identifier) {
|
||||
@@ -125,11 +130,18 @@ fun generateDestructuringBlock(
|
||||
}
|
||||
val isVar = multiDeclaration.isVar
|
||||
for ((index, entry) in multiDeclaration.entries.withIndex()) {
|
||||
statements += FirVariableImpl(
|
||||
session, null, entry.name,
|
||||
entry.returnTypeRef, isVar,
|
||||
FirComponentCallImpl(null, index + 1, generateResolvedAccessExpression(null, container)),
|
||||
FirVariableSymbol(entry.name) // TODO?
|
||||
statements += FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
entry.returnTypeRef,
|
||||
null,
|
||||
entry.name,
|
||||
FirComponentCallImpl(null, generateResolvedAccessExpression(null, container), index + 1),
|
||||
null,
|
||||
isVar,
|
||||
FirPropertySymbol(CallableId(entry.name)), // TODO?
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||
).apply {
|
||||
annotations += entry.annotations
|
||||
symbol.bind(this)
|
||||
|
||||
+148
-95
@@ -10,10 +10,12 @@ import com.intellij.psi.TokenType
|
||||
import com.intellij.util.diff.FlyweightCapableTreeStructure
|
||||
import org.jetbrains.kotlin.KtNodeTypes.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.NAME_FOR_DEFAULT_VALUE_PARAMETER
|
||||
import org.jetbrains.kotlin.fir.builder.Context
|
||||
import org.jetbrains.kotlin.fir.builder.generateAccessorsByDelegate
|
||||
import org.jetbrains.kotlin.fir.builder.generateComponentFunctions
|
||||
@@ -28,6 +30,7 @@ import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeModifier
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeParameterModifier
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.TypeProjectionModifier
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.FirDelegatedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||
@@ -76,8 +79,8 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
val firFile = FirFileImpl(
|
||||
session,
|
||||
null,
|
||||
session,
|
||||
fileName,
|
||||
context.packageFqName
|
||||
)
|
||||
@@ -358,20 +361,25 @@ class DeclarationsConverter(
|
||||
val isLocal = isClassLocal(classNode) { getParent() }
|
||||
|
||||
return withChildClassName(className) {
|
||||
val firClass = FirClassImpl(
|
||||
session,
|
||||
null,
|
||||
FirClassSymbol(context.currentClassId),
|
||||
className,
|
||||
val status = FirDeclarationStatusImpl(
|
||||
if (isLocal) Visibilities.LOCAL else modifiers.getVisibility(),
|
||||
modifiers.getModality(),
|
||||
modifiers.hasExpect(),
|
||||
modifiers.hasActual(),
|
||||
classKind,
|
||||
isInner = modifiers.isInner(),
|
||||
isCompanion = modifiers.isCompanion() && classKind == ClassKind.OBJECT,
|
||||
isData = modifiers.isDataClass() && classKind != ClassKind.OBJECT,
|
||||
modifiers.getModality()
|
||||
).apply {
|
||||
isExpect = modifiers.hasExpect()
|
||||
isActual = modifiers.hasActual()
|
||||
isInner = modifiers.isInner()
|
||||
isCompanion = modifiers.isCompanion() && classKind == ClassKind.OBJECT
|
||||
isData = modifiers.isDataClass() && classKind != ClassKind.OBJECT
|
||||
isInline = modifiers.hasInline()
|
||||
}
|
||||
val firClass = FirClassImpl(
|
||||
null,
|
||||
session,
|
||||
className,
|
||||
status,
|
||||
classKind,
|
||||
FirClassSymbol(context.currentClassId)
|
||||
|
||||
)
|
||||
firClass.annotations += modifiers.annotations
|
||||
firClass.typeParameters += firTypeParameters
|
||||
@@ -446,7 +454,7 @@ class DeclarationsConverter(
|
||||
superTypeRefs.ifEmpty { superTypeRefs += implicitAnyType }
|
||||
val delegatedType = delegatedSuperTypeRef ?: implicitAnyType
|
||||
|
||||
return FirAnonymousObjectImpl(null).apply {
|
||||
return FirAnonymousObjectImpl(null, session).apply {
|
||||
annotations += modifiers.annotations
|
||||
this.superTypeRefs += superTypeRefs
|
||||
this.typeRef = superTypeRefs.first()
|
||||
@@ -493,10 +501,10 @@ class DeclarationsConverter(
|
||||
val enumEntryName = identifier.nameAsSafeName()
|
||||
return withChildClassName(enumEntryName) {
|
||||
val firEnumEntry = FirEnumEntryImpl(
|
||||
session,
|
||||
null,
|
||||
FirClassSymbol(context.currentClassId),
|
||||
enumEntryName
|
||||
session,
|
||||
enumEntryName,
|
||||
FirClassSymbol(context.currentClassId)
|
||||
)
|
||||
firEnumEntry.annotations += modifiers.annotations
|
||||
|
||||
@@ -581,21 +589,28 @@ class DeclarationsConverter(
|
||||
isThis = false
|
||||
).extractArgumentsFrom(classWrapper.superTypeCallEntry, stubMode)
|
||||
|
||||
val status = FirDeclarationStatusImpl(
|
||||
if (primaryConstructor != null) modifiers.getVisibility() else defaultVisibility,
|
||||
Modality.FINAL
|
||||
).apply {
|
||||
isExpect = modifiers.hasExpect()
|
||||
isActual = modifiers.hasActual()
|
||||
isInner = classWrapper.isInner()
|
||||
}
|
||||
|
||||
return PrimaryConstructor(
|
||||
FirPrimaryConstructorImpl(
|
||||
session,
|
||||
null,
|
||||
FirConstructorSymbol(callableIdForClassConstructor()),
|
||||
if (primaryConstructor != null) modifiers.getVisibility() else defaultVisibility,
|
||||
modifiers.hasExpect(),
|
||||
modifiers.hasActual(),
|
||||
classWrapper.isInner(),
|
||||
session,
|
||||
classWrapper.delegatedSelfTypeRef,
|
||||
firDelegatedCall
|
||||
null,
|
||||
status,
|
||||
FirConstructorSymbol(callableIdForClassConstructor())
|
||||
).apply {
|
||||
annotations += modifiers.annotations
|
||||
this.typeParameters += typeParametersFromSelfType(classWrapper.delegatedSelfTypeRef)
|
||||
this.valueParameters += valueParameters.map { it.firValueParameter }
|
||||
this.delegatedConstructor = firDelegatedCall
|
||||
}, valueParameters
|
||||
)
|
||||
}
|
||||
@@ -613,8 +628,8 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
return FirAnonymousInitializerImpl(
|
||||
session,
|
||||
null,
|
||||
session,
|
||||
if (stubMode) FirEmptyExpressionBlock() else firBlock
|
||||
)
|
||||
}
|
||||
@@ -641,17 +656,22 @@ class DeclarationsConverter(
|
||||
if (classWrapper.isObjectLiteral()) FirErrorTypeRefImpl(null, "Constructor in object")
|
||||
else classWrapper.delegatedSelfTypeRef
|
||||
|
||||
val status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL).apply {
|
||||
isExpect = modifiers.hasExpect()
|
||||
isActual = modifiers.hasActual()
|
||||
isInner = classWrapper.isInner()
|
||||
}
|
||||
|
||||
val firConstructor = FirConstructorImpl(
|
||||
session,
|
||||
null,
|
||||
FirConstructorSymbol(callableIdForClassConstructor()),
|
||||
modifiers.getVisibility(),
|
||||
modifiers.hasExpect(),
|
||||
modifiers.hasActual(),
|
||||
classWrapper.isInner(),
|
||||
session,
|
||||
delegatedSelfTypeRef,
|
||||
constructorDelegationCall
|
||||
)
|
||||
null,
|
||||
status,
|
||||
FirConstructorSymbol(callableIdForClassConstructor())
|
||||
).apply {
|
||||
delegatedConstructor = constructorDelegationCall
|
||||
}
|
||||
|
||||
context.firFunctions += firConstructor
|
||||
firConstructor.annotations += modifiers.annotations
|
||||
@@ -716,15 +736,17 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
val typeAliasName = identifier.nameAsSafeName()
|
||||
val status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL).apply {
|
||||
isExpect = modifiers.hasExpect()
|
||||
isActual = modifiers.hasActual()
|
||||
}
|
||||
return withChildClassName(typeAliasName) {
|
||||
return@withChildClassName FirTypeAliasImpl(
|
||||
session,
|
||||
null,
|
||||
FirTypeAliasSymbol(context.currentClassId),
|
||||
session,
|
||||
typeAliasName,
|
||||
modifiers.getVisibility(),
|
||||
modifiers.hasExpect(),
|
||||
modifiers.hasActual(),
|
||||
status,
|
||||
FirTypeAliasSymbol(context.currentClassId),
|
||||
firType
|
||||
).apply {
|
||||
annotations += modifiers.annotations
|
||||
@@ -772,51 +794,57 @@ class DeclarationsConverter(
|
||||
val parentNode = property.getParent()
|
||||
val isLocal = !(parentNode?.tokenType == KT_FILE || parentNode?.tokenType == CLASS_BODY)
|
||||
return if (isLocal) {
|
||||
FirVariableImpl(
|
||||
FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
returnType,
|
||||
null,
|
||||
propertyName,
|
||||
returnType,
|
||||
isVar,
|
||||
firExpression,
|
||||
delegate = delegateExpression?.let {
|
||||
delegateExpression?.let {
|
||||
FirWrappedDelegateExpressionImpl(
|
||||
null, expressionConverter.getAsFirExpression(it, "Incorrect delegate expression")
|
||||
)
|
||||
}
|
||||
},
|
||||
isVar,
|
||||
FirPropertySymbol(CallableId(propertyName)),
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||
).apply {
|
||||
annotations += modifiers.annotations
|
||||
this.generateAccessorsByDelegate(this@DeclarationsConverter.session, member = false, stubMode = stubMode)
|
||||
}
|
||||
} else {
|
||||
FirMemberPropertyImpl(
|
||||
session,
|
||||
val status = FirDeclarationStatusImpl(modifiers.getVisibility(), modifiers.getModality()).apply {
|
||||
isExpect = modifiers.hasExpect()
|
||||
isActual = modifiers.hasActual()
|
||||
isOverride = modifiers.hasOverride()
|
||||
isConst = modifiers.isConst()
|
||||
isLateInit = modifiers.hasLateinit()
|
||||
}
|
||||
FirPropertyImpl(
|
||||
null,
|
||||
FirPropertySymbol(callableIdForName(propertyName)),
|
||||
propertyName,
|
||||
modifiers.getVisibility(),
|
||||
modifiers.getModality(),
|
||||
modifiers.hasExpect(),
|
||||
modifiers.hasActual(),
|
||||
modifiers.hasOverride(),
|
||||
modifiers.isConst(),
|
||||
modifiers.hasLateinit(),
|
||||
receiverType,
|
||||
session,
|
||||
returnType,
|
||||
isVar,
|
||||
receiverType,
|
||||
propertyName,
|
||||
firExpression,
|
||||
delegateExpression?.let {
|
||||
FirWrappedDelegateExpressionImpl(
|
||||
null,
|
||||
expressionConverter.getAsFirExpression(it, "Should have delegate")
|
||||
)
|
||||
}
|
||||
},
|
||||
isVar,
|
||||
FirPropertySymbol(callableIdForName(propertyName)),
|
||||
false,
|
||||
status
|
||||
).apply {
|
||||
this.typeParameters += firTypeParameters
|
||||
this.joinTypeParameters(typeConstraints)
|
||||
annotations += modifiers.annotations
|
||||
this.getter = getter ?: FirDefaultPropertyGetter(session, null, returnType, modifiers.getVisibility())
|
||||
this.setter = if (isVar) setter ?: FirDefaultPropertySetter(session, null, returnType, modifiers.getVisibility()) else null
|
||||
this.getter = getter ?: FirDefaultPropertyGetter(null, session, returnType, modifiers.getVisibility())
|
||||
this.setter = if (isVar) setter ?: FirDefaultPropertySetter(null, session, returnType, modifiers.getVisibility()) else null
|
||||
generateAccessorsByDelegate(
|
||||
this@DeclarationsConverter.session, member = parentNode?.tokenType != KT_FILE, stubMode = stubMode
|
||||
)
|
||||
@@ -858,8 +886,19 @@ class DeclarationsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
return FirVariableImpl(
|
||||
session, null, identifier.nameAsSafeName(), firType ?: implicitType, false, null
|
||||
val name = identifier.nameAsSafeName()
|
||||
return FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
firType ?: implicitType,
|
||||
null,
|
||||
name,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
FirPropertySymbol(CallableId(name)),
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||
).apply {
|
||||
annotations += modifiers.annotations
|
||||
}
|
||||
@@ -872,7 +911,12 @@ class DeclarationsConverter(
|
||||
var modifiers = Modifier()
|
||||
var isGetter = true
|
||||
var returnType: FirTypeRef? = null
|
||||
var firValueParameters: FirValueParameter = FirDefaultSetterValueParameter(session, null, propertyTypeRef)
|
||||
var firValueParameters: FirValueParameter = FirDefaultSetterValueParameter(
|
||||
null,
|
||||
session,
|
||||
propertyTypeRef,
|
||||
FirVariableSymbol(NAME_FOR_DEFAULT_VALUE_PARAMETER)
|
||||
)
|
||||
var block: LighterASTNode? = null
|
||||
var expression: LighterASTNode? = null
|
||||
getterOrSetter.forEachChildren {
|
||||
@@ -887,13 +931,15 @@ class DeclarationsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
val status = FirDeclarationStatusImpl(modifiers.getVisibility(), Modality.FINAL)
|
||||
|
||||
val firAccessor = FirPropertyAccessorImpl(
|
||||
session,
|
||||
null,
|
||||
isGetter,
|
||||
modifiers.getVisibility(),
|
||||
session,
|
||||
returnType ?: if (isGetter) propertyTypeRef else implicitUnitType,
|
||||
FirPropertyAccessorSymbol()
|
||||
FirPropertyAccessorSymbol(),
|
||||
isGetter,
|
||||
status
|
||||
)
|
||||
context.firFunctions += firAccessor
|
||||
firAccessor.annotations += modifiers.annotations
|
||||
@@ -924,10 +970,11 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
return FirValueParameterImpl(
|
||||
session,
|
||||
null,
|
||||
firValueParameter.name,
|
||||
session,
|
||||
if (firValueParameter.returnTypeRef == implicitType) propertyTypeRef else firValueParameter.returnTypeRef,
|
||||
firValueParameter.name,
|
||||
FirVariableSymbol(firValueParameter.name),
|
||||
firValueParameter.defaultValue,
|
||||
isCrossinline = modifiers.hasCrossinline() || firValueParameter.isCrossinline,
|
||||
isNoinline = modifiers.hasNoinline() || firValueParameter.isNoinline,
|
||||
@@ -976,34 +1023,38 @@ class DeclarationsConverter(
|
||||
val parentNode = functionDeclaration.getParent()
|
||||
val isLocal = !(parentNode?.tokenType == KT_FILE || parentNode?.tokenType == CLASS_BODY)
|
||||
val firFunction = if (identifier == null) {
|
||||
FirAnonymousFunctionImpl(session, null, returnType!!, receiverType, FirAnonymousFunctionSymbol())
|
||||
FirAnonymousFunctionImpl(null, session, returnType!!, receiverType, FirAnonymousFunctionSymbol())
|
||||
} else {
|
||||
val functionName = identifier.nameAsSafeName()
|
||||
FirMemberFunctionImpl(
|
||||
session,
|
||||
null,
|
||||
FirNamedFunctionSymbol(callableIdForName(functionName, isLocal)),
|
||||
functionName,
|
||||
val status = FirDeclarationStatusImpl(
|
||||
if (isLocal) Visibilities.LOCAL else modifiers.getVisibility(),
|
||||
modifiers.getModality(),
|
||||
modifiers.hasExpect(),
|
||||
modifiers.hasActual(),
|
||||
modifiers.hasOverride(),
|
||||
modifiers.hasOperator(),
|
||||
modifiers.hasInfix(),
|
||||
modifiers.hasInline(),
|
||||
modifiers.hasTailrec(),
|
||||
modifiers.hasExternal(),
|
||||
modifiers.hasSuspend(),
|
||||
modifiers.getModality()
|
||||
).apply {
|
||||
isExpect = modifiers.hasExpect()
|
||||
isActual = modifiers.hasActual()
|
||||
isOverride = modifiers.hasOverride()
|
||||
isOperator = modifiers.hasOperator()
|
||||
isInfix = modifiers.hasInfix()
|
||||
isInline = modifiers.hasInline()
|
||||
isTailRec = modifiers.hasTailrec()
|
||||
isExternal = modifiers.hasExternal()
|
||||
isSuspend = modifiers.hasSuspend()
|
||||
}
|
||||
FirSimpleFunctionImpl(
|
||||
null,
|
||||
session,
|
||||
returnType!!,
|
||||
receiverType,
|
||||
returnType!!
|
||||
functionName,
|
||||
status,
|
||||
FirNamedFunctionSymbol(callableIdForName(functionName, isLocal))
|
||||
)
|
||||
}
|
||||
|
||||
context.firFunctions += firFunction
|
||||
firFunction.annotations += modifiers.annotations
|
||||
|
||||
if (firFunction is FirMemberFunctionImpl) {
|
||||
if (firFunction is FirSimpleFunctionImpl) {
|
||||
firFunction.typeParameters += firTypeParameters
|
||||
firFunction.joinTypeParameters(typeConstraints)
|
||||
}
|
||||
@@ -1112,8 +1163,8 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
return FirDelegatedTypeRefImpl(
|
||||
firTypeRef,
|
||||
firExpression
|
||||
firExpression,
|
||||
firTypeRef
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1175,10 +1226,10 @@ class DeclarationsConverter(
|
||||
}
|
||||
|
||||
val firTypeParameter = FirTypeParameterImpl(
|
||||
session,
|
||||
null,
|
||||
FirTypeParameterSymbol(),
|
||||
session,
|
||||
identifier.nameAsSafeName(),
|
||||
FirTypeParameterSymbol(),
|
||||
typeParameterModifiers.getVariance(),
|
||||
typeParameterModifiers.hasReified()
|
||||
)
|
||||
@@ -1211,7 +1262,7 @@ class DeclarationsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
return firType.also { (it as FirAbstractAnnotatedTypeRef).annotations += typeModifiers.annotations }
|
||||
return firType.also { (it.annotations as MutableList<FirAnnotationCall>) += typeModifiers.annotations }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1307,8 +1358,8 @@ class DeclarationsConverter(
|
||||
return if (isStarProjection) FirStarProjectionImpl(null)
|
||||
else FirTypeProjectionWithVarianceImpl(
|
||||
null,
|
||||
modifiers.getVariance(),
|
||||
firType
|
||||
firType,
|
||||
modifiers.getVariance()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1369,11 +1420,13 @@ class DeclarationsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
val name = identifier.nameAsSafeName()
|
||||
val firValueParameter = FirValueParameterImpl(
|
||||
session,
|
||||
null,
|
||||
identifier.nameAsSafeName(),
|
||||
session,
|
||||
firType ?: implicitType,
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
firExpression,
|
||||
isCrossinline = modifiers.hasCrossinline(),
|
||||
isNoinline = modifiers.hasNoinline(),
|
||||
|
||||
+57
-28
@@ -9,25 +9,34 @@ import com.intellij.lang.LighterASTNode
|
||||
import com.intellij.psi.TokenType
|
||||
import com.intellij.util.diff.FlyweightCapableTreeStructure
|
||||
import org.jetbrains.kotlin.KtNodeTypes.*
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirWhenSubject
|
||||
import org.jetbrains.kotlin.fir.builder.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirVariable
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirVariableImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.labels.FirLabelImpl
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.impl.FirLabelImpl
|
||||
import org.jetbrains.kotlin.fir.lightTree.LightTree2Fir
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.ValueParameter
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.WhenEntry
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirExplicitSuperReference
|
||||
import org.jetbrains.kotlin.fir.references.FirExplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirExplicitSuperReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl
|
||||
@@ -116,16 +125,23 @@ class ExpressionsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
return FirAnonymousFunctionImpl(session, null, implicitType, implicitType, FirAnonymousFunctionSymbol()).apply {
|
||||
return FirAnonymousFunctionImpl(null, session, implicitType, implicitType, FirAnonymousFunctionSymbol()).apply {
|
||||
context.firFunctions += this
|
||||
var destructuringBlock: FirExpression? = null
|
||||
for (valueParameter in valueParameterList) {
|
||||
val multiDeclaration = valueParameter.destructuringDeclaration
|
||||
valueParameters += if (multiDeclaration != null) {
|
||||
val name = Name.special("<destruct>")
|
||||
val multiParameter = FirValueParameterImpl(
|
||||
this@ExpressionsConverter.session, null, Name.special("<destruct>"),
|
||||
null,
|
||||
this@ExpressionsConverter.session,
|
||||
FirImplicitTypeRefImpl(null),
|
||||
defaultValue = null, isCrossinline = false, isNoinline = false, isVararg = false
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
defaultValue = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isVararg = false
|
||||
)
|
||||
destructuringBlock = generateDestructuringBlock(
|
||||
this@ExpressionsConverter.session,
|
||||
@@ -205,7 +221,7 @@ class ExpressionsConverter(
|
||||
return if (conventionCallName != null || operationToken == IDENTIFIER) {
|
||||
FirFunctionCallImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(
|
||||
null, conventionCallName ?: operationTokenName.nameAsSafeName()
|
||||
null, conventionCallName ?: operationTokenName.nameAsSafeName(), null
|
||||
)
|
||||
explicitReceiver = getAsFirExpression(leftArgNode, "No left operand")
|
||||
arguments += rightArgAsFir
|
||||
@@ -303,7 +319,7 @@ class ExpressionsConverter(
|
||||
) { getAsFirExpression(this) }
|
||||
}
|
||||
FirFunctionCallImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(null, conventionCallName)
|
||||
calleeReference = FirSimpleNamedReference(null, conventionCallName, null)
|
||||
explicitReceiver = getAsFirExpression(argument, "No operand")
|
||||
}
|
||||
} else {
|
||||
@@ -401,10 +417,9 @@ class ExpressionsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
//TODO use contracts?
|
||||
if (firSelector is FirModifiableQualifiedAccess<*>) {
|
||||
(firSelector as FirModifiableQualifiedAccess<*>).safe = isSafe
|
||||
(firSelector as FirModifiableQualifiedAccess<*>).explicitReceiver = firReceiver
|
||||
(firSelector as? FirModifiableQualifiedAccess)?.let {
|
||||
it.safe = isSafe
|
||||
it.explicitReceiver = firReceiver
|
||||
}
|
||||
return firSelector
|
||||
}
|
||||
@@ -429,12 +444,12 @@ class ExpressionsConverter(
|
||||
|
||||
return FirFunctionCallImpl(null).apply {
|
||||
this.calleeReference = when {
|
||||
name != null -> FirSimpleNamedReference(null, name.nameAsSafeName())
|
||||
name != null -> FirSimpleNamedReference(null, name.nameAsSafeName(), null)
|
||||
additionalArgument != null -> {
|
||||
arguments += additionalArgument!!
|
||||
FirSimpleNamedReference(null, OperatorNameConventions.INVOKE)
|
||||
FirSimpleNamedReference(null, OperatorNameConventions.INVOKE, null)
|
||||
}
|
||||
else -> FirErrorNamedReference(null, "Call has no callee")
|
||||
else -> FirErrorNamedReferenceImpl(null, "Call has no callee")
|
||||
}
|
||||
|
||||
context.firFunctionCalls += this
|
||||
@@ -477,9 +492,18 @@ class ExpressionsConverter(
|
||||
whenExpression.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
PROPERTY -> subjectVariable = (declarationsConverter.convertPropertyDeclaration(it) as FirVariable<*>).let { variable ->
|
||||
FirVariableImpl(
|
||||
session, null, variable.name, variable.returnTypeRef,
|
||||
isVar = false, initializer = variable.initializer
|
||||
FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
variable.returnTypeRef,
|
||||
null,
|
||||
variable.name,
|
||||
variable.initializer,
|
||||
null,
|
||||
false,
|
||||
FirPropertySymbol(CallableId(variable.name)),
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||
)
|
||||
}
|
||||
DESTRUCTURING_DECLARATION -> subjectExpression =
|
||||
@@ -568,7 +592,7 @@ class ExpressionsConverter(
|
||||
|
||||
val name = if (isNegate) OperatorNameConventions.NOT else SpecialNames.NO_NAME_PROVIDED
|
||||
return FirFunctionCallImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(null, name)
|
||||
calleeReference = FirSimpleNamedReference(null, name, null)
|
||||
explicitReceiver = firExpression
|
||||
}
|
||||
}
|
||||
@@ -601,7 +625,7 @@ class ExpressionsConverter(
|
||||
}
|
||||
}
|
||||
return FirFunctionCallImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(null, OperatorNameConventions.GET)
|
||||
calleeReference = FirSimpleNamedReference(null, OperatorNameConventions.GET, null)
|
||||
explicitReceiver = firExpression
|
||||
arguments += indices
|
||||
}
|
||||
@@ -640,7 +664,7 @@ class ExpressionsConverter(
|
||||
private fun convertSimpleNameExpression(referenceExpression: LighterASTNode): FirQualifiedAccessExpression {
|
||||
return FirQualifiedAccessExpressionImpl(null).apply {
|
||||
calleeReference =
|
||||
FirSimpleNamedReference(null, referenceExpression.asText.nameAsSafeName())
|
||||
FirSimpleNamedReference(null, referenceExpression.asText.nameAsSafeName(), null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,7 +725,7 @@ class ExpressionsConverter(
|
||||
val iteratorVal = generateTemporaryVariable(
|
||||
this@ExpressionsConverter.session, null, Name.special("<iterator>"),
|
||||
FirFunctionCallImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(null, Name.identifier("iterator"))
|
||||
calleeReference = FirSimpleNamedReference(null, Name.identifier("iterator"), null)
|
||||
explicitReceiver = generateResolvedAccessExpression(null, rangeVal)
|
||||
}
|
||||
)
|
||||
@@ -709,7 +733,7 @@ class ExpressionsConverter(
|
||||
statements += FirWhileLoopImpl(
|
||||
null,
|
||||
FirFunctionCallImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(null, Name.identifier("hasNext"))
|
||||
calleeReference = FirSimpleNamedReference(null, Name.identifier("hasNext"), null)
|
||||
explicitReceiver = generateResolvedAccessExpression(null, iteratorVal)
|
||||
}
|
||||
).configure {
|
||||
@@ -723,7 +747,7 @@ class ExpressionsConverter(
|
||||
this@ExpressionsConverter.session, null,
|
||||
if (multiDeclaration != null) Name.special("<destruct>") else parameter!!.firValueParameter.name,
|
||||
FirFunctionCallImpl(null).apply {
|
||||
calleeReference = FirSimpleNamedReference(null, Name.identifier("next"))
|
||||
calleeReference = FirSimpleNamedReference(null, Name.identifier("next"), null)
|
||||
explicitReceiver = generateResolvedAccessExpression(null, iteratorVal)
|
||||
}
|
||||
)
|
||||
@@ -838,7 +862,7 @@ class ExpressionsConverter(
|
||||
}
|
||||
}
|
||||
|
||||
return FirWhenExpressionImpl(null).apply {
|
||||
return FirWhenExpressionImpl(null, null, null).apply {
|
||||
val trueBranch = convertLoopBody(thenBlock)
|
||||
branches += FirWhenBranchImpl(null, firCondition, trueBranch)
|
||||
val elseBranch = convertLoopBody(elseBlock)
|
||||
@@ -953,7 +977,12 @@ class ExpressionsConverter(
|
||||
}
|
||||
}
|
||||
return when {
|
||||
identifier != null -> FirNamedArgumentExpressionImpl(null, identifier.nameAsSafeName(), isSpread, firExpression)
|
||||
identifier != null -> FirNamedArgumentExpressionImpl(
|
||||
null,
|
||||
firExpression,
|
||||
isSpread,
|
||||
identifier.nameAsSafeName()
|
||||
)
|
||||
isSpread -> FirSpreadArgumentExpressionImpl(null, firExpression)
|
||||
else -> firExpression
|
||||
}
|
||||
|
||||
+1
-1
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.fir.lightTree.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.builder.generateTemporaryVariable
|
||||
import org.jetbrains.kotlin.fir.declarations.FirVariable
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
||||
import org.jetbrains.kotlin.fir.lightTree.converter.generateDestructuringBlock
|
||||
|
||||
data class DestructuringDeclaration(
|
||||
|
||||
+2
-2
@@ -5,9 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.lightTree.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirConstructorImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
|
||||
data class PrimaryConstructor(
|
||||
val firConstructor: FirConstructorImpl,
|
||||
val firConstructor: FirConstructor,
|
||||
val valueParameters: List<ValueParameter>
|
||||
)
|
||||
+22
-24
@@ -8,17 +8,12 @@ package org.jetbrains.kotlin.fir.lightTree.fir
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirMemberPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirQualifiedAccessExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.Modifier
|
||||
import org.jetbrains.kotlin.fir.references.FirPropertyFromParameterCallableReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterCallableReference
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.types.FirErrorTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
||||
|
||||
@@ -40,31 +35,34 @@ class ValueParameter(
|
||||
type = FirErrorTypeRefImpl(null, "Incomplete code")
|
||||
}
|
||||
|
||||
return FirMemberPropertyImpl(
|
||||
session,
|
||||
val status = FirDeclarationStatusImpl(modifiers.getVisibility(), modifiers.getModality()).apply {
|
||||
isExpect = modifiers.hasExpect()
|
||||
isActual = modifiers.hasActual()
|
||||
isOverride = modifiers.hasOverride()
|
||||
isConst = false
|
||||
isLateInit = false
|
||||
}
|
||||
|
||||
return FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
type,
|
||||
null,
|
||||
FirPropertySymbol(callableId),
|
||||
name,
|
||||
modifiers.getVisibility(),
|
||||
modifiers.getModality(),
|
||||
modifiers.hasExpect(),
|
||||
modifiers.hasActual(),
|
||||
isOverride = modifiers.hasOverride(),
|
||||
isConst = false,
|
||||
isLateInit = false,
|
||||
receiverTypeRef = null,
|
||||
returnTypeRef = type,
|
||||
isVar = this.isVar,
|
||||
initializer = FirQualifiedAccessExpressionImpl(null).apply {
|
||||
FirQualifiedAccessExpressionImpl(null).apply {
|
||||
calleeReference = FirPropertyFromParameterCallableReference(
|
||||
null, name, this@ValueParameter.firValueParameter.symbol
|
||||
)
|
||||
},
|
||||
delegate = null
|
||||
null,
|
||||
this.isVar,
|
||||
FirPropertySymbol(callableId),
|
||||
false,
|
||||
status
|
||||
).apply {
|
||||
annotations += this@ValueParameter.firValueParameter.annotations
|
||||
getter = FirDefaultPropertyGetter(session, null, type, modifiers.getVisibility())
|
||||
setter = if (this.isVar) FirDefaultPropertySetter(session, null, type, modifiers.getVisibility()) else null
|
||||
getter = FirDefaultPropertyGetter(null, session, type, modifiers.getVisibility())
|
||||
setter = if (this.isVar) FirDefaultPropertySetter(null, session, type, modifiers.getVisibility()) else null
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -10,7 +10,8 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.CLASS_MODIFIER
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.FUNCTION_MODIFIER
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.INHERITANCE_MODIFIER
|
||||
@@ -21,7 +22,7 @@ import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.PROPERTY_MOD
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.VISIBILITY_MODIFIER
|
||||
|
||||
class Modifier(
|
||||
psi: PsiElement? = null,
|
||||
override val psi: PsiElement? = null,
|
||||
private val classModifiers: MutableList<ClassModifier> = mutableListOf(),
|
||||
private val memberModifiers: MutableList<MemberModifier> = mutableListOf(),
|
||||
private val visibilityModifiers: MutableList<VisibilityModifier> = mutableListOf(),
|
||||
@@ -30,7 +31,9 @@ class Modifier(
|
||||
private val inheritanceModifiers: MutableList<InheritanceModifier> = mutableListOf(),
|
||||
private val parameterModifiers: MutableList<ParameterModifier> = mutableListOf(),
|
||||
private val platformModifiers: MutableList<PlatformModifier> = mutableListOf()
|
||||
) : FirAbstractAnnotatedElement(psi) {
|
||||
) : FirAbstractAnnotatedElement {
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
|
||||
fun addModifier(modifier: LighterASTNode) {
|
||||
val tokenType = modifier.tokenType
|
||||
when {
|
||||
|
||||
+6
-3
@@ -7,13 +7,16 @@ package org.jetbrains.kotlin.fir.lightTree.fir.modifier
|
||||
|
||||
import com.intellij.lang.LighterASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
|
||||
class TypeModifier(
|
||||
psi: PsiElement? = null,
|
||||
override val psi: PsiElement? = null,
|
||||
var hasSuspend: Boolean = false
|
||||
) : FirAbstractAnnotatedElement(psi) {
|
||||
) : FirAbstractAnnotatedElement {
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
|
||||
fun addModifier(modifier: LighterASTNode) {
|
||||
when (modifier.tokenType) {
|
||||
KtTokens.SUSPEND_KEYWORD -> this.hasSuspend = true
|
||||
|
||||
+6
-4
@@ -7,17 +7,19 @@ package org.jetbrains.kotlin.fir.lightTree.fir.modifier
|
||||
|
||||
import com.intellij.lang.LighterASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.REIFICATION_MODIFIER
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.VARIANCE_MODIFIER
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
class TypeParameterModifier(
|
||||
psi: PsiElement? = null,
|
||||
override val psi: PsiElement? = null,
|
||||
private val varianceModifiers: MutableList<VarianceModifier> = mutableListOf(),
|
||||
|
||||
private var reificationModifier: ReificationModifier? = null
|
||||
) : FirAbstractAnnotatedElement(psi) {
|
||||
) : FirAbstractAnnotatedElement {
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
|
||||
fun addModifier(modifier: LighterASTNode) {
|
||||
val tokenType = modifier.tokenType
|
||||
when {
|
||||
|
||||
+6
-3
@@ -7,14 +7,17 @@ package org.jetbrains.kotlin.fir.lightTree.fir.modifier
|
||||
|
||||
import com.intellij.lang.LighterASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.lightTree.fir.modifier.ModifierSets.VARIANCE_MODIFIER
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
class TypeProjectionModifier(
|
||||
psi: PsiElement? = null,
|
||||
override val psi: PsiElement? = null,
|
||||
private val varianceModifiers: MutableList<VarianceModifier> = mutableListOf()
|
||||
) : FirAbstractAnnotatedElement(psi) {
|
||||
) : FirAbstractAnnotatedElement {
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
|
||||
fun addModifier(modifier: LighterASTNode) {
|
||||
val tokenType = modifier.tokenType
|
||||
when {
|
||||
|
||||
@@ -10,22 +10,18 @@ import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.KtNodeTypes.*
|
||||
import org.jetbrains.kotlin.fir.FirFunctionTarget
|
||||
import org.jetbrains.kotlin.fir.FirLoopTarget
|
||||
import org.jetbrains.kotlin.fir.FirReference
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirErrorFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirErrorLoop
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirErrorFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.addDefaultBoundIfNecessary
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirExplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirErrorFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeTypeParameterType
|
||||
@@ -112,7 +108,14 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
if (lastFunction != null) {
|
||||
target.bind(lastFunction)
|
||||
} else {
|
||||
target.bind(FirErrorFunction(this@BaseFirBuilder.session, psi, "Cannot bind unlabeled return to a function"))
|
||||
target.bind(
|
||||
FirErrorFunctionImpl(
|
||||
psi,
|
||||
this@BaseFirBuilder.session,
|
||||
"Cannot bind unlabeled return to a function",
|
||||
FirErrorFunctionSymbol()
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
for (firFunction in context.firFunctions.asReversed()) {
|
||||
@@ -123,7 +126,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
return@apply
|
||||
}
|
||||
}
|
||||
is FirNamedFunction -> {
|
||||
is FirMemberFunction<*> -> {
|
||||
if (firFunction.name.asString() == labelName) {
|
||||
target.bind(firFunction)
|
||||
return@apply
|
||||
@@ -131,14 +134,21 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
}
|
||||
}
|
||||
}
|
||||
target.bind(FirErrorFunction(this@BaseFirBuilder.session, psi, "Cannot bind label $labelName to a function"))
|
||||
target.bind(
|
||||
FirErrorFunctionImpl(
|
||||
psi,
|
||||
this@BaseFirBuilder.session,
|
||||
"Cannot bind label $labelName to a function",
|
||||
FirErrorFunctionSymbol()
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun KtClassOrObject?.toDelegatedSelfType(firClass: FirRegularClass): FirTypeRef {
|
||||
val typeParameters = firClass.typeParameters.map {
|
||||
FirTypeParameterImpl(session, it.psi, FirTypeParameterSymbol(), it.name, Variance.INVARIANT, false).apply {
|
||||
FirTypeParameterImpl(it.psi, session, it.name, FirTypeParameterSymbol(), Variance.INVARIANT, false).apply {
|
||||
this.bounds += it.bounds
|
||||
addDefaultBoundIfNecessary()
|
||||
}
|
||||
@@ -165,7 +175,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
session,
|
||||
FirThrowExpressionImpl(
|
||||
parent.getPsiOrNull(), FirFunctionCallImpl(parent.getPsiOrNull()).apply {
|
||||
calleeReference = FirSimpleNamedReference(parent, KNPE)
|
||||
calleeReference = FirSimpleNamedReference(parent, KNPE, null)
|
||||
}
|
||||
), "bangbang", parent
|
||||
)
|
||||
@@ -179,7 +189,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
return this
|
||||
}
|
||||
|
||||
fun FirLoopJump.bindLabel(expression: T): FirLoopJump {
|
||||
fun FirAbstractLoopJump.bindLabel(expression: T): FirAbstractLoopJump {
|
||||
val labelName = expression.getLabelName()
|
||||
target = FirLoopTarget(labelName)
|
||||
val lastLoop = context.firLoops.lastOrNull()
|
||||
@@ -252,7 +262,6 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
else ->
|
||||
throw AssertionError("Unknown literal type: $type, $text")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun Array<out T?>.toInterpolatingCall(
|
||||
@@ -343,7 +352,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
statements += temporaryVariable
|
||||
val resultName = Name.special("<unary-result>")
|
||||
val resultInitializer = FirFunctionCallImpl(baseExpression).apply {
|
||||
this.calleeReference = FirSimpleNamedReference(baseExpression?.operationReference, callName)
|
||||
this.calleeReference = FirSimpleNamedReference(baseExpression?.operationReference, callName, null)
|
||||
this.explicitReceiver = generateResolvedAccessExpression(baseExpression, temporaryVariable)
|
||||
}
|
||||
val resultVar = generateTemporaryVariable(this@BaseFirBuilder.session, baseExpression, resultName, resultInitializer)
|
||||
@@ -380,7 +389,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirModifiableQualifiedAccess<*>.initializeLValue(
|
||||
private fun FirModifiableQualifiedAccess.initializeLValue(
|
||||
left: T?,
|
||||
convertQualified: T.() -> FirQualifiedAccess?
|
||||
): FirReference {
|
||||
@@ -388,7 +397,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
if (left != null) {
|
||||
when (tokenType) {
|
||||
REFERENCE_EXPRESSION -> {
|
||||
return FirSimpleNamedReference(left.getPsiOrNull(), left.getReferencedNameAsName())
|
||||
return FirSimpleNamedReference(left.getPsiOrNull(), left.getReferencedNameAsName(), null)
|
||||
}
|
||||
THIS_EXPRESSION -> {
|
||||
return FirExplicitThisReference(left.getPsiOrNull(), left.getLabelName())
|
||||
@@ -400,7 +409,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
safe = firMemberAccess.safe
|
||||
firMemberAccess.calleeReference
|
||||
} else {
|
||||
FirErrorNamedReference(
|
||||
FirErrorNamedReferenceImpl(
|
||||
left.getPsiOrNull(), "Unsupported qualified LValue: ${left.asText}"
|
||||
)
|
||||
}
|
||||
@@ -410,7 +419,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
}
|
||||
}
|
||||
}
|
||||
return FirErrorNamedReference(left.getPsiOrNull(), "Unsupported LValue: $tokenType")
|
||||
return FirErrorNamedReferenceImpl(left.getPsiOrNull(), "Unsupported LValue: $tokenType")
|
||||
}
|
||||
|
||||
fun T?.generateAssignment(
|
||||
@@ -431,7 +440,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
}
|
||||
} else {
|
||||
return firArrayAccess.apply {
|
||||
calleeReference = FirSimpleNamedReference(psi, OperatorNameConventions.SET)
|
||||
calleeReference = FirSimpleNamedReference(psi, OperatorNameConventions.SET, null)
|
||||
arguments += value
|
||||
}
|
||||
}
|
||||
@@ -447,7 +456,7 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
statements += generateTemporaryVariable(
|
||||
this@BaseFirBuilder.session, this@generateAssignment.getPsiOrNull(), name, firArrayAccess.explicitReceiver!!
|
||||
)
|
||||
statements += arraySet.apply { lValue = FirSimpleNamedReference(psiArrayExpression, name) }
|
||||
statements += arraySet.apply { lValue = FirSimpleNamedReference(psiArrayExpression, name, null) }
|
||||
}
|
||||
}
|
||||
if (operation != FirOperation.ASSIGN &&
|
||||
@@ -461,12 +470,12 @@ abstract class BaseFirBuilder<T>(val session: FirSession, val context: Context =
|
||||
this@generateAssignment?.convert()
|
||||
?: FirErrorExpressionImpl(this.getPsiOrNull(), "No LValue in assignment")
|
||||
)
|
||||
statements += FirVariableAssignmentImpl(psi, value, operation).apply {
|
||||
lValue = FirSimpleNamedReference(this.getPsiOrNull(), name)
|
||||
statements += FirVariableAssignmentImpl(psi, false, value, operation).apply {
|
||||
lValue = FirSimpleNamedReference(this.getPsiOrNull(), name, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
return FirVariableAssignmentImpl(psi, value, operation).apply {
|
||||
return FirVariableAssignmentImpl(psi, false, value, operation).apply {
|
||||
lValue = initializeLValue(this@generateAssignment) { convert() as? FirQualifiedAccess }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,21 +7,23 @@ package org.jetbrains.kotlin.fir.builder
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.tree.IElementType
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirFunctionTarget
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirWhenSubject
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirModifiableAccessorsOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyAccessorImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirVariableImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.FirVariable
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.references.FirDelegateFieldReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirExplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirDelegateFieldReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertyAccessorSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeStarProjection
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
@@ -165,9 +167,9 @@ fun FirExpression.generateLazyLogicalOperation(
|
||||
other: FirExpression, isAnd: Boolean, basePsi: KtElement?
|
||||
): FirBinaryLogicExpression {
|
||||
val kind = if (isAnd)
|
||||
FirBinaryLogicExpression.OperationKind.AND
|
||||
LogicOperationKind.AND
|
||||
else
|
||||
FirBinaryLogicExpression.OperationKind.OR
|
||||
LogicOperationKind.OR
|
||||
return FirBinaryLogicExpressionImpl(basePsi, this, other, kind)
|
||||
}
|
||||
|
||||
@@ -231,20 +233,20 @@ fun FirExpression.generateContainsOperation(
|
||||
operationReference: KtOperationReferenceExpression?
|
||||
): FirFunctionCall {
|
||||
val containsCall = FirFunctionCallImpl(base).apply {
|
||||
calleeReference = FirSimpleNamedReference(operationReference, OperatorNameConventions.CONTAINS)
|
||||
calleeReference = FirSimpleNamedReference(operationReference, OperatorNameConventions.CONTAINS, null)
|
||||
explicitReceiver = this@generateContainsOperation
|
||||
arguments += argument
|
||||
}
|
||||
if (!inverted) return containsCall
|
||||
return FirFunctionCallImpl(base).apply {
|
||||
calleeReference = FirSimpleNamedReference(operationReference, OperatorNameConventions.NOT)
|
||||
calleeReference = FirSimpleNamedReference(operationReference, OperatorNameConventions.NOT, null)
|
||||
explicitReceiver = containsCall
|
||||
}
|
||||
}
|
||||
|
||||
fun generateAccessExpression(psi: PsiElement?, name: Name): FirQualifiedAccessExpression =
|
||||
FirQualifiedAccessExpressionImpl(psi).apply {
|
||||
calleeReference = FirSimpleNamedReference(psi, name)
|
||||
calleeReference = FirSimpleNamedReference(psi, name, null)
|
||||
}
|
||||
|
||||
fun generateResolvedAccessExpression(psi: PsiElement?, variable: FirVariable<*>): FirQualifiedAccessExpression =
|
||||
@@ -266,11 +268,18 @@ internal fun generateDestructuringBlock(
|
||||
}
|
||||
val isVar = multiDeclaration.isVar
|
||||
for ((index, entry) in multiDeclaration.entries.withIndex()) {
|
||||
statements += FirVariableImpl(
|
||||
session, entry, entry.nameAsSafeName,
|
||||
entry.typeReference.toFirOrImplicitTypeRef(), isVar,
|
||||
FirComponentCallImpl(entry, index + 1, generateResolvedAccessExpression(entry, container)),
|
||||
FirVariableSymbol(entry.nameAsSafeName) // TODO?
|
||||
statements += FirPropertyImpl(
|
||||
entry,
|
||||
session,
|
||||
entry.typeReference.toFirOrImplicitTypeRef(),
|
||||
null,
|
||||
entry.nameAsSafeName,
|
||||
FirComponentCallImpl(entry, generateResolvedAccessExpression(entry, container), index + 1),
|
||||
null,
|
||||
isVar,
|
||||
FirPropertySymbol(CallableId(entry.nameAsSafeName)), // TODO?
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||
).apply {
|
||||
entry.extractAnnotationsTo(this)
|
||||
symbol.bind(this)
|
||||
@@ -282,7 +291,19 @@ internal fun generateDestructuringBlock(
|
||||
fun generateTemporaryVariable(
|
||||
session: FirSession, psi: PsiElement?, name: Name, initializer: FirExpression
|
||||
): FirVariable<*> =
|
||||
FirVariableImpl(session, psi, name, FirImplicitTypeRefImpl(psi), false, initializer, FirVariableSymbol(name)).apply {
|
||||
FirPropertyImpl(
|
||||
psi,
|
||||
session,
|
||||
FirImplicitTypeRefImpl(psi),
|
||||
null,
|
||||
name,
|
||||
initializer,
|
||||
null,
|
||||
false,
|
||||
FirPropertySymbol(CallableId(name)),
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||
).apply {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@@ -290,15 +311,15 @@ fun generateTemporaryVariable(
|
||||
session: FirSession, psi: PsiElement?, specialName: String, initializer: FirExpression
|
||||
): FirVariable<*> = generateTemporaryVariable(session, psi, Name.special("<$specialName>"), initializer)
|
||||
|
||||
fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: FirSession, member: Boolean, stubMode: Boolean) {
|
||||
fun FirModifiableVariable<*>.generateAccessorsByDelegate(session: FirSession, member: Boolean, stubMode: Boolean) {
|
||||
val variable = this as FirVariable<*>
|
||||
val delegateFieldSymbol = delegateFieldSymbol ?: return
|
||||
val delegate = delegate as? FirWrappedDelegateExpressionImpl ?: return
|
||||
fun delegateAccess() = FirQualifiedAccessExpressionImpl(null).apply {
|
||||
calleeReference = FirDelegateFieldReferenceImpl(null, delegateFieldSymbol)
|
||||
calleeReference = FirDelegateFieldReferenceImpl(null, null, delegateFieldSymbol)
|
||||
}
|
||||
|
||||
fun thisRef() =
|
||||
fun thisRef(): FirExpression =
|
||||
if (member) FirQualifiedAccessExpressionImpl(null).apply {
|
||||
calleeReference = FirExplicitThisReference(null, null)
|
||||
}
|
||||
@@ -311,19 +332,26 @@ fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: FirSession,
|
||||
|
||||
delegate.delegateProvider = if (stubMode) FirExpressionStub(null) else FirFunctionCallImpl(null).apply {
|
||||
explicitReceiver = delegate.expression
|
||||
calleeReference = FirSimpleNamedReference(null, PROVIDE_DELEGATE)
|
||||
calleeReference = FirSimpleNamedReference(null, PROVIDE_DELEGATE, null)
|
||||
arguments += thisRef()
|
||||
arguments += propertyRef()
|
||||
}
|
||||
if (stubMode) return
|
||||
getter = (getter as? FirPropertyAccessorImpl)
|
||||
?: FirPropertyAccessorImpl(session, null, true, Visibilities.UNKNOWN, FirImplicitTypeRefImpl(null), FirPropertyAccessorSymbol()).apply Accessor@{
|
||||
if (getter == null || getter is FirDefaultPropertyAccessor) {
|
||||
getter = FirPropertyAccessorImpl(
|
||||
null,
|
||||
session,
|
||||
FirImplicitTypeRefImpl(null),
|
||||
FirPropertyAccessorSymbol(),
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.UNKNOWN, Modality.FINAL)
|
||||
).apply Accessor@{
|
||||
body = FirSingleExpressionBlock(
|
||||
FirReturnExpressionImpl(
|
||||
null,
|
||||
FirFunctionCallImpl(null).apply {
|
||||
explicitReceiver = delegateAccess()
|
||||
calleeReference = FirSimpleNamedReference(null, GET_VALUE)
|
||||
calleeReference = FirSimpleNamedReference(null, GET_VALUE, null)
|
||||
arguments += thisRef()
|
||||
arguments += propertyRef()
|
||||
}
|
||||
@@ -333,11 +361,19 @@ fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: FirSession,
|
||||
}
|
||||
)
|
||||
}
|
||||
setter = (setter as? FirPropertyAccessorImpl)
|
||||
?: FirPropertyAccessorImpl(session, null, false, Visibilities.UNKNOWN, session.builtinTypes.unitType, FirPropertyAccessorSymbol()).apply {
|
||||
}
|
||||
if (setter == null || setter is FirDefaultPropertyAccessor) {
|
||||
setter = FirPropertyAccessorImpl(
|
||||
null,
|
||||
session,
|
||||
session.builtinTypes.unitType,
|
||||
FirPropertyAccessorSymbol(),
|
||||
false,
|
||||
FirDeclarationStatusImpl(Visibilities.UNKNOWN, Modality.FINAL)
|
||||
).apply {
|
||||
val parameter = FirValueParameterImpl(
|
||||
session, null, DELEGATED_SETTER_PARAM,
|
||||
FirImplicitTypeRefImpl(null),
|
||||
null, session, FirImplicitTypeRefImpl(null),
|
||||
DELEGATED_SETTER_PARAM, FirVariableSymbol(name),
|
||||
defaultValue = null, isCrossinline = false,
|
||||
isNoinline = false, isVararg = false
|
||||
)
|
||||
@@ -345,7 +381,7 @@ fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: FirSession,
|
||||
body = FirSingleExpressionBlock(
|
||||
FirFunctionCallImpl(null).apply {
|
||||
explicitReceiver = delegateAccess()
|
||||
calleeReference = FirSimpleNamedReference(null, SET_VALUE)
|
||||
calleeReference = FirSimpleNamedReference(null, SET_VALUE, null)
|
||||
arguments += thisRef()
|
||||
arguments += propertyRef()
|
||||
arguments += FirQualifiedAccessExpressionImpl(null).apply {
|
||||
@@ -354,6 +390,7 @@ fun FirModifiableAccessorsOwner.generateAccessorsByDelegate(session: FirSession,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val GET_VALUE = Name.identifier("getValue")
|
||||
|
||||
@@ -11,14 +11,17 @@ import org.jetbrains.kotlin.fir.FirFunctionTarget
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.addDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirMemberFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.references.FirImplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirImplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -35,16 +38,21 @@ fun List<Pair<KtParameter?, FirProperty>>.generateComponentFunctions(
|
||||
val name = Name.identifier("component$componentIndex")
|
||||
componentIndex++
|
||||
val symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, name))
|
||||
val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply {
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
isOperator = false
|
||||
isInfix = false
|
||||
isInline = false
|
||||
isTailRec = false
|
||||
isExternal = false
|
||||
isSuspend = false
|
||||
}
|
||||
firClass.addDeclaration(
|
||||
FirMemberFunctionImpl(
|
||||
session, ktParameter, symbol, name,
|
||||
Visibilities.PUBLIC, Modality.FINAL,
|
||||
isExpect = false, isActual = false,
|
||||
isOverride = false, isOperator = false,
|
||||
isInfix = false, isInline = false,
|
||||
isTailRec = false, isExternal = false,
|
||||
isSuspend = false, receiverTypeRef = null,
|
||||
returnTypeRef = FirImplicitTypeRefImpl(ktParameter)
|
||||
FirSimpleFunctionImpl(
|
||||
ktParameter, session, FirImplicitTypeRefImpl(ktParameter),
|
||||
null, name, status, symbol
|
||||
).apply {
|
||||
val componentFunction = this
|
||||
body = FirSingleExpressionBlock(
|
||||
@@ -77,22 +85,33 @@ fun List<Pair<KtParameter?, FirProperty>>.generateCopyFunction(
|
||||
firPrimaryConstructor: FirConstructor
|
||||
) {
|
||||
val symbol = FirNamedFunctionSymbol(CallableId(packageFqName, classFqName, copyName))
|
||||
val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply {
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
isOperator = false
|
||||
isInfix = false
|
||||
isInline = false
|
||||
isTailRec = false
|
||||
isExternal = false
|
||||
isSuspend = false
|
||||
}
|
||||
firClass.addDeclaration(
|
||||
FirMemberFunctionImpl(
|
||||
session, classOrObject, symbol, copyName,
|
||||
Visibilities.PUBLIC, Modality.FINAL,
|
||||
isExpect = false, isActual = false,
|
||||
isOverride = false, isOperator = false,
|
||||
isInfix = false, isInline = false,
|
||||
isTailRec = false, isExternal = false,
|
||||
isSuspend = false, receiverTypeRef = null,
|
||||
returnTypeRef = firPrimaryConstructor.returnTypeRef
|
||||
FirSimpleFunctionImpl(
|
||||
classOrObject,
|
||||
session,
|
||||
firPrimaryConstructor.returnTypeRef,
|
||||
null,
|
||||
copyName,
|
||||
status,
|
||||
symbol
|
||||
).apply {
|
||||
for ((ktParameter, firProperty) in this@generateCopyFunction) {
|
||||
val name = firProperty.name
|
||||
valueParameters += FirValueParameterImpl(
|
||||
session, ktParameter, name,
|
||||
firProperty.returnTypeRef,
|
||||
ktParameter, session, firProperty.returnTypeRef,
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
FirQualifiedAccessExpressionImpl(ktParameter).apply {
|
||||
dispatchReceiver = FirThisReceiverExpressionImpl(null, FirImplicitThisReference(firClass.symbol)).apply {
|
||||
typeRef = firPrimaryConstructor.returnTypeRef
|
||||
@@ -104,29 +123,6 @@ fun List<Pair<KtParameter?, FirProperty>>.generateCopyFunction(
|
||||
}
|
||||
|
||||
body = FirEmptyExpressionBlock()
|
||||
// body = FirSingleExpressionBlock(
|
||||
// session,
|
||||
// FirReturnExpressionImpl(
|
||||
// session, this@generateCopyFunction,
|
||||
// FirFunctionCallImpl(session, this@generateCopyFunction).apply {
|
||||
// calleeReference = FirResolvedCallableReferenceImpl(
|
||||
// session, this@generateCopyFunction, firClass.name,
|
||||
// firPrimaryConstructor.symbol
|
||||
// )
|
||||
// }.apply {
|
||||
// for ((ktParameter, firParameter) in primaryConstructorParameters.zip(valueParameters)) {
|
||||
// this.arguments += FirQualifiedAccessExpressionImpl(session, ktParameter).apply {
|
||||
// calleeReference = FirResolvedCallableReferenceImpl(
|
||||
// session, ktParameter, firParameter.name, firParameter.symbol
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// ).apply {
|
||||
// target = FirFunctionTarget(null)
|
||||
// target.bind(copyFunction)
|
||||
// }
|
||||
// )
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -11,16 +11,15 @@ import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirWhenSubject
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.labels.FirLabelImpl
|
||||
import org.jetbrains.kotlin.fir.references.*
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.impl.FirAbstractAnnotatedElement
|
||||
import org.jetbrains.kotlin.fir.impl.FirLabelImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.*
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
@@ -180,7 +179,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
val isSpread = getSpreadElement() != null
|
||||
return when {
|
||||
name != null -> FirNamedArgumentExpressionImpl(expression, name, isSpread, firExpression)
|
||||
name != null -> FirNamedArgumentExpressionImpl(expression, firExpression, isSpread, name)
|
||||
isSpread -> FirSpreadArgumentExpressionImpl(expression, firExpression)
|
||||
else -> firExpression
|
||||
}
|
||||
@@ -193,28 +192,33 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
): FirPropertyAccessor {
|
||||
if (this == null) {
|
||||
return if (isGetter) {
|
||||
FirDefaultPropertyGetter(session, property, propertyTypeRef, property.visibility)
|
||||
FirDefaultPropertyGetter(property, session, propertyTypeRef, property.visibility)
|
||||
} else {
|
||||
FirDefaultPropertySetter(session, property, propertyTypeRef, property.visibility)
|
||||
FirDefaultPropertySetter(property, session, propertyTypeRef, property.visibility)
|
||||
}
|
||||
}
|
||||
val firAccessor = FirPropertyAccessorImpl(
|
||||
session,
|
||||
this,
|
||||
isGetter,
|
||||
visibility,
|
||||
session,
|
||||
if (isGetter) {
|
||||
returnTypeReference?.convertSafe() ?: propertyTypeRef
|
||||
} else {
|
||||
returnTypeReference.toFirOrUnitType()
|
||||
},
|
||||
FirPropertyAccessorSymbol()
|
||||
FirPropertyAccessorSymbol(),
|
||||
isGetter,
|
||||
FirDeclarationStatusImpl(visibility, Modality.FINAL)
|
||||
)
|
||||
this@RawFirBuilder.context.firFunctions += firAccessor
|
||||
extractAnnotationsTo(firAccessor)
|
||||
extractValueParametersTo(firAccessor, propertyTypeRef)
|
||||
if (!isGetter && firAccessor.valueParameters.isEmpty()) {
|
||||
firAccessor.valueParameters += FirDefaultSetterValueParameter(session, this, propertyTypeRef)
|
||||
firAccessor.valueParameters += FirDefaultSetterValueParameter(
|
||||
this,
|
||||
session,
|
||||
propertyTypeRef,
|
||||
FirVariableSymbol(NAME_FOR_DEFAULT_VALUE_PARAMETER)
|
||||
)
|
||||
}
|
||||
firAccessor.body = this.buildFirBody()
|
||||
this@RawFirBuilder.context.firFunctions.removeLast()
|
||||
@@ -222,15 +226,17 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
|
||||
private fun KtParameter.toFirValueParameter(defaultTypeRef: FirTypeRef? = null): FirValueParameter {
|
||||
val name = nameAsSafeName
|
||||
val firValueParameter = FirValueParameterImpl(
|
||||
session,
|
||||
this,
|
||||
nameAsSafeName,
|
||||
session,
|
||||
when {
|
||||
typeReference != null -> typeReference.toFirOrErrorType()
|
||||
defaultTypeRef != null -> defaultTypeRef
|
||||
else -> null.toFirOrImplicitType()
|
||||
},
|
||||
name,
|
||||
FirVariableSymbol(CallableId(name)),
|
||||
if (hasDefaultValue()) {
|
||||
{ defaultValue }.toFirExpression("Should have default value")
|
||||
} else null,
|
||||
@@ -245,30 +251,32 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
private fun KtParameter.toFirProperty(firParameter: FirValueParameter): FirProperty {
|
||||
require(hasValOrVar())
|
||||
val type = typeReference.toFirOrErrorType()
|
||||
val firProperty = FirMemberPropertyImpl(
|
||||
session,
|
||||
val status = FirDeclarationStatusImpl(visibility, modality).apply {
|
||||
isExpect = hasExpectModifier()
|
||||
isActual = hasActualModifier()
|
||||
isOverride = hasModifier(OVERRIDE_KEYWORD)
|
||||
isConst = false
|
||||
isLateInit = false
|
||||
}
|
||||
val firProperty = FirPropertyImpl(
|
||||
this,
|
||||
FirPropertySymbol(callableIdForName(nameAsSafeName)),
|
||||
session,
|
||||
type,
|
||||
null,
|
||||
nameAsSafeName,
|
||||
visibility,
|
||||
modality,
|
||||
hasExpectModifier(),
|
||||
hasActualModifier(),
|
||||
isOverride = hasModifier(OVERRIDE_KEYWORD),
|
||||
isConst = false,
|
||||
isLateInit = false,
|
||||
receiverTypeRef = null,
|
||||
returnTypeRef = type,
|
||||
isVar = isMutable,
|
||||
initializer = FirQualifiedAccessExpressionImpl(this).apply {
|
||||
FirQualifiedAccessExpressionImpl(this).apply {
|
||||
calleeReference = FirPropertyFromParameterCallableReference(
|
||||
this@toFirProperty, nameAsSafeName, firParameter.symbol
|
||||
)
|
||||
},
|
||||
delegate = null
|
||||
null,
|
||||
isMutable,
|
||||
FirPropertySymbol(callableIdForName(nameAsSafeName)),
|
||||
false,
|
||||
status
|
||||
).apply {
|
||||
getter = FirDefaultPropertyGetter(this@RawFirBuilder.session, this@toFirProperty, type, visibility)
|
||||
setter = if (isMutable) FirDefaultPropertySetter(this@RawFirBuilder.session, this@toFirProperty, type, visibility) else null
|
||||
getter = FirDefaultPropertyGetter(this@toFirProperty, this@RawFirBuilder.session, type, visibility)
|
||||
setter = if (isMutable) FirDefaultPropertySetter(this@toFirProperty, this@RawFirBuilder.session, type, visibility) else null
|
||||
}
|
||||
extractAnnotationsTo(firProperty)
|
||||
return firProperty
|
||||
@@ -280,7 +288,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
}
|
||||
|
||||
private fun KtTypeParameterListOwner.extractTypeParametersTo(container: FirAbstractMemberDeclaration) {
|
||||
private fun KtTypeParameterListOwner.extractTypeParametersTo(container: FirModifiableTypeParametersOwner) {
|
||||
for (typeParameter in typeParameters) {
|
||||
container.typeParameters += typeParameter.convert<FirTypeParameter>()
|
||||
}
|
||||
@@ -323,8 +331,8 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
is KtDelegatedSuperTypeEntry -> {
|
||||
val type = superTypeListEntry.typeReference.toFirOrErrorType()
|
||||
container.superTypeRefs += FirDelegatedTypeRefImpl(
|
||||
type,
|
||||
{ superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate")
|
||||
{ superTypeListEntry.delegateExpression }.toFirExpression("Should have delegate"),
|
||||
type
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -380,17 +388,21 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
else
|
||||
Visibilities.UNKNOWN
|
||||
|
||||
val status = FirDeclarationStatusImpl(this?.visibility ?: defaultVisibility(), Modality.FINAL).apply {
|
||||
isExpect = this@toFirConstructor?.hasExpectModifier() ?: false
|
||||
isActual = this@toFirConstructor?.hasActualModifier() ?: false
|
||||
isInner = owner.hasModifier(INNER_KEYWORD)
|
||||
}
|
||||
val firConstructor = FirPrimaryConstructorImpl(
|
||||
session,
|
||||
this ?: owner,
|
||||
FirConstructorSymbol(callableIdForClassConstructor()),
|
||||
this?.visibility ?: defaultVisibility(),
|
||||
this?.hasExpectModifier() ?: false,
|
||||
this?.hasActualModifier() ?: false,
|
||||
owner.hasModifier(INNER_KEYWORD),
|
||||
session,
|
||||
delegatedSelfTypeRef,
|
||||
firDelegatedCall
|
||||
)
|
||||
null,
|
||||
status,
|
||||
FirConstructorSymbol(callableIdForClassConstructor())
|
||||
).apply {
|
||||
delegatedConstructor = firDelegatedCall
|
||||
}
|
||||
this?.extractAnnotationsTo(firConstructor)
|
||||
firConstructor.typeParameters += typeParametersFromSelfType(delegatedSelfTypeRef)
|
||||
this?.extractValueParametersTo(firConstructor)
|
||||
@@ -399,7 +411,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
|
||||
override fun visitKtFile(file: KtFile, data: Unit): FirElement {
|
||||
context.packageFqName = file.packageFqName
|
||||
val firFile = FirFileImpl(session, file, file.name, context.packageFqName)
|
||||
val firFile = FirFileImpl(file, session, file.name, context.packageFqName)
|
||||
for (annotationEntry in file.annotationEntries) {
|
||||
firFile.annotations += annotationEntry.convert<FirAnnotationCall>()
|
||||
}
|
||||
@@ -420,10 +432,10 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
override fun visitEnumEntry(enumEntry: KtEnumEntry, data: Unit): FirElement {
|
||||
return withChildClassName(enumEntry.nameAsSafeName) {
|
||||
val firEnumEntry = FirEnumEntryImpl(
|
||||
session,
|
||||
enumEntry,
|
||||
FirClassSymbol(context.currentClassId),
|
||||
enumEntry.nameAsSafeName
|
||||
session,
|
||||
enumEntry.nameAsSafeName,
|
||||
FirClassSymbol(context.currentClassId)
|
||||
)
|
||||
enumEntry.extractAnnotationsTo(firEnumEntry)
|
||||
val delegatedSelfType = enumEntry.toDelegatedSelfType(firEnumEntry)
|
||||
@@ -452,20 +464,24 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
else -> throw AssertionError("Unexpected class or object: ${classOrObject.text}")
|
||||
}
|
||||
val firClass = FirClassImpl(
|
||||
session,
|
||||
classOrObject,
|
||||
FirClassSymbol(context.currentClassId),
|
||||
classOrObject.nameAsSafeName,
|
||||
val status = FirDeclarationStatusImpl(
|
||||
if (classOrObject.isLocal) Visibilities.LOCAL else classOrObject.visibility,
|
||||
classOrObject.modality,
|
||||
classOrObject.hasExpectModifier(),
|
||||
classOrObject.hasActualModifier(),
|
||||
classKind,
|
||||
isInner = classOrObject.hasModifier(INNER_KEYWORD),
|
||||
isCompanion = (classOrObject as? KtObjectDeclaration)?.isCompanion() == true,
|
||||
isData = (classOrObject as? KtClass)?.isData() == true,
|
||||
classOrObject.modality
|
||||
).apply {
|
||||
isExpect = classOrObject.hasExpectModifier()
|
||||
isActual = classOrObject.hasActualModifier()
|
||||
isInner = classOrObject.hasModifier(INNER_KEYWORD)
|
||||
isCompanion = (classOrObject as? KtObjectDeclaration)?.isCompanion() == true
|
||||
isData = (classOrObject as? KtClass)?.isData() == true
|
||||
isInline = classOrObject.hasModifier(INLINE_KEYWORD)
|
||||
}
|
||||
val firClass = FirClassImpl(
|
||||
classOrObject,
|
||||
session,
|
||||
classOrObject.nameAsSafeName,
|
||||
status,
|
||||
classKind,
|
||||
FirClassSymbol(context.currentClassId)
|
||||
)
|
||||
classOrObject.extractAnnotationsTo(firClass)
|
||||
classOrObject.extractTypeParametersTo(firClass)
|
||||
@@ -507,7 +523,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
|
||||
override fun visitObjectLiteralExpression(expression: KtObjectLiteralExpression, data: Unit): FirElement {
|
||||
val objectDeclaration = expression.objectDeclaration
|
||||
return FirAnonymousObjectImpl(expression).apply {
|
||||
return FirAnonymousObjectImpl(expression, session).apply {
|
||||
objectDeclaration.extractAnnotationsTo(this)
|
||||
objectDeclaration.extractSuperTypeListEntriesTo(this, null)
|
||||
this.typeRef = superTypeRefs.first() // TODO
|
||||
@@ -522,15 +538,17 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
|
||||
override fun visitTypeAlias(typeAlias: KtTypeAlias, data: Unit): FirElement {
|
||||
val status = FirDeclarationStatusImpl(typeAlias.visibility, Modality.FINAL).apply {
|
||||
isExpect = typeAlias.hasExpectModifier()
|
||||
isActual = typeAlias.hasActualModifier()
|
||||
}
|
||||
return withChildClassName(typeAlias.nameAsSafeName) {
|
||||
val firTypeAlias = FirTypeAliasImpl(
|
||||
session,
|
||||
typeAlias,
|
||||
FirTypeAliasSymbol(context.currentClassId),
|
||||
session,
|
||||
typeAlias.nameAsSafeName,
|
||||
typeAlias.visibility,
|
||||
typeAlias.hasExpectModifier(),
|
||||
typeAlias.hasActualModifier(),
|
||||
status,
|
||||
FirTypeAliasSymbol(context.currentClassId),
|
||||
typeAlias.getTypeReference().toFirOrErrorType()
|
||||
)
|
||||
typeAlias.extractAnnotationsTo(firTypeAlias)
|
||||
@@ -548,32 +566,35 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
val receiverType = function.receiverTypeReference.convertSafe<FirTypeRef>()
|
||||
val firFunction = if (function.name == null) {
|
||||
FirAnonymousFunctionImpl(session, function, returnType, receiverType, FirAnonymousFunctionSymbol())
|
||||
FirAnonymousFunctionImpl(function, session, returnType, receiverType, FirAnonymousFunctionSymbol())
|
||||
} else {
|
||||
|
||||
FirMemberFunctionImpl(
|
||||
session,
|
||||
function,
|
||||
FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName, function.isLocal)),
|
||||
function.nameAsSafeName,
|
||||
val status = FirDeclarationStatusImpl(
|
||||
if (function.isLocal) Visibilities.LOCAL else function.visibility,
|
||||
function.modality,
|
||||
function.hasExpectModifier(),
|
||||
function.hasActualModifier(),
|
||||
function.hasModifier(OVERRIDE_KEYWORD),
|
||||
function.hasModifier(OPERATOR_KEYWORD),
|
||||
function.hasModifier(INFIX_KEYWORD),
|
||||
function.hasModifier(INLINE_KEYWORD),
|
||||
function.hasModifier(TAILREC_KEYWORD),
|
||||
function.hasModifier(EXTERNAL_KEYWORD),
|
||||
function.hasModifier(SUSPEND_KEYWORD),
|
||||
function.modality
|
||||
).apply {
|
||||
isExpect = function.hasExpectModifier()
|
||||
isActual = function.hasActualModifier()
|
||||
isOverride = function.hasModifier(OVERRIDE_KEYWORD)
|
||||
isOperator = function.hasModifier(OPERATOR_KEYWORD)
|
||||
isInfix = function.hasModifier(INFIX_KEYWORD)
|
||||
isInline = function.hasModifier(INLINE_KEYWORD)
|
||||
isTailRec = function.hasModifier(TAILREC_KEYWORD)
|
||||
isExternal = function.hasModifier(EXTERNAL_KEYWORD)
|
||||
isSuspend = function.hasModifier(SUSPEND_KEYWORD)
|
||||
}
|
||||
FirSimpleFunctionImpl(
|
||||
function,
|
||||
session,
|
||||
returnType,
|
||||
receiverType,
|
||||
returnType
|
||||
function.nameAsSafeName,
|
||||
status,
|
||||
FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName, function.isLocal))
|
||||
)
|
||||
}
|
||||
context.firFunctions += firFunction
|
||||
function.extractAnnotationsTo(firFunction)
|
||||
if (firFunction is FirMemberFunctionImpl) {
|
||||
if (firFunction is FirSimpleFunctionImpl) {
|
||||
function.extractTypeParametersTo(firFunction)
|
||||
}
|
||||
for (valueParameter in function.valueParameters) {
|
||||
@@ -588,16 +609,23 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
val literal = expression.functionLiteral
|
||||
val returnType = FirImplicitTypeRefImpl(literal)
|
||||
val receiverType = FirImplicitTypeRefImpl(literal)
|
||||
return FirAnonymousFunctionImpl(session, literal, returnType, receiverType, FirAnonymousFunctionSymbol()).apply {
|
||||
return FirAnonymousFunctionImpl(literal, session, returnType, receiverType, FirAnonymousFunctionSymbol()).apply {
|
||||
context.firFunctions += this
|
||||
var destructuringBlock: FirExpression? = null
|
||||
for (valueParameter in literal.valueParameters) {
|
||||
val multiDeclaration = valueParameter.destructuringDeclaration
|
||||
valueParameters += if (multiDeclaration != null) {
|
||||
val name = Name.special("<destruct>")
|
||||
val multiParameter = FirValueParameterImpl(
|
||||
this@RawFirBuilder.session, valueParameter, Name.special("<destruct>"),
|
||||
valueParameter,
|
||||
this@RawFirBuilder.session,
|
||||
FirImplicitTypeRefImpl(multiDeclaration),
|
||||
defaultValue = null, isCrossinline = false, isNoinline = false, isVararg = false
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
defaultValue = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isVararg = false
|
||||
)
|
||||
destructuringBlock = generateDestructuringBlock(
|
||||
this@RawFirBuilder.session,
|
||||
@@ -639,17 +667,21 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
owner: KtClassOrObject,
|
||||
hasPrimaryConstructor: Boolean
|
||||
): FirConstructor {
|
||||
val status = FirDeclarationStatusImpl(visibility, Modality.FINAL).apply {
|
||||
isExpect = hasExpectModifier()
|
||||
isActual = hasActualModifier()
|
||||
isInner = owner.hasModifier(INNER_KEYWORD)
|
||||
}
|
||||
val firConstructor = FirConstructorImpl(
|
||||
session,
|
||||
this,
|
||||
FirConstructorSymbol(callableIdForClassConstructor()),
|
||||
visibility,
|
||||
hasExpectModifier(),
|
||||
hasActualModifier(),
|
||||
owner.hasModifier(INNER_KEYWORD),
|
||||
session,
|
||||
delegatedSelfTypeRef,
|
||||
getDelegationCall().convert(delegatedSuperTypeRef, delegatedSelfTypeRef, hasPrimaryConstructor)
|
||||
)
|
||||
null,
|
||||
status,
|
||||
FirConstructorSymbol(callableIdForClassConstructor())
|
||||
).apply {
|
||||
delegatedConstructor = getDelegationCall().convert(delegatedSuperTypeRef, delegatedSelfTypeRef, hasPrimaryConstructor)
|
||||
}
|
||||
this@RawFirBuilder.context.firFunctions += firConstructor
|
||||
extractAnnotationsTo(firConstructor)
|
||||
firConstructor.typeParameters += typeParametersFromSelfType(delegatedSelfTypeRef)
|
||||
@@ -682,8 +714,8 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
|
||||
override fun visitAnonymousInitializer(initializer: KtAnonymousInitializer, data: Unit): FirElement {
|
||||
return FirAnonymousInitializerImpl(
|
||||
session,
|
||||
initializer,
|
||||
session,
|
||||
if (stubMode) FirEmptyExpressionBlock() else initializer.body.toFirBlock()
|
||||
)
|
||||
}
|
||||
@@ -697,45 +729,51 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
} else null
|
||||
val delegateExpression by lazy { property.delegate?.expression }
|
||||
val firProperty = if (property.isLocal) {
|
||||
FirVariableImpl(
|
||||
session,
|
||||
FirPropertyImpl(
|
||||
property,
|
||||
name,
|
||||
session,
|
||||
propertyType,
|
||||
isVar,
|
||||
null,
|
||||
name,
|
||||
initializer,
|
||||
delegate = delegateExpression?.let {
|
||||
delegateExpression?.let {
|
||||
FirWrappedDelegateExpressionImpl(
|
||||
it,
|
||||
it.toFirExpression("Incorrect delegate expression")
|
||||
)
|
||||
}
|
||||
},
|
||||
isVar,
|
||||
FirPropertySymbol(CallableId(name)),
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||
).apply {
|
||||
generateAccessorsByDelegate(this@RawFirBuilder.session, member = false, stubMode = stubMode)
|
||||
}
|
||||
} else {
|
||||
FirMemberPropertyImpl(
|
||||
session,
|
||||
val status = FirDeclarationStatusImpl(property.visibility, property.modality).apply {
|
||||
isExpect = property.hasExpectModifier()
|
||||
isActual = property.hasActualModifier()
|
||||
isOverride = property.hasModifier(OVERRIDE_KEYWORD)
|
||||
isConst = property.hasModifier(CONST_KEYWORD)
|
||||
isLateInit = property.hasModifier(LATEINIT_KEYWORD)
|
||||
}
|
||||
FirPropertyImpl(
|
||||
property,
|
||||
FirPropertySymbol(callableIdForName(name)),
|
||||
name,
|
||||
property.visibility,
|
||||
property.modality,
|
||||
property.hasExpectModifier(),
|
||||
property.hasActualModifier(),
|
||||
property.hasModifier(OVERRIDE_KEYWORD),
|
||||
property.hasModifier(CONST_KEYWORD),
|
||||
property.hasModifier(LATEINIT_KEYWORD),
|
||||
property.receiverTypeReference.convertSafe(),
|
||||
session,
|
||||
propertyType,
|
||||
isVar,
|
||||
property.receiverTypeReference.convertSafe(),
|
||||
name,
|
||||
initializer,
|
||||
if (property.hasDelegate()) {
|
||||
FirWrappedDelegateExpressionImpl(
|
||||
if (stubMode) null else delegateExpression,
|
||||
{ delegateExpression }.toFirExpression("Should have delegate")
|
||||
)
|
||||
} else null
|
||||
} else null,
|
||||
isVar,
|
||||
FirPropertySymbol(callableIdForName(name)),
|
||||
false,
|
||||
status
|
||||
).apply {
|
||||
property.extractTypeParametersTo(this)
|
||||
getter = property.getter.toFirPropertyAccessor(property, propertyType, isGetter = true)
|
||||
@@ -817,10 +855,10 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
override fun visitTypeParameter(parameter: KtTypeParameter, data: Unit): FirElement {
|
||||
val parameterName = parameter.nameAsSafeName
|
||||
val firTypeParameter = FirTypeParameterImpl(
|
||||
session,
|
||||
parameter,
|
||||
FirTypeParameterSymbol(),
|
||||
session,
|
||||
parameterName,
|
||||
FirTypeParameterSymbol(),
|
||||
parameter.variance,
|
||||
parameter.hasModifier(REIFIED_KEYWORD)
|
||||
)
|
||||
@@ -852,13 +890,13 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
val firType = typeReference.toFirOrErrorType()
|
||||
return FirTypeProjectionWithVarianceImpl(
|
||||
typeProjection,
|
||||
firType,
|
||||
when (projectionKind) {
|
||||
KtProjectionKind.IN -> Variance.IN_VARIANCE
|
||||
KtProjectionKind.OUT -> Variance.OUT_VARIANCE
|
||||
KtProjectionKind.NONE -> Variance.INVARIANT
|
||||
KtProjectionKind.STAR -> throw AssertionError("* should not be here")
|
||||
},
|
||||
firType
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -910,7 +948,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
|
||||
override fun visitIfExpression(expression: KtIfExpression, data: Unit): FirElement {
|
||||
return FirWhenExpressionImpl(expression).apply {
|
||||
return FirWhenExpressionImpl(expression, null, null).apply {
|
||||
val condition = expression.condition
|
||||
val firCondition = condition.toFirExpression("If statement should have condition")
|
||||
val trueBranch = expression.then.toFirBlock()
|
||||
@@ -929,11 +967,22 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
else -> ktSubjectExpression
|
||||
}?.toFirExpression("Incorrect when subject expression: ${ktSubjectExpression?.text}")
|
||||
val subjectVariable = when (ktSubjectExpression) {
|
||||
is KtVariableDeclaration -> FirVariableImpl(
|
||||
session, ktSubjectExpression, ktSubjectExpression.nameAsSafeName,
|
||||
ktSubjectExpression.typeReference.toFirOrImplicitType(),
|
||||
isVar = false, initializer = subjectExpression
|
||||
)
|
||||
is KtVariableDeclaration -> {
|
||||
val name = ktSubjectExpression.nameAsSafeName
|
||||
FirPropertyImpl(
|
||||
ktSubjectExpression,
|
||||
session,
|
||||
ktSubjectExpression.typeReference.toFirOrImplicitType(),
|
||||
null,
|
||||
name,
|
||||
subjectExpression,
|
||||
null,
|
||||
false,
|
||||
FirPropertySymbol(CallableId(name)),
|
||||
true,
|
||||
FirDeclarationStatusImpl(Visibilities.LOCAL, Modality.FINAL)
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
val hasSubject = subjectExpression != null
|
||||
@@ -996,7 +1045,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
val iteratorVal = generateTemporaryVariable(
|
||||
this@RawFirBuilder.session, expression.loopRange, Name.special("<iterator>"),
|
||||
FirFunctionCallImpl(expression).apply {
|
||||
calleeReference = FirSimpleNamedReference(expression, Name.identifier("iterator"))
|
||||
calleeReference = FirSimpleNamedReference(expression, Name.identifier("iterator"), null)
|
||||
explicitReceiver = generateResolvedAccessExpression(expression.loopRange, rangeVal)
|
||||
}
|
||||
)
|
||||
@@ -1004,7 +1053,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
statements += FirWhileLoopImpl(
|
||||
expression,
|
||||
FirFunctionCallImpl(expression).apply {
|
||||
calleeReference = FirSimpleNamedReference(expression, Name.identifier("hasNext"))
|
||||
calleeReference = FirSimpleNamedReference(expression, Name.identifier("hasNext"), null)
|
||||
explicitReceiver = generateResolvedAccessExpression(expression, iteratorVal)
|
||||
}
|
||||
).configure {
|
||||
@@ -1020,7 +1069,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
this@RawFirBuilder.session, expression.loopParameter,
|
||||
if (multiDeclaration != null) Name.special("<destruct>") else parameter.nameAsSafeName,
|
||||
FirFunctionCallImpl(expression).apply {
|
||||
calleeReference = FirSimpleNamedReference(expression, Name.identifier("next"))
|
||||
calleeReference = FirSimpleNamedReference(expression, Name.identifier("next"), null)
|
||||
explicitReceiver = generateResolvedAccessExpression(expression, iteratorVal)
|
||||
}
|
||||
)
|
||||
@@ -1073,7 +1122,8 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
FirFunctionCallImpl(expression).apply {
|
||||
calleeReference = FirSimpleNamedReference(
|
||||
expression.operationReference,
|
||||
conventionCallName ?: expression.operationReference.getReferencedNameAsName()
|
||||
conventionCallName ?: expression.operationReference.getReferencedNameAsName(),
|
||||
null
|
||||
)
|
||||
explicitReceiver = leftArgument
|
||||
arguments += rightArgument
|
||||
@@ -1128,7 +1178,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
}
|
||||
FirFunctionCallImpl(expression).apply {
|
||||
calleeReference = FirSimpleNamedReference(
|
||||
expression.operationReference, conventionCallName
|
||||
expression.operationReference, conventionCallName, null
|
||||
)
|
||||
explicitReceiver = argument.toFirExpression("No operand")
|
||||
}
|
||||
@@ -1145,15 +1195,15 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
return FirFunctionCallImpl(expression).apply {
|
||||
val calleeReference = when (calleeExpression) {
|
||||
is KtSimpleNameExpression -> FirSimpleNamedReference(
|
||||
calleeExpression, calleeExpression.getReferencedNameAsName()
|
||||
calleeExpression, calleeExpression.getReferencedNameAsName(), null
|
||||
)
|
||||
null -> FirErrorNamedReference(
|
||||
null -> FirErrorNamedReferenceImpl(
|
||||
calleeExpression, "Call has no callee"
|
||||
)
|
||||
else -> {
|
||||
arguments += calleeExpression.toFirExpression("Incorrect invoke receiver")
|
||||
FirSimpleNamedReference(
|
||||
expression, OperatorNameConventions.INVOKE
|
||||
expression, OperatorNameConventions.INVOKE, null
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1170,7 +1220,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
override fun visitArrayAccessExpression(expression: KtArrayAccessExpression, data: Unit): FirElement {
|
||||
val arrayExpression = expression.arrayExpression
|
||||
return FirFunctionCallImpl(expression).apply {
|
||||
calleeReference = FirSimpleNamedReference(expression, OperatorNameConventions.GET)
|
||||
calleeReference = FirSimpleNamedReference(expression, OperatorNameConventions.GET, null)
|
||||
explicitReceiver = arrayExpression.toFirExpression("No array expression")
|
||||
for (indexExpression in expression.indexExpressions) {
|
||||
arguments += indexExpression.toFirExpression("Incorrect index expression")
|
||||
@@ -1182,7 +1232,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
val selector = expression.selectorExpression
|
||||
?: return FirErrorExpressionImpl(expression, "Qualified expression without selector")
|
||||
val firSelector = selector.toFirExpression("Incorrect selector expression")
|
||||
if (firSelector is FirModifiableQualifiedAccess<*>) {
|
||||
if (firSelector is FirModifiableQualifiedAccess) {
|
||||
firSelector.safe = expression is KtSafeQualifiedExpression
|
||||
firSelector.explicitReceiver = expression.receiverExpression.toFirExpression("Incorrect receiver expression")
|
||||
}
|
||||
@@ -1256,7 +1306,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
|
||||
override fun visitCallableReferenceExpression(expression: KtCallableReferenceExpression, data: Unit): FirElement {
|
||||
return FirCallableReferenceAccessImpl(expression).apply {
|
||||
calleeReference = FirSimpleNamedReference(
|
||||
expression.callableReference, expression.callableReference.getReferencedNameAsName()
|
||||
expression.callableReference, expression.callableReference.getReferencedNameAsName(), null
|
||||
)
|
||||
explicitReceiver = expression.receiverExpression?.toFirExpression("Incorrect receiver expression")
|
||||
}
|
||||
|
||||
+1
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.parsing.KotlinParserDefinition
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtPsiFactory
|
||||
|
||||
+5
-6
@@ -9,7 +9,6 @@ import com.intellij.testFramework.TestDataPath
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirErrorDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.expressions.FirErrorExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
@@ -101,11 +100,11 @@ class RawFirBuilderTotalKotlinTestCase : AbstractRawFirBuilderTestCase() {
|
||||
statement.acceptChildren(this)
|
||||
}
|
||||
|
||||
override fun visitErrorDeclaration(errorDeclaration: FirErrorDeclaration) {
|
||||
errorDeclarations++
|
||||
println(errorDeclaration.render())
|
||||
errorDeclaration.psi?.let { println(it) }
|
||||
}
|
||||
// override fun visitErrorDeclaration(errorDeclaration: FirErrorDeclaration) {
|
||||
// errorDeclarations++
|
||||
// println(errorDeclaration.render())
|
||||
// errorDeclaration.psi?.let { println(it) }
|
||||
// }
|
||||
|
||||
override fun visitDeclaration(declaration: FirDeclaration) {
|
||||
normalDeclarations++
|
||||
|
||||
@@ -17,6 +17,8 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirFunctionCallImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirTryExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirWhenExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||
@@ -35,7 +37,8 @@ fun FirFunctionCall.copy(
|
||||
typeArguments: List<FirTypeProjection> = this.typeArguments,
|
||||
resultType: FirTypeRef = this.typeRef
|
||||
): FirFunctionCall {
|
||||
return FirFunctionCallImpl(psi, safe).apply {
|
||||
return FirFunctionCallImpl(psi).apply {
|
||||
this.safe = safe
|
||||
this.annotations.addAll(annotations)
|
||||
this.arguments.addAll(arguments)
|
||||
this.calleeReference = calleeReference
|
||||
@@ -60,7 +63,7 @@ fun FirAnonymousFunction.copy(
|
||||
controlFlowGraphReference: FirControlFlowGraphReference = this.controlFlowGraphReference,
|
||||
invocationKind: InvocationKind? = this.invocationKind
|
||||
): FirAnonymousFunction {
|
||||
return FirAnonymousFunctionImpl(session, psi, returnTypeRef, receiverTypeRef, symbol).apply {
|
||||
return FirAnonymousFunctionImpl(psi, session, returnTypeRef, receiverTypeRef, symbol).apply {
|
||||
this.valueParameters.addAll(valueParameters)
|
||||
this.body = body
|
||||
this.annotations.addAll(annotations)
|
||||
@@ -75,7 +78,9 @@ fun FirAnonymousFunction.copy(
|
||||
fun FirTypeRef.resolvedTypeFromPrototype(
|
||||
type: ConeKotlinType
|
||||
): FirResolvedTypeRef {
|
||||
return FirResolvedTypeRefImpl(psi, type, annotations)
|
||||
return FirResolvedTypeRefImpl(psi, type).apply {
|
||||
annotations += this@resolvedTypeFromPrototype.annotations
|
||||
}
|
||||
}
|
||||
|
||||
fun FirTypeParameter.copy(
|
||||
@@ -83,7 +88,7 @@ fun FirTypeParameter.copy(
|
||||
annotations: List<FirAnnotationCall> = this.annotations
|
||||
): FirTypeParameterImpl {
|
||||
return FirTypeParameterImpl(
|
||||
session, psi, symbol, name, variance, isReified
|
||||
psi, session, name, symbol, variance, isReified
|
||||
).apply {
|
||||
this.bounds += bounds
|
||||
this.annotations += annotations
|
||||
@@ -93,7 +98,8 @@ fun FirTypeParameter.copy(
|
||||
fun FirWhenExpression.copy(
|
||||
resultType: FirTypeRef = this.typeRef,
|
||||
calleeReference: FirReference = this.calleeReference
|
||||
): FirWhenExpressionImpl = FirWhenExpressionImpl(psi, subject, subjectVariable, calleeReference).apply {
|
||||
): FirWhenExpressionImpl = FirWhenExpressionImpl(psi, subject, subjectVariable).apply {
|
||||
this.calleeReference = calleeReference
|
||||
this@apply.branches.addAll(this@copy.branches)
|
||||
this.typeRef = resultType
|
||||
this.calleeReference = calleeReference
|
||||
@@ -102,7 +108,8 @@ fun FirWhenExpression.copy(
|
||||
fun FirTryExpression.copy(
|
||||
resultType: FirTypeRef = this.typeRef,
|
||||
calleeReference: FirReference = this.calleeReference
|
||||
): FirTryExpressionImpl = FirTryExpressionImpl(psi, tryBlock, finallyBlock, calleeReference).apply {
|
||||
): FirTryExpressionImpl = FirTryExpressionImpl(psi, tryBlock, finallyBlock).apply {
|
||||
this.calleeReference = calleeReference
|
||||
this@apply.catches.addAll(this@copy.catches)
|
||||
this.typeRef = resultType
|
||||
}
|
||||
@@ -12,10 +12,11 @@ import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirBackingFieldReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.*
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirBackingFieldReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.ImplicitReceiverStack
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
@@ -48,8 +49,8 @@ class FirCallResolver(
|
||||
fun resolveCallAndSelectCandidate(functionCall: FirFunctionCall, expectedTypeRef: FirTypeRef?, file: FirFile): FirFunctionCall {
|
||||
qualifiedResolver.reset()
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val functionCall = (functionCall.transformExplicitReceiver(transformer, noExpectedType) as FirFunctionCall)
|
||||
.transformArguments(transformer, null) as FirFunctionCall
|
||||
val functionCall = functionCall.transformExplicitReceiver(transformer, noExpectedType)
|
||||
.transformArguments(transformer, null)
|
||||
|
||||
val name = functionCall.calleeReference.name
|
||||
|
||||
@@ -190,7 +191,8 @@ class FirCallResolver(
|
||||
else -> null
|
||||
}
|
||||
if (referencedSymbol is FirClassLikeSymbol<*>) {
|
||||
return FirResolvedQualifierImpl(nameReference.psi, referencedSymbol.classId).apply {
|
||||
val classId = referencedSymbol.classId
|
||||
return FirResolvedQualifierImpl(nameReference.psi, classId.packageFqName, classId.relativeClassName).apply {
|
||||
resultType = typeForQualifier(this)
|
||||
}
|
||||
}
|
||||
@@ -218,21 +220,20 @@ class FirCallResolver(
|
||||
val name = namedReference.name
|
||||
val psi = namedReference.psi
|
||||
return when {
|
||||
candidates.isEmpty() -> FirErrorNamedReference(
|
||||
candidates.isEmpty() -> FirErrorNamedReferenceImpl(
|
||||
psi, "Unresolved name: $name"
|
||||
)
|
||||
applicability < CandidateApplicability.SYNTHETIC_RESOLVED -> {
|
||||
FirErrorNamedReference(
|
||||
FirErrorNamedReferenceImpl(
|
||||
psi,
|
||||
"Inapplicable($applicability): ${candidates.map { describeSymbol(it.symbol) }}",
|
||||
namedReference.name
|
||||
"Inapplicable($applicability): ${candidates.map { describeSymbol(it.symbol) }}"
|
||||
)
|
||||
}
|
||||
candidates.size == 1 -> {
|
||||
val candidate = candidates.single()
|
||||
val coneSymbol = candidate.symbol
|
||||
when {
|
||||
coneSymbol is FirBackingFieldSymbol -> FirBackingFieldReferenceImpl(psi, coneSymbol)
|
||||
coneSymbol is FirBackingFieldSymbol -> FirBackingFieldReferenceImpl(psi, null, coneSymbol)
|
||||
coneSymbol is FirVariableSymbol && (
|
||||
coneSymbol !is FirPropertySymbol ||
|
||||
(coneSymbol.phasedFir(session) as FirMemberDeclaration).typeParameters.isEmpty()
|
||||
@@ -241,9 +242,8 @@ class FirCallResolver(
|
||||
else -> FirNamedReferenceWithCandidate(psi, name, candidate)
|
||||
}
|
||||
}
|
||||
else -> FirErrorNamedReference(
|
||||
psi, "Ambiguity: $name, ${candidates.map { describeSymbol(it.symbol) }}",
|
||||
namedReference.name
|
||||
else -> FirErrorNamedReferenceImpl(
|
||||
psi, "Ambiguity: $name, ${candidates.map { describeSymbol(it.symbol) }}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.PackageOrClass
|
||||
|
||||
+4
-4
@@ -11,8 +11,8 @@ import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.constructType
|
||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
@@ -83,7 +83,7 @@ abstract class AbstractAnnotationDeserializer(
|
||||
val parameter = parameterByName[name] ?: return@mapNotNull null
|
||||
val value = resolveValue(parameter.returnTypeRef, it.value, nameResolver) ?: return@mapNotNull null
|
||||
FirNamedArgumentExpressionImpl(
|
||||
null, name, false, value
|
||||
null, value, false, name
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ abstract class AbstractAnnotationDeserializer(
|
||||
val entrySymbol = entryLookupTag.toSymbol(this@AbstractAnnotationDeserializer.session)
|
||||
this.calleeReference = entrySymbol?.let {
|
||||
FirResolvedCallableReferenceImpl(null, entryName, it)
|
||||
} ?: FirErrorNamedReference(
|
||||
} ?: FirErrorNamedReferenceImpl(
|
||||
null,
|
||||
errorReason = "Strange deserialized enum value: $classId.$entryName"
|
||||
)
|
||||
|
||||
+20
-11
@@ -7,7 +7,9 @@ package org.jetbrains.kotlin.fir.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.addDeclarations
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirClassImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirEnumEntryImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
@@ -35,16 +37,24 @@ fun deserializeClassToSymbol(
|
||||
) {
|
||||
val flags = classProto.flags
|
||||
val kind = Flags.CLASS_KIND.get(flags)
|
||||
FirClassImpl(
|
||||
session, null, symbol, classId.shortClassName,
|
||||
val status = FirDeclarationStatusImpl(
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
ProtoEnumFlags.modality(Flags.MODALITY.get(flags)),
|
||||
Flags.IS_EXPECT_CLASS.get(flags), false,
|
||||
ProtoEnumFlags.modality(Flags.MODALITY.get(flags))
|
||||
).apply {
|
||||
isExpect = Flags.IS_EXPECT_CLASS.get(flags)
|
||||
isActual = false
|
||||
isCompanion = kind == ProtoBuf.Class.Kind.COMPANION_OBJECT
|
||||
isInner = Flags.IS_INNER.get(flags)
|
||||
isData = Flags.IS_DATA.get(classProto.flags)
|
||||
isInline = Flags.IS_INLINE_CLASS.get(classProto.flags)
|
||||
}
|
||||
FirClassImpl(
|
||||
null,
|
||||
session,
|
||||
classId.shortClassName,
|
||||
status,
|
||||
ProtoEnumFlags.classKind(kind),
|
||||
Flags.IS_INNER.get(flags),
|
||||
kind == ProtoBuf.Class.Kind.COMPANION_OBJECT,
|
||||
Flags.IS_DATA.get(classProto.flags),
|
||||
Flags.IS_INLINE_CLASS.get(classProto.flags)
|
||||
symbol
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
val context =
|
||||
@@ -94,12 +104,11 @@ fun deserializeClassToSymbol(
|
||||
val enumEntryId = classId.createNestedClassId(enumEntryName)
|
||||
|
||||
val symbol = FirClassSymbol(enumEntryId)
|
||||
FirEnumEntryImpl(session, null, symbol, enumEntryId.shortClassName).apply {
|
||||
FirEnumEntryImpl(null, session, enumEntryId.shortClassName, symbol).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
superTypeRefs += FirResolvedTypeRefImpl(
|
||||
null,
|
||||
ConeClassTypeImpl(ConeClassLikeLookupTagImpl(classId), emptyArray(), false),
|
||||
emptyList()
|
||||
ConeClassTypeImpl(ConeClassLikeLookupTagImpl(classId), emptyArray(), false)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+79
-64
@@ -5,6 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
@@ -126,18 +128,19 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
val flags = proto.flags
|
||||
val name = c.nameResolver.getName(proto.name)
|
||||
val local = c.childContext(proto.typeParameterList)
|
||||
val status = FirDeclarationStatusImpl(ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), Modality.FINAL).apply {
|
||||
isExpect = Flags.IS_EXPECT_CLASS.get(flags)
|
||||
isActual = false
|
||||
}
|
||||
return FirTypeAliasImpl(
|
||||
c.session,
|
||||
null,
|
||||
FirTypeAliasSymbol(ClassId(c.packageFqName, name)),
|
||||
c.session,
|
||||
name,
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
Flags.IS_EXPECT_CLASS.get(flags),
|
||||
false,
|
||||
status,
|
||||
FirTypeAliasSymbol(ClassId(c.packageFqName, name)),
|
||||
FirResolvedTypeRefImpl(
|
||||
null,
|
||||
local.typeDeserializer.type(proto.underlyingType(c.typeTable)),
|
||||
emptyList() /* TODO */
|
||||
local.typeDeserializer.type(proto.underlyingType(c.typeTable))
|
||||
)
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
@@ -155,36 +158,40 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
val getterFlags = if (proto.hasGetterFlags()) proto.getterFlags else flags
|
||||
val setterFlags = if (proto.hasSetterFlags()) proto.setterFlags else flags
|
||||
val isVar = Flags.IS_VAR.get(flags)
|
||||
|
||||
return FirMemberPropertyImpl(
|
||||
c.session,
|
||||
null,
|
||||
symbol,
|
||||
callableName,
|
||||
val status = FirDeclarationStatusImpl(
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
ProtoEnumFlags.modality(Flags.MODALITY.get(flags)),
|
||||
isExpect = Flags.IS_EXPECT_PROPERTY.get(flags),
|
||||
isActual = false,
|
||||
isOverride = false,
|
||||
isConst = Flags.IS_CONST.get(flags),
|
||||
isLateInit = Flags.IS_LATEINIT.get(flags),
|
||||
receiverTypeRef = proto.receiverType(c.typeTable)?.toTypeRef(local),
|
||||
returnTypeRef = returnTypeRef,
|
||||
isVar = isVar,
|
||||
initializer = null,
|
||||
delegate = null
|
||||
ProtoEnumFlags.modality(Flags.MODALITY.get(flags))
|
||||
).apply {
|
||||
isExpect = Flags.IS_EXPECT_PROPERTY.get(flags)
|
||||
isActual = false
|
||||
isOverride = false
|
||||
isConst = Flags.IS_CONST.get(flags)
|
||||
isLateInit = Flags.IS_LATEINIT.get(flags)
|
||||
}
|
||||
return FirPropertyImpl(
|
||||
null,
|
||||
c.session,
|
||||
returnTypeRef,
|
||||
proto.receiverType(c.typeTable)?.toTypeRef(local),
|
||||
callableName,
|
||||
null,
|
||||
null,
|
||||
isVar,
|
||||
symbol,
|
||||
false,
|
||||
status
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
|
||||
annotations += c.annotationDeserializer.loadPropertyAnnotations(proto, local.nameResolver)
|
||||
getter = FirDefaultPropertyGetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags)))
|
||||
getter = FirDefaultPropertyGetter(null, c.session, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(getterFlags)))
|
||||
setter = if (isVar) {
|
||||
FirDefaultPropertySetter(c.session, null, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(setterFlags)))
|
||||
FirDefaultPropertySetter(null, c.session, returnTypeRef, ProtoEnumFlags.visibility(Flags.VISIBILITY.get(setterFlags)))
|
||||
} else null
|
||||
}
|
||||
}
|
||||
|
||||
fun loadFunction(proto: ProtoBuf.Function): FirNamedFunction {
|
||||
fun loadFunction(proto: ProtoBuf.Function): FirSimpleFunction {
|
||||
val flags = if (proto.hasFlags()) proto.flags else loadOldFlags(proto.oldFlags)
|
||||
|
||||
val receiverAnnotations =
|
||||
@@ -198,26 +205,30 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
val callableName = c.nameResolver.getName(proto.name)
|
||||
val symbol = FirNamedFunctionSymbol(CallableId(c.packageFqName, c.relativeClassName, callableName))
|
||||
val local = c.childContext(proto.typeParameterList)
|
||||
val status = FirDeclarationStatusImpl(
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
ProtoEnumFlags.modality(Flags.MODALITY.get(flags))
|
||||
).apply {
|
||||
isExpect = Flags.IS_EXPECT_FUNCTION.get(flags)
|
||||
isActual = false
|
||||
isOverride = false
|
||||
isOperator = Flags.IS_OPERATOR.get(flags)
|
||||
isInfix = Flags.IS_INFIX.get(flags)
|
||||
isInline = Flags.IS_INLINE.get(flags)
|
||||
isTailRec = Flags.IS_TAILREC.get(flags)
|
||||
isExternal = Flags.IS_EXTERNAL_FUNCTION.get(flags)
|
||||
isSuspend = Flags.IS_SUSPEND.get(flags)
|
||||
}
|
||||
|
||||
// TODO: support contracts
|
||||
return FirMemberFunctionImpl(
|
||||
c.session,
|
||||
return FirSimpleFunctionImpl(
|
||||
null,
|
||||
symbol,
|
||||
c.session,
|
||||
proto.returnType(local.typeTable).toTypeRef(local),
|
||||
proto.receiverType(local.typeTable)?.toTypeRef(local),
|
||||
callableName,
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
ProtoEnumFlags.modality(Flags.MODALITY.get(flags)),
|
||||
Flags.IS_EXPECT_FUNCTION.get(flags),
|
||||
isActual = false,
|
||||
isOverride = false,
|
||||
isOperator = Flags.IS_OPERATOR.get(flags),
|
||||
isInfix = Flags.IS_INFIX.get(flags),
|
||||
isInline = Flags.IS_INLINE.get(flags),
|
||||
isTailRec = Flags.IS_TAILREC.get(flags),
|
||||
isExternal = Flags.IS_EXTERNAL_FUNCTION.get(flags),
|
||||
isSuspend = Flags.IS_SUSPEND.get(flags),
|
||||
receiverTypeRef = proto.receiverType(local.typeTable)?.toTypeRef(local),
|
||||
returnTypeRef = proto.returnType(local.typeTable).toTypeRef(local)
|
||||
status,
|
||||
symbol
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
typeParameters += local.typeDeserializer.ownTypeParameters.map { it.fir }
|
||||
@@ -244,29 +255,28 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
)
|
||||
)
|
||||
|
||||
val status = FirDeclarationStatusImpl(ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)), Modality.FINAL).apply {
|
||||
isExpect = Flags.IS_EXPECT_FUNCTION.get(flags)
|
||||
isActual = false
|
||||
isInner = klass.isInner
|
||||
}
|
||||
return if (isPrimary) {
|
||||
FirPrimaryConstructorImpl(
|
||||
c.session,
|
||||
null,
|
||||
symbol,
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
Flags.IS_EXPECT_FUNCTION.get(flags),
|
||||
false,
|
||||
klass.isInner,
|
||||
c.session,
|
||||
delegatedSelfType,
|
||||
null
|
||||
null,
|
||||
status,
|
||||
symbol
|
||||
)
|
||||
} else {
|
||||
FirConstructorImpl(
|
||||
c.session,
|
||||
null,
|
||||
symbol,
|
||||
ProtoEnumFlags.visibility(Flags.VISIBILITY.get(flags)),
|
||||
Flags.IS_EXPECT_FUNCTION.get(flags),
|
||||
false,
|
||||
klass.isInner,
|
||||
c.session,
|
||||
delegatedSelfType,
|
||||
null
|
||||
null,
|
||||
status,
|
||||
symbol
|
||||
)
|
||||
}.apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
@@ -289,13 +299,17 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
): List<FirValueParameter> {
|
||||
return valueParameters.map { proto ->
|
||||
val flags = if (proto.hasFlags()) proto.flags else 0
|
||||
val name = c.nameResolver.getName(proto.name)
|
||||
FirValueParameterImpl(
|
||||
c.session, null, c.nameResolver.getName(proto.name),
|
||||
null,
|
||||
c.session,
|
||||
proto.type(c.typeTable).toTypeRef(c),
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
defaultValue(flags),
|
||||
Flags.IS_CROSSINLINE.get(flags),
|
||||
Flags.IS_NOINLINE.get(flags),
|
||||
proto.varargElementType(c.typeTable) != null
|
||||
isCrossinline = Flags.IS_CROSSINLINE.get(flags),
|
||||
isNoinline = Flags.IS_NOINLINE.get(flags),
|
||||
isVararg = proto.varargElementType(c.typeTable) != null
|
||||
).apply {
|
||||
annotations += c.annotationDeserializer.loadValueParameterAnnotations(proto, c.nameResolver)
|
||||
}
|
||||
@@ -305,9 +319,10 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
|
||||
private fun ProtoBuf.Type.toTypeRef(context: FirDeserializationContext): FirTypeRef {
|
||||
val coneType = context.typeDeserializer.type(this)
|
||||
return FirResolvedTypeRefImpl(
|
||||
null, coneType,
|
||||
context.annotationDeserializer.loadTypeAnnotations(this, context.nameResolver)
|
||||
)
|
||||
null, coneType
|
||||
).apply {
|
||||
annotations += context.annotationDeserializer.loadTypeAnnotations(this@toTypeRef, context.nameResolver)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,8 +6,8 @@
|
||||
package org.jetbrains.kotlin.fir.deserialization
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.addDefaultBoundIfNecessary
|
||||
import org.jetbrains.kotlin.fir.resolve.toTypeProjection
|
||||
import org.jetbrains.kotlin.fir.symbols.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
@@ -78,10 +78,10 @@ class FirTypeDeserializer(
|
||||
val name = nameResolver.getName(proto.name)
|
||||
val symbol = FirTypeParameterSymbol()
|
||||
FirTypeParameterImpl(
|
||||
session,
|
||||
null,
|
||||
symbol,
|
||||
session,
|
||||
name,
|
||||
symbol,
|
||||
proto.variance.convertVariance(),
|
||||
proto.reified
|
||||
)
|
||||
@@ -98,7 +98,7 @@ class FirTypeDeserializer(
|
||||
val declaration = symbol.fir as FirTypeParameterImpl
|
||||
declaration.apply {
|
||||
proto.upperBoundList.mapTo(bounds) {
|
||||
FirResolvedTypeRefImpl(null, type(it), emptyList())
|
||||
FirResolvedTypeRefImpl(null, type(it))
|
||||
}
|
||||
addDefaultBoundIfNecessary()
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvable
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.references.FirThisReference
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.resultType
|
||||
@@ -194,7 +196,7 @@ fun <T : ConeKotlinType> T.withArguments(arguments: Array<out ConeKotlinTypeProj
|
||||
|
||||
fun FirFunction<*>.constructFunctionalTypeRef(session: FirSession): FirResolvedTypeRef {
|
||||
val receiverTypeRef = when (this) {
|
||||
is FirNamedFunction -> receiverTypeRef
|
||||
is FirSimpleFunction -> receiverTypeRef
|
||||
is FirAnonymousFunction -> receiverTypeRef
|
||||
else -> null
|
||||
}
|
||||
@@ -225,7 +227,7 @@ fun BodyResolveComponents.typeForQualifier(resolvedQualifier: FirResolvedQualifi
|
||||
val classId = resolvedQualifier.classId
|
||||
val resultType = resolvedQualifier.resultType
|
||||
if (classId != null) {
|
||||
val classSymbol = symbolProvider.getClassLikeSymbolByFqName(classId)!!
|
||||
val classSymbol: FirClassLikeSymbol<*> = symbolProvider.getClassLikeSymbolByFqName(classId)!!
|
||||
val declaration = classSymbol.phasedFir
|
||||
if (declaration is FirClass) {
|
||||
if (declaration.classKind == ClassKind.OBJECT) {
|
||||
@@ -282,7 +284,7 @@ fun <T : FirResolvable> BodyResolveComponents.typeFromCallee(access: T): FirReso
|
||||
is FirThisReference -> {
|
||||
val labelName = newCallee.labelName
|
||||
val implicitReceiver = implicitReceiverStack[labelName]
|
||||
FirResolvedTypeRefImpl(null, implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName"), emptyList())
|
||||
FirResolvedTypeRefImpl(null, implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName"))
|
||||
}
|
||||
else -> error("Failed to extract type from: $newCallee")
|
||||
}
|
||||
@@ -309,10 +311,7 @@ private fun BodyResolveComponents.typeFromSymbol(symbol: AbstractFirBasedSymbol<
|
||||
"no enum item supertype"
|
||||
)
|
||||
} else
|
||||
FirResolvedTypeRefImpl(
|
||||
null, symbol.constructType(emptyArray(), isNullable = false),
|
||||
annotations = emptyList()
|
||||
)
|
||||
FirResolvedTypeRefImpl(null, symbol.constructType(emptyArray(), isNullable = false))
|
||||
}
|
||||
else -> error("WTF ! $symbol")
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSessionComponent
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirMemberFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.FirSyntheticFunctionSymbol
|
||||
@@ -22,6 +23,7 @@ import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
@@ -31,8 +33,8 @@ import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
interface FirSamResolver : FirSessionComponent {
|
||||
fun getFunctionTypeForPossibleSamType(type: ConeKotlinType): ConeKotlinType?
|
||||
fun shouldRunSamConversionForFunction(firNamedFunction: FirNamedFunction): Boolean
|
||||
fun getSamConstructor(firRegularClass: FirRegularClass): FirNamedFunction?
|
||||
fun shouldRunSamConversionForFunction(firNamedFunction: FirSimpleFunction): Boolean
|
||||
fun getSamConstructor(firRegularClass: FirRegularClass): FirSimpleFunction?
|
||||
}
|
||||
|
||||
private val NULL_STUB = Any()
|
||||
@@ -92,13 +94,13 @@ class FirSamResolverImpl(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun getSamConstructor(firRegularClass: FirRegularClass): FirNamedFunction? {
|
||||
override fun getSamConstructor(firRegularClass: FirRegularClass): FirSimpleFunction? {
|
||||
return samConstructor.getOrPut(firRegularClass) {
|
||||
buildSamConstructor(firRegularClass) ?: return@getOrPut NULL_STUB
|
||||
} as? FirNamedFunction
|
||||
} as? FirSimpleFunction
|
||||
}
|
||||
|
||||
private fun buildSamConstructor(firRegularClass: FirRegularClass): FirNamedFunction? {
|
||||
private fun buildSamConstructor(firRegularClass: FirRegularClass): FirSimpleFunction? {
|
||||
val functionType = resolveFunctionTypeIfSamInterface(firRegularClass) ?: return null
|
||||
|
||||
val classId = firRegularClass.classId
|
||||
@@ -112,7 +114,11 @@ class FirSamResolverImpl(
|
||||
|
||||
val newTypeParameters = firRegularClass.typeParameters.map { typeParameter ->
|
||||
FirTypeParameterImpl(
|
||||
firSession, typeParameter.psi, FirTypeParameterSymbol(), typeParameter.name, Variance.INVARIANT,
|
||||
typeParameter.psi,
|
||||
firSession,
|
||||
typeParameter.name,
|
||||
FirTypeParameterSymbol(),
|
||||
Variance.INVARIANT,
|
||||
isReified = false
|
||||
).apply {
|
||||
annotations += typeParameter.annotations
|
||||
@@ -141,27 +147,38 @@ class FirSamResolverImpl(
|
||||
firRegularClass.symbol.toLookupTag(), newTypeParameterTypes.toTypedArray(), isNullable = false
|
||||
)
|
||||
|
||||
return FirMemberFunctionImpl(
|
||||
firSession, null, symbol, classId.shortClassName,
|
||||
firRegularClass.visibility, Modality.FINAL,
|
||||
isExpect = firRegularClass.isExpect,
|
||||
isActual = firRegularClass.isActual,
|
||||
isOverride = false,
|
||||
isOperator = false,
|
||||
isInfix = false,
|
||||
isExternal = false,
|
||||
isInline = false,
|
||||
isSuspend = false,
|
||||
isTailRec = false,
|
||||
receiverTypeRef = null,
|
||||
returnTypeRef = FirResolvedTypeRefImpl(null, substitutedReturnType)
|
||||
val status = FirDeclarationStatusImpl(firRegularClass.visibility, Modality.FINAL).apply {
|
||||
isExpect = firRegularClass.isExpect
|
||||
isActual = firRegularClass.isActual
|
||||
isOverride = false
|
||||
isOperator = false
|
||||
isInfix = false
|
||||
isExternal = false
|
||||
isInline = false
|
||||
isSuspend = false
|
||||
isTailRec = false
|
||||
}
|
||||
|
||||
return FirSimpleFunctionImpl(
|
||||
null,
|
||||
firSession,
|
||||
FirResolvedTypeRefImpl(null, substitutedReturnType),
|
||||
null,
|
||||
classId.shortClassName,
|
||||
status,
|
||||
symbol
|
||||
).apply {
|
||||
valueParameters += listOf(
|
||||
FirValueParameterImpl(
|
||||
session, psi, SAM_PARAMETER_NAME,
|
||||
psi,
|
||||
session,
|
||||
FirResolvedTypeRefImpl(firRegularClass.psi, substitutedFunctionType),
|
||||
SAM_PARAMETER_NAME,
|
||||
FirVariableSymbol(SAM_PARAMETER_NAME),
|
||||
defaultValue = null,
|
||||
isCrossinline = false, isNoinline = false, isVararg = false
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isVararg = false
|
||||
)
|
||||
)
|
||||
typeParameters += newTypeParameters
|
||||
@@ -178,7 +195,7 @@ class FirSamResolverImpl(
|
||||
} as? ConeKotlinType
|
||||
}
|
||||
|
||||
override fun shouldRunSamConversionForFunction(firNamedFunction: FirNamedFunction): Boolean {
|
||||
override fun shouldRunSamConversionForFunction(firNamedFunction: FirSimpleFunction): Boolean {
|
||||
// TODO: properly support, see org.jetbrains.kotlin.load.java.sam.JvmSamConversionTransformer.shouldRunSamConversionForFunction
|
||||
return true
|
||||
}
|
||||
@@ -187,7 +204,7 @@ class FirSamResolverImpl(
|
||||
private fun FirRegularClass.getSingleAbstractMethodOrNull(
|
||||
session: FirSession,
|
||||
scopeSession: ScopeSession
|
||||
): FirNamedFunction? {
|
||||
): FirSimpleFunction? {
|
||||
// TODO: restrict to Java interfaces
|
||||
if (classKind != ClassKind.INTERFACE || hasMoreThenOneAbstractFunctionOrHasAbstractProperty()) return null
|
||||
|
||||
@@ -218,8 +235,8 @@ private fun FirRegularClass.findSingleAbstractMethodByNames(
|
||||
session: FirSession,
|
||||
scopeSession: ScopeSession,
|
||||
samCandidateNames: Set<Name>
|
||||
): FirNamedFunction? {
|
||||
var resultMethod: FirNamedFunction? = null
|
||||
): FirSimpleFunction? {
|
||||
var resultMethod: FirSimpleFunction? = null
|
||||
var metIncorrectMember = false
|
||||
|
||||
val classUseSiteMemberScope = session.firSymbolProvider.getClassUseSiteMemberScope(classId, session, scopeSession)
|
||||
@@ -241,8 +258,8 @@ private fun FirRegularClass.findSingleAbstractMethodByNames(
|
||||
|
||||
classUseSiteMemberScope.processFunctionsByName(candidateName) { functionSymbol ->
|
||||
val firFunction = functionSymbol.fir
|
||||
require(firFunction is FirNamedFunction) {
|
||||
"${functionSymbol.callableId.callableName} is expected to be FirNamedFunction, but ${functionSymbol::class} was found"
|
||||
require(firFunction is FirSimpleFunction) {
|
||||
"${functionSymbol.callableId.callableName} is expected to be _root_ide_package_.org.jetbrains.kotlin.fir.declarations.FirSimpleFunction, but ${functionSymbol::class} was found"
|
||||
}
|
||||
|
||||
if (firFunction.modality != Modality.ABSTRACT) return@processFunctionsByName ProcessorAction.NEXT
|
||||
@@ -266,7 +283,7 @@ private fun FirRegularClass.hasMoreThenOneAbstractFunctionOrHasAbstractProperty(
|
||||
var wasAbstractFunction = false
|
||||
for (declaration in declarations) {
|
||||
if (declaration is FirProperty && declaration.modality == Modality.ABSTRACT) return true
|
||||
if (declaration is FirNamedFunction && declaration.modality == Modality.ABSTRACT) {
|
||||
if (declaration is FirSimpleFunction && declaration.modality == Modality.ABSTRACT) {
|
||||
if (wasAbstractFunction) return true
|
||||
wasAbstractFunction = true
|
||||
}
|
||||
@@ -275,7 +292,7 @@ private fun FirRegularClass.hasMoreThenOneAbstractFunctionOrHasAbstractProperty(
|
||||
return false
|
||||
}
|
||||
|
||||
private fun FirNamedFunction.getFunctionTypeForAbstractMethod(session: FirSession): ConeLookupTagBasedType {
|
||||
private fun FirSimpleFunction.getFunctionTypeForAbstractMethod(session: FirSession): ConeLookupTagBasedType {
|
||||
val parameterTypes = valueParameters.map {
|
||||
it.returnTypeRef.coneTypeSafe<ConeKotlinType>() ?: ConeKotlinErrorType("No type for parameter $it")
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession): FirScope? {
|
||||
return when (this) {
|
||||
is ConeKotlinErrorType -> null
|
||||
is ConeClassErrorType -> null
|
||||
is ConeAbbreviatedType -> directExpansionType(useSiteSession)?.scope(useSiteSession, scopeSession)
|
||||
is ConeClassLikeType -> {
|
||||
// TODO: for ConeClassLikeType they might be a type alias instead of a regular class
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.resolve
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
@@ -14,7 +15,6 @@ import org.jetbrains.kotlin.fir.resolve.calls.ResolutionStageRunner
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.phasedFir
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
|
||||
interface SessionHolder {
|
||||
|
||||
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe
|
||||
@@ -39,7 +39,7 @@ fun resolveArgumentExpression(
|
||||
typeProvider: (FirExpression) -> FirTypeRef?
|
||||
) {
|
||||
return when (argument) {
|
||||
is FirFunctionCall, is FirCallLikeControlFlowExpression -> resolveSubCallArgument(
|
||||
is FirFunctionCall, is FirWhenExpression, is FirTryExpression -> resolveSubCallArgument(
|
||||
csBuilder,
|
||||
argument as FirResolvable,
|
||||
expectedType,
|
||||
@@ -248,7 +248,7 @@ private fun Candidate.getExpectedTypeWithSAMConversion(
|
||||
): ConeKotlinType? {
|
||||
if (candidateExpectedType.isBuiltinFunctionalType) return null
|
||||
// TODO: if (!callComponents.languageVersionSettings.supportsFeature(LanguageFeature.SamConversionPerArgument)) return null
|
||||
val firNamedFunction = symbol.fir as? FirNamedFunction ?: return null
|
||||
val firNamedFunction = symbol.fir as? FirSimpleFunction ?: return null
|
||||
if (!samResolver.shouldRunSamConversionForFunction(firNamedFunction)) return null
|
||||
|
||||
val argumentIsFunctional = when ((argument as? FirWrappedArgumentExpression)?.expression ?: argument) {
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ class InvokeReceiverCandidateCollector(
|
||||
val session = components.session
|
||||
val boundInvokeCallInfo = CallInfo(
|
||||
invokeCallInfo.callKind,
|
||||
FirQualifiedAccessExpressionImpl(null, false).apply {
|
||||
FirQualifiedAccessExpressionImpl(null).apply {
|
||||
calleeReference = FirNamedReferenceWithCandidate(
|
||||
null,
|
||||
(candidate.symbol as FirCallableSymbol<*>).callableId.callableName,
|
||||
|
||||
@@ -44,7 +44,7 @@ class CandidateFactory(
|
||||
|
||||
fun PostponedArgumentsAnalyzer.Context.addSubsystemFromExpression(expression: FirExpression) {
|
||||
when (expression) {
|
||||
is FirFunctionCall, is FirCallLikeControlFlowExpression -> (expression as FirResolvable).candidate()?.let { addOtherSystem(it.system.asReadOnlyStorage()) }
|
||||
is FirFunctionCall, is FirWhenExpression, is FirTryExpression -> (expression as FirResolvable).candidate()?.let { addOtherSystem(it.system.asReadOnlyStorage()) }
|
||||
is FirWrappedArgumentExpression -> addSubsystemFromExpression(expression.expression)
|
||||
is FirBlock -> expression.returnExpressions().forEach { addSubsystemFromExpression(it) }
|
||||
}
|
||||
|
||||
+3
-7
@@ -5,11 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
@@ -54,7 +50,7 @@ class ConeOverloadConflictResolver(
|
||||
|
||||
private fun createFlatSignature(call: Candidate): FlatSignature<Candidate> {
|
||||
return when (val declaration = call.symbol.fir) {
|
||||
is FirNamedFunction -> createFlatSignature(call, declaration)
|
||||
is FirSimpleFunction -> createFlatSignature(call, declaration)
|
||||
is FirConstructor -> createFlatSignature(call, declaration)
|
||||
is FirVariable<*> -> createFlatSignature(call, declaration)
|
||||
else -> error("Not supported: $declaration")
|
||||
@@ -81,7 +77,7 @@ class ConeOverloadConflictResolver(
|
||||
return type
|
||||
}
|
||||
|
||||
private fun createFlatSignature(call: Candidate, function: FirNamedFunction): FlatSignature<Candidate> {
|
||||
private fun createFlatSignature(call: Candidate, function: FirSimpleFunction): FlatSignature<Candidate> {
|
||||
return FlatSignature(
|
||||
call,
|
||||
function.typeParameters.map { it.symbol },
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParametersOwner
|
||||
import org.jetbrains.kotlin.fir.renderWithType
|
||||
import org.jetbrains.kotlin.fir.resolve.constructType
|
||||
import org.jetbrains.kotlin.fir.resolve.firSymbolProvider
|
||||
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystem
|
||||
internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() {
|
||||
override suspend fun check(candidate: Candidate, sink: CheckerSink, callInfo: CallInfo) {
|
||||
val declaration = candidate.symbol.fir
|
||||
if (declaration !is FirCallableMemberDeclaration<*> || declaration.typeParameters.isEmpty()) {
|
||||
if (declaration !is FirTypeParametersOwner || declaration.typeParameters.isEmpty()) {
|
||||
candidate.substitutor = ConeSubstitutor.Empty
|
||||
return
|
||||
}
|
||||
@@ -84,7 +84,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() {
|
||||
}
|
||||
|
||||
fun createToFreshVariableSubstitutorAndAddInitialConstraints(
|
||||
declaration: FirCallableMemberDeclaration<*>,
|
||||
declaration: FirTypeParametersOwner,
|
||||
candidate: Candidate,
|
||||
csBuilder: ConstraintSystemOperation
|
||||
): Pair<ConeSubstitutor, List<ConeTypeVariable>> {
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
@@ -14,7 +14,7 @@ class FirNamedReferenceWithCandidate(
|
||||
psi: PsiElement?,
|
||||
name: Name,
|
||||
val candidate: Candidate
|
||||
) : FirSimpleNamedReference(psi, name) {
|
||||
) : FirSimpleNamedReference(psi, name, candidate.symbol) {
|
||||
override val candidateSymbol: AbstractFirBasedSymbol<*>
|
||||
get() = candidate.symbol
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.classId
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirThisReceiverExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirImplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirImplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.renderWithType
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.isInner
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.EMPTY
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.TOWER_LEVEL
|
||||
|
||||
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.visibility
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.resolve.firProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyGetter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertySetter
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirMemberPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.modality
|
||||
import org.jetbrains.kotlin.fir.declarations.visibility
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||
@@ -39,7 +42,7 @@ class FirSyntheticPropertiesScope(
|
||||
symbol: FirFunctionSymbol<*>,
|
||||
processor: (FirCallableSymbol<*>) -> ProcessorAction
|
||||
): ProcessorAction {
|
||||
val fir = symbol.fir as? FirNamedFunction ?: return ProcessorAction.NEXT
|
||||
val fir = symbol.fir as? FirSimpleFunction ?: return ProcessorAction.NEXT
|
||||
|
||||
if (fir.typeParameters.isNotEmpty()) return ProcessorAction.NEXT
|
||||
if (fir.valueParameters.isNotEmpty()) return ProcessorAction.NEXT
|
||||
@@ -47,27 +50,29 @@ class FirSyntheticPropertiesScope(
|
||||
val synthetic = SyntheticPropertySymbol(CallableId(symbol.callableId.packageName, symbol.callableId.className, name))
|
||||
|
||||
val returnTypeRef = typeCalculator.tryCalculateReturnType(fir)
|
||||
FirMemberPropertyImpl(
|
||||
session,
|
||||
val status = FirDeclarationStatusImpl(fir.visibility, fir.modality).apply {
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
isConst = false
|
||||
isLateInit = false
|
||||
}
|
||||
FirPropertyImpl(
|
||||
null,
|
||||
session,
|
||||
returnTypeRef,
|
||||
null,
|
||||
synthetic,
|
||||
name,
|
||||
fir.visibility,
|
||||
fir.modality,
|
||||
isExpect = false,
|
||||
isActual = false,
|
||||
isOverride = false,
|
||||
isConst = false,
|
||||
isLateInit = false,
|
||||
receiverTypeRef = null,
|
||||
returnTypeRef = returnTypeRef,
|
||||
isVar = true,
|
||||
initializer = null,
|
||||
delegate = null
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
synthetic,
|
||||
false,
|
||||
status
|
||||
).apply {
|
||||
resolvePhase = fir.resolvePhase
|
||||
getter = FirDefaultPropertyGetter(this@FirSyntheticPropertiesScope.session, null, returnTypeRef, fir.visibility)
|
||||
setter = FirDefaultPropertySetter(this@FirSyntheticPropertiesScope.session, null, returnTypeRef, fir.visibility)
|
||||
getter = FirDefaultPropertyGetter(null, this@FirSyntheticPropertiesScope.session, returnTypeRef, fir.visibility)
|
||||
setter = FirDefaultPropertySetter(null, this@FirSyntheticPropertiesScope.session, returnTypeRef, fir.visibility)
|
||||
}
|
||||
return processor(synthetic)
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.calls
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
|
||||
+13
-1
@@ -5,7 +5,19 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.dfa
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ControlFlowGraph
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
|
||||
class FirControlFlowGraphReferenceImpl(val controlFlowGraph: ControlFlowGraph) : FirControlFlowGraphReference()
|
||||
class FirControlFlowGraphReferenceImpl(val controlFlowGraph: ControlFlowGraph) : FirControlFlowGraphReference {
|
||||
override val psi: PsiElement? get() = null
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirControlFlowGraphReference {
|
||||
return this
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -6,12 +6,13 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.dfa
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousInitializer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirThisReceiverExpressionImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.ImplicitReceiverStackImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.Condition.*
|
||||
@@ -19,7 +20,6 @@ import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirBodyResolveTransformer
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
@@ -477,7 +477,7 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC
|
||||
graphBuilder.exitConstExpresion(constExpression).mergeIncomingFlow()
|
||||
}
|
||||
|
||||
fun exitVariableDeclaration(variable: FirVariable<*>) {
|
||||
fun exitVariableDeclaration(variable: FirProperty) {
|
||||
val node = graphBuilder.exitVariableDeclaration(variable).mergeIncomingFlow()
|
||||
val initializer = variable.initializer ?: return
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.dfa
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.CFGNode
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner
|
||||
|
||||
interface Stack<T> {
|
||||
val size: Int
|
||||
|
||||
+9
-1
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.fir.declarations.FirAnonymousInitializer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
|
||||
class ControlFlowGraph(val name: String, val kind: Kind) {
|
||||
val nodes = mutableListOf<CFGNode<*>>()
|
||||
@@ -146,7 +148,7 @@ class StubNode(owner: ControlFlowGraph, level: Int) : CFGNode<FirStub>(owner, le
|
||||
override val fir: FirStub get() = FirStub
|
||||
}
|
||||
|
||||
class VariableDeclarationNode(owner: ControlFlowGraph, override val fir: FirVariable<*>, level: Int) : CFGNode<FirVariable<*>>(owner, level)
|
||||
class VariableDeclarationNode(owner: ControlFlowGraph, override val fir: FirProperty, level: Int) : CFGNode<FirProperty>(owner, level)
|
||||
class VariableAssignmentNode(owner: ControlFlowGraph, override val fir: FirVariableAssignment, level: Int) : CFGNode<FirVariableAssignment>(owner, level)
|
||||
|
||||
// ----------------------------------- Other -----------------------------------
|
||||
@@ -158,4 +160,10 @@ class AnnotationExitNode(owner: ControlFlowGraph, override val fir: FirAnnotatio
|
||||
|
||||
object FirStub : FirElement {
|
||||
override val psi: PsiElement? get() = null
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement {
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
+9
-10
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.resolve.dfa.cfg
|
||||
import org.jetbrains.kotlin.contracts.description.InvocationKind
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirAbstractPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.*
|
||||
@@ -56,8 +55,8 @@ class ControlFlowGraphBuilder {
|
||||
*/
|
||||
fun enterFunction(function: FirFunction<*>): Pair<FunctionEnterNode, CFGNode<*>?> {
|
||||
val name = when (function) {
|
||||
is FirNamedFunction -> function.name.asString()
|
||||
is FirAbstractPropertyAccessor -> if (function.isGetter) "<getter>" else "<setter>"
|
||||
is FirSimpleFunction -> function.name.asString()
|
||||
is FirPropertyAccessor -> if (function.isGetter) "<getter>" else "<setter>"
|
||||
is FirAnonymousFunction -> "<anonymous>" // TODO: add check to lambda or fun
|
||||
is FirConstructor -> function.name.asString()
|
||||
else -> throw IllegalArgumentException("Unknown function: ${function.render()}")
|
||||
@@ -323,13 +322,13 @@ class ControlFlowGraphBuilder {
|
||||
// ----------------------------------- Boolean operators -----------------------------------
|
||||
|
||||
fun enterBinaryAnd(binaryLogicExpression: FirBinaryLogicExpression): BinaryAndEnterNode {
|
||||
assert(binaryLogicExpression.kind == FirBinaryLogicExpression.OperationKind.AND)
|
||||
assert(binaryLogicExpression.kind == LogicOperationKind.AND)
|
||||
binaryAndExitNodes.push(createBinaryAndExitNode(binaryLogicExpression))
|
||||
return createBinaryAndEnterNode(binaryLogicExpression).also { addNewSimpleNode(it) }.also { levelCounter++ }
|
||||
}
|
||||
|
||||
fun exitLeftBinaryAndArgument(binaryLogicExpression: FirBinaryLogicExpression): Pair<BinaryAndExitLeftOperandNode, BinaryAndEnterRightOperandNode> {
|
||||
assert(binaryLogicExpression.kind == FirBinaryLogicExpression.OperationKind.AND)
|
||||
assert(binaryLogicExpression.kind == LogicOperationKind.AND)
|
||||
val lastNode = lastNodes.pop()
|
||||
val leftBooleanConstValue = lastNode.booleanConstValue
|
||||
|
||||
@@ -347,7 +346,7 @@ class ControlFlowGraphBuilder {
|
||||
|
||||
fun exitBinaryAnd(binaryLogicExpression: FirBinaryLogicExpression): BinaryAndExitNode {
|
||||
levelCounter--
|
||||
assert(binaryLogicExpression.kind == FirBinaryLogicExpression.OperationKind.AND)
|
||||
assert(binaryLogicExpression.kind == LogicOperationKind.AND)
|
||||
return binaryAndExitNodes.pop().also {
|
||||
val rightNode = lastNodes.pop()
|
||||
addEdge(rightNode, it, propagateDeadness = false, isDead = it.leftOperandNode.booleanConstValue == false)
|
||||
@@ -357,7 +356,7 @@ class ControlFlowGraphBuilder {
|
||||
}
|
||||
|
||||
fun enterBinaryOr(binaryLogicExpression: FirBinaryLogicExpression): BinaryOrEnterNode {
|
||||
assert(binaryLogicExpression.kind == FirBinaryLogicExpression.OperationKind.OR)
|
||||
assert(binaryLogicExpression.kind == LogicOperationKind.OR)
|
||||
binaryOrExitNodes.push(createBinaryOrExitNode(binaryLogicExpression))
|
||||
return createBinaryOrEnterNode(binaryLogicExpression).also {
|
||||
addNewSimpleNode(it)
|
||||
@@ -366,7 +365,7 @@ class ControlFlowGraphBuilder {
|
||||
|
||||
fun exitLeftBinaryOrArgument(binaryLogicExpression: FirBinaryLogicExpression): Pair<BinaryOrExitLeftOperandNode, BinaryOrEnterRightOperandNode> {
|
||||
levelCounter--
|
||||
assert(binaryLogicExpression.kind == FirBinaryLogicExpression.OperationKind.OR)
|
||||
assert(binaryLogicExpression.kind == LogicOperationKind.OR)
|
||||
val previousNode = lastNodes.pop()
|
||||
val leftBooleanValue = previousNode.booleanConstValue
|
||||
|
||||
@@ -384,7 +383,7 @@ class ControlFlowGraphBuilder {
|
||||
}
|
||||
|
||||
fun exitBinaryOr(binaryLogicExpression: FirBinaryLogicExpression): BinaryOrExitNode {
|
||||
assert(binaryLogicExpression.kind == FirBinaryLogicExpression.OperationKind.OR)
|
||||
assert(binaryLogicExpression.kind == LogicOperationKind.OR)
|
||||
levelCounter--
|
||||
return binaryOrExitNodes.pop().also {
|
||||
val rightNode = lastNodes.pop()
|
||||
@@ -497,7 +496,7 @@ class ControlFlowGraphBuilder {
|
||||
return createConstExpressionNode(constExpression).also { addNewSimpleNode(it) }
|
||||
}
|
||||
|
||||
fun exitVariableDeclaration(variable: FirVariable<*>): VariableDeclarationNode {
|
||||
fun exitVariableDeclaration(variable: FirProperty): VariableDeclarationNode {
|
||||
return createVariableDeclarationNode(variable).also { addNewSimpleNode(it) }
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ fun ControlFlowGraphBuilder.createAnnotationExitNode(fir: FirAnnotationCall): An
|
||||
fun ControlFlowGraphBuilder.createAnnotationEnterNode(fir: FirAnnotationCall): AnnotationEnterNode =
|
||||
AnnotationEnterNode(graph, fir, levelCounter)
|
||||
|
||||
fun ControlFlowGraphBuilder.createVariableDeclarationNode(fir: FirVariable<*>): VariableDeclarationNode =
|
||||
fun ControlFlowGraphBuilder.createVariableDeclarationNode(fir: FirProperty): VariableDeclarationNode =
|
||||
VariableDeclarationNode(graph, fir, levelCounter)
|
||||
|
||||
fun ControlFlowGraphBuilder.createConstExpressionNode(fir: FirConstExpression<*>): ConstExpressionNode =
|
||||
|
||||
+3
-8
@@ -6,12 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.dfa.cfg
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirAbstractPropertyAccessor
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirErrorFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirDoWhileLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirLoop
|
||||
import org.jetbrains.kotlin.fir.expressions.FirWhileLoop
|
||||
@@ -155,10 +150,10 @@ fun CFGNode<*>.render(): String =
|
||||
}
|
||||
|
||||
private fun FirFunction<*>.name(): String = when (this) {
|
||||
is FirNamedFunction -> name.asString()
|
||||
is FirSimpleFunction -> name.asString()
|
||||
is FirAnonymousFunction -> "anonymousFunction"
|
||||
is FirConstructor -> name.asString()
|
||||
is FirAbstractPropertyAccessor -> if (isGetter) "getter" else "setter"
|
||||
is FirPropertyAccessor -> if (isGetter) "getter" else "setter"
|
||||
is FirErrorFunction -> "errorFunction"
|
||||
else -> TODO(toString())
|
||||
}
|
||||
|
||||
+44
-46
@@ -12,10 +12,7 @@ import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirBuiltinAnnotationDeserializer
|
||||
import org.jetbrains.kotlin.fir.deserialization.FirDeserializationContext
|
||||
@@ -27,10 +24,7 @@ import org.jetbrains.kotlin.fir.resolve.getOrPut
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
@@ -99,7 +93,7 @@ class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider(
|
||||
}
|
||||
return lookup.getOrPut(classId, { FirClassSymbol(classId) }) { symbol ->
|
||||
if (shouldBeEnumEntry) {
|
||||
FirEnumEntryImpl(session, null, symbol, classId.shortClassName).apply {
|
||||
FirEnumEntryImpl(null, session, classId.shortClassName, symbol).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
}
|
||||
} else {
|
||||
@@ -169,80 +163,84 @@ class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider(
|
||||
val prefix = kind.classNamePrefix
|
||||
val arity = className.substring(prefix.length).toIntOrNull() ?: return null
|
||||
fictitiousFunctionSymbols.getOrPut(arity) {
|
||||
val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.ABSTRACT).apply {
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isInner = false
|
||||
isCompanion = false
|
||||
isData = false
|
||||
isInline = false
|
||||
}
|
||||
FirClassSymbol(this).apply {
|
||||
FirClassImpl(
|
||||
session,
|
||||
null,
|
||||
this,
|
||||
session,
|
||||
relativeClassName.shortName(),
|
||||
Visibilities.PUBLIC,
|
||||
Modality.ABSTRACT,
|
||||
isExpect = false,
|
||||
isActual = false,
|
||||
classKind = ClassKind.INTERFACE,
|
||||
isInner = false,
|
||||
isCompanion = false,
|
||||
isData = false,
|
||||
isInline = false
|
||||
status,
|
||||
ClassKind.INTERFACE,
|
||||
this
|
||||
).apply klass@{
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
typeParameters.addAll((1..arity).map {
|
||||
FirTypeParameterImpl(
|
||||
this@FirLibrarySymbolProviderImpl.session,
|
||||
null,
|
||||
FirTypeParameterSymbol(),
|
||||
this@FirLibrarySymbolProviderImpl.session,
|
||||
Name.identifier("P$it"),
|
||||
FirTypeParameterSymbol(),
|
||||
Variance.IN_VARIANCE,
|
||||
false
|
||||
)
|
||||
})
|
||||
typeParameters.add(
|
||||
FirTypeParameterImpl(
|
||||
this@FirLibrarySymbolProviderImpl.session,
|
||||
null,
|
||||
FirTypeParameterSymbol(),
|
||||
this@FirLibrarySymbolProviderImpl.session,
|
||||
Name.identifier("R"),
|
||||
FirTypeParameterSymbol(),
|
||||
Variance.OUT_VARIANCE,
|
||||
false
|
||||
)
|
||||
)
|
||||
val name = OperatorNameConventions.INVOKE
|
||||
val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.ABSTRACT).apply {
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
isOperator = true
|
||||
isInfix = false
|
||||
isInline = false
|
||||
isTailRec = false
|
||||
isExternal = false
|
||||
isSuspend = false
|
||||
}
|
||||
addDeclaration(
|
||||
FirMemberFunctionImpl(
|
||||
this@FirLibrarySymbolProviderImpl.session,
|
||||
FirSimpleFunctionImpl(
|
||||
null,
|
||||
FirNamedFunctionSymbol(CallableId(packageFqName, relativeClassName, name)),
|
||||
name,
|
||||
Visibilities.PUBLIC,
|
||||
Modality.ABSTRACT,
|
||||
isExpect = false,
|
||||
isActual = false,
|
||||
isOverride = false,
|
||||
isOperator = true,
|
||||
isInfix = false,
|
||||
isInline = false,
|
||||
isTailRec = false,
|
||||
isExternal = false,
|
||||
isSuspend = false,
|
||||
receiverTypeRef = null,
|
||||
returnTypeRef = FirResolvedTypeRefImpl(
|
||||
this@FirLibrarySymbolProviderImpl.session,
|
||||
FirResolvedTypeRefImpl(
|
||||
null,
|
||||
ConeTypeParameterTypeImpl(
|
||||
typeParameters.last().symbol.toLookupTag(),
|
||||
false
|
||||
)
|
||||
)
|
||||
),
|
||||
null,
|
||||
name,
|
||||
status,
|
||||
FirNamedFunctionSymbol(CallableId(packageFqName, relativeClassName, name))
|
||||
).apply {
|
||||
resolvePhase = FirResolvePhase.DECLARATIONS
|
||||
valueParameters += this@klass.typeParameters.dropLast(1).map { typeParameter ->
|
||||
val name = Name.identifier(typeParameter.name.asString().toLowerCase())
|
||||
FirValueParameterImpl(
|
||||
this@FirLibrarySymbolProviderImpl.session,
|
||||
null,
|
||||
Name.identifier(typeParameter.name.asString().toLowerCase()),
|
||||
this@FirLibrarySymbolProviderImpl.session,
|
||||
FirResolvedTypeRefImpl(
|
||||
null,
|
||||
ConeTypeParameterTypeImpl(typeParameter.symbol.toLookupTag(), false)
|
||||
),
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
defaultValue = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
@@ -251,7 +249,7 @@ class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider(
|
||||
}
|
||||
}
|
||||
)
|
||||
replaceSupertypes(listOf(session.builtinTypes.anyType))
|
||||
replaceSuperTypeRefs(listOf(session.builtinTypes.anyType))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -280,7 +278,7 @@ class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider(
|
||||
}
|
||||
|
||||
override fun getAllCallableNamesInClass(classId: ClassId): Set<Name> {
|
||||
return getClassDeclarations(classId).filterIsInstance<FirCallableMemberDeclaration<*>>().mapTo(mutableSetOf()) { it.name }
|
||||
return getClassDeclarations(classId).filterIsInstance<FirMemberDeclaration>().mapTo(mutableSetOf()) { it.name }
|
||||
}
|
||||
|
||||
private fun getClassDeclarations(classId: ClassId): List<FirDeclaration> {
|
||||
|
||||
@@ -85,25 +85,23 @@ class FirProviderImpl(val session: FirSession) : FirProvider() {
|
||||
state.classifierContainerFileMap[classId] = file
|
||||
}
|
||||
|
||||
override fun <F : FirCallableMemberDeclaration<F>> visitCallableMemberDeclaration(
|
||||
callableMemberDeclaration: FirCallableMemberDeclaration<F>
|
||||
) {
|
||||
val symbol = callableMemberDeclaration.symbol
|
||||
override fun <F : FirCallableDeclaration<F>> visitCallableDeclaration(callableDeclaration: FirCallableDeclaration<F>) {
|
||||
val symbol = callableDeclaration.symbol
|
||||
val callableId = symbol.callableId
|
||||
state.callableMap.merge(callableId, listOf(symbol)) { a, b -> a + b }
|
||||
state.callableContainerMap[symbol] = file
|
||||
}
|
||||
|
||||
override fun visitConstructor(constructor: FirConstructor) {
|
||||
visitCallableMemberDeclaration(constructor)
|
||||
visitCallableDeclaration(constructor)
|
||||
}
|
||||
|
||||
override fun visitNamedFunction(namedFunction: FirNamedFunction) {
|
||||
visitCallableMemberDeclaration(namedFunction)
|
||||
override fun visitSimpleFunction(simpleFunction: FirSimpleFunction) {
|
||||
visitCallableDeclaration(simpleFunction)
|
||||
}
|
||||
|
||||
override fun visitProperty(property: FirProperty) {
|
||||
visitCallableMemberDeclaration(property)
|
||||
visitCallableDeclaration(property)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
+12
-6
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvable
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
@@ -18,12 +19,13 @@ import org.jetbrains.kotlin.fir.resolve.transformers.MapArguments
|
||||
import org.jetbrains.kotlin.fir.resolve.typeFromCallee
|
||||
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
||||
import org.jetbrains.kotlin.fir.returnExpressions
|
||||
import org.jetbrains.kotlin.fir.transformSingle
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
||||
@@ -38,7 +40,8 @@ class FirCallCompleter(
|
||||
) : BodyResolveComponents by transformer {
|
||||
private val completer = ConstraintSystemCompleter(inferenceComponents)
|
||||
|
||||
fun <T : FirResolvable> completeCall(call: T, expectedTypeRef: FirTypeRef?): T {
|
||||
fun <T> completeCall(call: T, expectedTypeRef: FirTypeRef?): T
|
||||
where T : FirResolvable, T : FirStatement {
|
||||
val typeRef = typeFromCallee(call)
|
||||
if (typeRef.type is ConeKotlinErrorType) {
|
||||
if (call is FirExpression) {
|
||||
@@ -95,17 +98,20 @@ class FirCallCompleter(
|
||||
): Pair<List<FirExpression>, InferenceSession> {
|
||||
|
||||
val itParam = when {
|
||||
lambdaArgument.valueParameters.isEmpty() && parameters.size == 1 ->
|
||||
lambdaArgument.valueParameters.isEmpty() && parameters.size == 1 -> {
|
||||
val name = Name.identifier("it")
|
||||
FirValueParameterImpl(
|
||||
session,
|
||||
null,
|
||||
Name.identifier("it"),
|
||||
FirResolvedTypeRefImpl(null, parameters.single(), emptyList()),
|
||||
session,
|
||||
FirResolvedTypeRefImpl(null, parameters.single()),
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
defaultValue = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isVararg = false
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -8,8 +8,9 @@ package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.references.FirEmptyControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirEmptyControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.FirControlFlowGraphReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.ControlFlowGraph
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
@@ -24,7 +25,7 @@ object ControlFlowGraphReferenceTransformer : FirTransformer<ControlFlowGraph>()
|
||||
override fun <F : FirFunction<F>> transformFunction(
|
||||
function: FirFunction<F>,
|
||||
data: ControlFlowGraph
|
||||
): CompositeTransformResult<FirDeclaration> {
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
return (function.transformChildren(this, data) as FirFunction<*>).compose()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -6,11 +6,11 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
import org.jetbrains.kotlin.fir.visitors.FirDefaultTransformer
|
||||
|
||||
@@ -33,7 +33,7 @@ abstract class FirAbstractPhaseTransformer<D>(
|
||||
}
|
||||
|
||||
override fun transformDeclaration(declaration: FirDeclaration, data: D): CompositeTransformResult<FirDeclaration> {
|
||||
declaration.resolvePhase = transformerPhase
|
||||
declaration.replaceResolvePhase(transformerPhase)
|
||||
|
||||
return super.transformDeclaration(declaration, data)
|
||||
}
|
||||
|
||||
+75
-66
@@ -14,8 +14,9 @@ import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyExpressionBlock
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionWithSmartcastImpl
|
||||
import org.jetbrains.kotlin.fir.references.FirExplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.*
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.DataFlowInferenceContext
|
||||
@@ -26,6 +27,7 @@ import org.jetbrains.kotlin.fir.scopes.addImportingScopes
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType
|
||||
import org.jetbrains.kotlin.fir.symbols.*
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.*
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
@@ -100,7 +102,7 @@ open class FirBodyResolveTransformer(
|
||||
this.file = file
|
||||
return withScopeCleanup(topLevelScopes) {
|
||||
topLevelScopes.addImportingScopes(file, session, scopeSession)
|
||||
super.transformFile(file, data)
|
||||
super.transformFile(file, data) as CompositeTransformResult<FirFile>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +113,7 @@ open class FirBodyResolveTransformer(
|
||||
|
||||
override fun transformConstructor(constructor: FirConstructor, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
if (implicitTypeOnly) return constructor.compose()
|
||||
return transformFunction(constructor, data)
|
||||
return transformFunction(constructor, data) as CompositeTransformResult<FirDeclaration>
|
||||
}
|
||||
|
||||
override fun transformAnonymousInitializer(
|
||||
@@ -128,6 +130,10 @@ open class FirBodyResolveTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformTypeRef(typeRef: FirTypeRef, data: Any?): CompositeTransformResult<FirTypeRef> {
|
||||
return typeRef.compose()
|
||||
}
|
||||
|
||||
override fun transformImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: Any?): CompositeTransformResult<FirTypeRef> {
|
||||
if (data == null)
|
||||
return implicitTypeRef.compose()
|
||||
@@ -135,16 +141,16 @@ open class FirBodyResolveTransformer(
|
||||
return data.compose()
|
||||
}
|
||||
|
||||
override fun transformValueParameter(valueParameter: FirValueParameter, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformValueParameter(valueParameter: FirValueParameter, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
localScopes.lastOrNull()?.storeDeclaration(valueParameter)
|
||||
if (valueParameter.returnTypeRef is FirImplicitTypeRef) {
|
||||
valueParameter.resolvePhase = transformerPhase
|
||||
valueParameter.replaceResolvePhase(transformerPhase)
|
||||
return valueParameter.compose() // TODO
|
||||
}
|
||||
return transformDeclaration(valueParameter, valueParameter.returnTypeRef)
|
||||
return (transformDeclaration(valueParameter, valueParameter.returnTypeRef).single as FirStatement).compose()
|
||||
}
|
||||
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
val oldConstructorScope = primaryConstructorParametersScope
|
||||
primaryConstructorParametersScope = null
|
||||
val type = regularClass.defaultType()
|
||||
@@ -158,18 +164,7 @@ open class FirBodyResolveTransformer(
|
||||
transformDeclaration(regularClass, data)
|
||||
}
|
||||
primaryConstructorParametersScope = oldConstructorScope
|
||||
return result
|
||||
}
|
||||
|
||||
override fun transformUncheckedNotNullCast(
|
||||
uncheckedNotNullCast: FirUncheckedNotNullCast,
|
||||
data: Any?
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
val notNullCast = transformExpression(uncheckedNotNullCast, data).single as FirUncheckedNotNullCast
|
||||
val resultType = notNullCast.expression.resultType
|
||||
notNullCast.resultType =
|
||||
resultType.withReplacedConeType(resultType.coneTypeUnsafe<ConeKotlinType>().withNullability(ConeNullability.NOT_NULL))
|
||||
return notNullCast.compose()
|
||||
return result as CompositeTransformResult<FirStatement>
|
||||
}
|
||||
|
||||
override fun transformTypeOperatorCall(typeOperatorCall: FirTypeOperatorCall, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
@@ -179,8 +174,7 @@ open class FirBodyResolveTransformer(
|
||||
FirOperation.IS, FirOperation.NOT_IS -> {
|
||||
resolved.resultType = FirResolvedTypeRefImpl(
|
||||
null,
|
||||
StandardClassIds.Boolean(symbolProvider).constructType(emptyArray(), isNullable = false),
|
||||
emptyList()
|
||||
StandardClassIds.Boolean(symbolProvider).constructType(emptyArray(), isNullable = false)
|
||||
)
|
||||
}
|
||||
FirOperation.AS -> {
|
||||
@@ -207,10 +201,11 @@ open class FirBodyResolveTransformer(
|
||||
is FirExplicitThisReference -> {
|
||||
val labelName = callee.labelName
|
||||
val implicitReceiver = implicitReceiverStack[labelName]
|
||||
callee.boundSymbol = implicitReceiver?.boundSymbol
|
||||
implicitReceiver?.boundSymbol?.let {
|
||||
callee.replaceBoundSymbol(it)
|
||||
}
|
||||
qualifiedAccessExpression.resultType = FirResolvedTypeRefImpl(
|
||||
null, implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName"),
|
||||
emptyList()
|
||||
null, implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName")
|
||||
)
|
||||
qualifiedAccessExpression
|
||||
}
|
||||
@@ -255,6 +250,13 @@ open class FirBodyResolveTransformer(
|
||||
return result.compose()
|
||||
}
|
||||
|
||||
override fun transformThisReceiverExpression(
|
||||
thisReceiverExpression: FirThisReceiverExpression,
|
||||
data: Any?
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
return transformQualifiedAccessExpression(thisReceiverExpression, data)
|
||||
}
|
||||
|
||||
private fun transformQualifiedAccessUsingSmartcastInfo(qualifiedAccessExpression: FirQualifiedAccessExpression): FirQualifiedAccessExpression {
|
||||
val typesFromSmartCast = dataFlowAnalyzer.getTypeUsingSmartcastInfo(qualifiedAccessExpression) ?: return qualifiedAccessExpression
|
||||
val allTypes = typesFromSmartCast.toMutableList().also {
|
||||
@@ -262,9 +264,10 @@ open class FirBodyResolveTransformer(
|
||||
}
|
||||
val intersectedType = ConeTypeIntersector.intersectTypes(inferenceComponents.ctx as ConeInferenceContext, allTypes)
|
||||
// TODO: add check that intersectedType is not equal to original type
|
||||
return FirExpressionWithSmartcastImpl(qualifiedAccessExpression, typesFromSmartCast).also {
|
||||
it.resultType = FirResolvedTypeRefImpl(qualifiedAccessExpression.resultType.psi, intersectedType, qualifiedAccessExpression.resultType.annotations)
|
||||
val intersectedTypeRef = FirResolvedTypeRefImpl(qualifiedAccessExpression.resultType.psi, intersectedType).apply {
|
||||
annotations += qualifiedAccessExpression.resultType.annotations
|
||||
}
|
||||
return FirExpressionWithSmartcastImpl(qualifiedAccessExpression, intersectedTypeRef, typesFromSmartCast)
|
||||
}
|
||||
|
||||
override fun transformVariableAssignment(
|
||||
@@ -286,7 +289,7 @@ open class FirBodyResolveTransformer(
|
||||
return result.compose()
|
||||
}
|
||||
|
||||
override fun transformAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
return when (data) {
|
||||
null -> {
|
||||
anonymousFunction.compose()
|
||||
@@ -306,17 +309,20 @@ open class FirBodyResolveTransformer(
|
||||
else {
|
||||
val singleParameterType = resolvedLambdaAtom.parameters.singleOrNull()
|
||||
val itParam = when {
|
||||
af.valueParameters.isEmpty() && singleParameterType != null ->
|
||||
af.valueParameters.isEmpty() && singleParameterType != null -> {
|
||||
val name = Name.identifier("it")
|
||||
FirValueParameterImpl(
|
||||
session,
|
||||
null,
|
||||
Name.identifier("it"),
|
||||
FirResolvedTypeRefImpl(null, singleParameterType, emptyList()),
|
||||
session,
|
||||
FirResolvedTypeRefImpl(null, singleParameterType),
|
||||
name,
|
||||
FirVariableSymbol(name),
|
||||
defaultValue = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isVararg = false
|
||||
)
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
if (itParam != null) {
|
||||
@@ -347,7 +353,7 @@ open class FirBodyResolveTransformer(
|
||||
?: returnTypeRefFromResolvedAtom
|
||||
?: af.returnTypeRef
|
||||
)
|
||||
af = af.transformValueParameters(ImplicitToErrorTypeTransformer, null) as FirAnonymousFunction
|
||||
af = af.transformValueParameters(ImplicitToErrorTypeTransformer, null)
|
||||
val bodyExpectedType = returnTypeRefFromResolvedAtom ?: data
|
||||
af = transformFunction(af, bodyExpectedType).single as FirAnonymousFunction
|
||||
af = af.copy(
|
||||
@@ -357,7 +363,7 @@ open class FirBodyResolveTransformer(
|
||||
af.compose()
|
||||
}
|
||||
else -> {
|
||||
transformFunction(anonymousFunction, data)
|
||||
transformFunction(anonymousFunction, data).single.compose()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -367,7 +373,7 @@ open class FirBodyResolveTransformer(
|
||||
return element.compose()
|
||||
}
|
||||
|
||||
override fun transformValueParameter(valueParameter: FirValueParameter, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformValueParameter(valueParameter: FirValueParameter, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
if (valueParameter.returnTypeRef is FirImplicitTypeRef) {
|
||||
valueParameter.transformReturnTypeRef(
|
||||
StoreType,
|
||||
@@ -593,7 +599,7 @@ open class FirBodyResolveTransformer(
|
||||
|
||||
val type = ConeClassTypeImpl(symbol.toLookupTag(), emptyArray(), isNullable = kind == IrConstKind.Null)
|
||||
|
||||
constExpression.resultType = FirResolvedTypeRefImpl(null, type, emptyList())
|
||||
constExpression.resultType = FirResolvedTypeRefImpl(null, type)
|
||||
} else {
|
||||
constExpression.resultType = if (kind != IrConstKind.Null) {
|
||||
expectedType.resolvedTypeFromPrototype(
|
||||
@@ -623,7 +629,7 @@ open class FirBodyResolveTransformer(
|
||||
}.compose()
|
||||
}
|
||||
|
||||
override fun <F : FirFunction<F>> transformFunction(function: FirFunction<F>, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun <F : FirFunction<F>> transformFunction(function: FirFunction<F>, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
return withScopeCleanup(localScopes) {
|
||||
localScopes += FirLocalScope()
|
||||
dataFlowAnalyzer.enterFunction(function)
|
||||
@@ -632,7 +638,7 @@ open class FirBodyResolveTransformer(
|
||||
dataFlowAnalyzer.exitFunction(result)?.let { controlFlowGraph ->
|
||||
result.transformControlFlowGraphReference(ControlFlowGraphReferenceTransformer, controlFlowGraph)
|
||||
}
|
||||
}
|
||||
} as CompositeTransformResult<FirStatement>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,7 +647,7 @@ open class FirBodyResolveTransformer(
|
||||
returnTypeRef: FirTypeRef,
|
||||
receiverTypeRef: FirTypeRef? = null
|
||||
): CompositeTransformResult<FirDeclaration> {
|
||||
if (function is FirNamedFunction) {
|
||||
if (function is FirSimpleFunction) {
|
||||
localScopes.lastOrNull()?.storeDeclaration(function)
|
||||
}
|
||||
val result = transformFunction(function, returnTypeRef).single as FirFunction<*>
|
||||
@@ -654,23 +660,23 @@ open class FirBodyResolveTransformer(
|
||||
}.compose()
|
||||
}
|
||||
|
||||
override fun transformNamedFunction(namedFunction: FirNamedFunction, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
val returnTypeRef = namedFunction.returnTypeRef
|
||||
override fun transformSimpleFunction(simpleFunction: FirSimpleFunction, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
val returnTypeRef = simpleFunction.returnTypeRef
|
||||
if ((returnTypeRef !is FirImplicitTypeRef) && implicitTypeOnly) {
|
||||
return namedFunction.compose()
|
||||
return simpleFunction.compose()
|
||||
}
|
||||
return withFullBodyResolve {
|
||||
if (returnTypeRef is FirImplicitTypeRef) {
|
||||
namedFunction.transformReturnTypeRef(StoreType, FirComputingImplicitTypeRef)
|
||||
simpleFunction.transformReturnTypeRef(StoreType, FirComputingImplicitTypeRef)
|
||||
}
|
||||
|
||||
val receiverTypeRef = namedFunction.receiverTypeRef
|
||||
val receiverTypeRef = simpleFunction.receiverTypeRef
|
||||
if (receiverTypeRef != null) {
|
||||
withLabelAndReceiverType(namedFunction.name, namedFunction, receiverTypeRef.coneTypeUnsafe()) {
|
||||
transformFunctionWithGivenSignature(namedFunction, returnTypeRef, receiverTypeRef)
|
||||
withLabelAndReceiverType(simpleFunction.name, simpleFunction, receiverTypeRef.coneTypeUnsafe()) {
|
||||
transformFunctionWithGivenSignature(simpleFunction, returnTypeRef, receiverTypeRef)
|
||||
}
|
||||
} else {
|
||||
transformFunctionWithGivenSignature(namedFunction, returnTypeRef)
|
||||
transformFunctionWithGivenSignature(simpleFunction, returnTypeRef)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -699,7 +705,7 @@ open class FirBodyResolveTransformer(
|
||||
}
|
||||
} else {
|
||||
transformFunctionWithGivenSignature(accessor, expectedReturnTypeRef)
|
||||
}
|
||||
} as CompositeTransformResult<FirStatement>
|
||||
}
|
||||
|
||||
private fun storeVariableReturnType(variable: FirVariable<*>) {
|
||||
@@ -742,6 +748,11 @@ open class FirBodyResolveTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirProperty.transformChildrenWithoutAccessors(returnTypeRef: FirTypeRef): FirProperty {
|
||||
return transformReturnTypeRef(this@FirBodyResolveTransformer, returnTypeRef).
|
||||
transformOtherChildren(this@FirBodyResolveTransformer, returnTypeRef)
|
||||
}
|
||||
|
||||
private fun <F : FirVariable<F>> FirVariable<F>.transformAccessors() {
|
||||
var enhancedTypeRef = returnTypeRef
|
||||
getter?.let {
|
||||
@@ -771,21 +782,21 @@ open class FirBodyResolveTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
override fun <F : FirVariable<F>> transformVariable(variable: FirVariable<F>, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
variable.transformChildrenWithoutAccessors(this, variable.returnTypeRef)
|
||||
private fun transformLocalVariable(variable: FirProperty, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
assert(variable.isLocal)
|
||||
variable.transformOtherChildren(this, variable.returnTypeRef)
|
||||
if (variable.initializer != null) {
|
||||
storeVariableReturnType(variable)
|
||||
}
|
||||
variable.transformAccessors()
|
||||
if (variable !is FirProperty) {
|
||||
localScopes.lastOrNull()?.storeDeclaration(variable)
|
||||
}
|
||||
variable.resolvePhase = transformerPhase
|
||||
localScopes.lastOrNull()?.storeDeclaration(variable)
|
||||
variable.replaceResolvePhase(transformerPhase)
|
||||
dataFlowAnalyzer.exitVariableDeclaration(variable)
|
||||
return variable.compose()
|
||||
}
|
||||
|
||||
override fun transformProperty(property: FirProperty, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
if (property.isLocal) return transformLocalVariable(property, data)
|
||||
val returnTypeRef = property.returnTypeRef
|
||||
if (returnTypeRef !is FirImplicitTypeRef && implicitTypeOnly) return property.compose()
|
||||
if (property.resolvePhase == transformerPhase) return property.compose()
|
||||
@@ -797,7 +808,7 @@ open class FirBodyResolveTransformer(
|
||||
withScopeCleanup(localScopes) {
|
||||
localScopes.addIfNotNull(primaryConstructorParametersScope)
|
||||
withContainer(property) {
|
||||
property.transformChildrenWithoutAccessors(this, returnTypeRef)
|
||||
property.transformChildrenWithoutAccessors(returnTypeRef)
|
||||
if (property.initializer != null) {
|
||||
storeVariableReturnType(property)
|
||||
}
|
||||
@@ -808,7 +819,7 @@ open class FirBodyResolveTransformer(
|
||||
property.transformAccessors()
|
||||
}
|
||||
}
|
||||
property.resolvePhase = transformerPhase
|
||||
property.replaceResolvePhase(transformerPhase)
|
||||
val controlFlowGraph = dataFlowAnalyzer.exitProperty(property)
|
||||
property.transformControlFlowGraphReference(ControlFlowGraphReferenceTransformer, controlFlowGraph)
|
||||
property.compose()
|
||||
@@ -850,8 +861,7 @@ open class FirBodyResolveTransformer(
|
||||
transformedGetClassCall.resultType =
|
||||
FirResolvedTypeRefImpl(
|
||||
null,
|
||||
kClassSymbol.constructType(arrayOf(typeOfExpression), false),
|
||||
emptyList()
|
||||
kClassSymbol.constructType(arrayOf(typeOfExpression), false)
|
||||
)
|
||||
return transformedGetClassCall.compose()
|
||||
}
|
||||
@@ -862,17 +872,16 @@ open class FirBodyResolveTransformer(
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
val booleanType = builtinTypes.booleanType
|
||||
return when (binaryLogicExpression.kind) {
|
||||
FirBinaryLogicExpression.OperationKind.AND ->
|
||||
LogicOperationKind.AND ->
|
||||
binaryLogicExpression.also(dataFlowAnalyzer::enterBinaryAnd)
|
||||
.transformLeftOperand(this, booleanType).also(dataFlowAnalyzer::exitLeftBinaryAndArgument)
|
||||
.transformRightOperand(this, booleanType).also(dataFlowAnalyzer::exitBinaryAnd)
|
||||
|
||||
FirBinaryLogicExpression.OperationKind.OR ->
|
||||
LogicOperationKind.OR ->
|
||||
binaryLogicExpression.also(dataFlowAnalyzer::enterBinaryOr)
|
||||
.transformLeftOperand(this, booleanType).also(dataFlowAnalyzer::exitLeftBinaryOrArgument)
|
||||
.transformRightOperand(this, booleanType).also(dataFlowAnalyzer::exitBinaryOr)
|
||||
|
||||
}.transformRestChildren(this, booleanType).also {
|
||||
}.transformOtherChildren(this, booleanType).also {
|
||||
it.resultType = booleanType
|
||||
}.compose()
|
||||
}
|
||||
@@ -893,14 +902,14 @@ open class FirBodyResolveTransformer(
|
||||
return whileLoop.also(dataFlowAnalyzer::enterWhileLoop)
|
||||
.transformCondition(this, data).also(dataFlowAnalyzer::exitWhileLoopCondition)
|
||||
.transformBlock(this, data).also(dataFlowAnalyzer::exitWhileLoop)
|
||||
.transformRestChildren(this, data).compose()
|
||||
.transformOtherChildren(this, data).compose()
|
||||
}
|
||||
|
||||
override fun transformDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
return doWhileLoop.also(dataFlowAnalyzer::enterDoWhileLoop)
|
||||
.transformBlock(this, data).also(dataFlowAnalyzer::enterDoWhileLoopCondition)
|
||||
.transformCondition(this, data).also(dataFlowAnalyzer::exitDoWhileLoop)
|
||||
.transformRestChildren(this, data).compose()
|
||||
.transformOtherChildren(this, data).compose()
|
||||
}
|
||||
|
||||
// ----------------------- Util functions -----------------------
|
||||
@@ -1028,7 +1037,7 @@ class FirImplicitTypeBodyResolveTransformerAdapter : FirTransformer<Nothing?>()
|
||||
|
||||
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
||||
val transformer = FirBodyResolveTransformer(
|
||||
file.fileSession,
|
||||
file.session,
|
||||
phase = FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE,
|
||||
implicitTypeOnly = true,
|
||||
scopeSession = scopeSession
|
||||
@@ -1049,7 +1058,7 @@ class FirBodyResolveTransformerAdapter : FirTransformer<Nothing?>() {
|
||||
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
||||
// Despite of real phase is EXPRESSIONS, we state IMPLICIT_TYPES here, because DECLARATIONS previous phase is OK for us
|
||||
val transformer = FirBodyResolveTransformer(
|
||||
file.fileSession,
|
||||
file.session,
|
||||
phase = FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE,
|
||||
implicitTypeOnly = false,
|
||||
scopeSession = scopeSession
|
||||
|
||||
+6
-6
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.copy
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirResolvedCallableReferenceImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.candidate
|
||||
import org.jetbrains.kotlin.fir.resolve.constructFunctionalTypeRef
|
||||
@@ -88,15 +88,15 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
val typeRef = argument.typeRef as FirResolvedTypeRef
|
||||
FirTypeProjectionWithVarianceImpl(
|
||||
argument.psi,
|
||||
argument.variance,
|
||||
typeRef.withReplacedConeType(type)
|
||||
typeRef.withReplacedConeType(type),
|
||||
argument.variance
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
FirTypeProjectionWithVarianceImpl(
|
||||
argument?.psi,
|
||||
Variance.INVARIANT,
|
||||
FirResolvedTypeRefImpl(null, type, emptyList())
|
||||
FirResolvedTypeRefImpl(null, type),
|
||||
Variance.INVARIANT
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
override fun transformAnonymousFunction(
|
||||
anonymousFunction: FirAnonymousFunction,
|
||||
data: Nothing?
|
||||
): CompositeTransformResult<FirDeclaration> {
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
val initialType = anonymousFunction.returnTypeRef.coneTypeSafe<ConeKotlinType>()
|
||||
if (initialType != null) {
|
||||
val finalType = finalSubstitutor.substituteOrNull(initialType)
|
||||
|
||||
+2
-2
@@ -33,8 +33,8 @@ class FirImportResolveTransformer() : FirAbstractTreeTransformer(phase = FirReso
|
||||
}
|
||||
|
||||
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
||||
session = file.fileSession
|
||||
symbolProvider = FirSymbolProvider.getInstance(file.fileSession)
|
||||
session = file.session
|
||||
symbolProvider = FirSymbolProvider.getInstance(file.session)
|
||||
return file.also { it.transformChildren(this, null) }.compose()
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -7,8 +7,6 @@ package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.resolve.FirTypeResolver
|
||||
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
@@ -34,21 +32,23 @@ class FirSpecificTypeResolverTransformer(
|
||||
functionTypeRef.transformChildren(this, data)
|
||||
return FirResolvedFunctionTypeRefImpl(
|
||||
functionTypeRef.psi,
|
||||
typeResolver.resolveType(functionTypeRef, towerScope, position),
|
||||
functionTypeRef.isMarkedNullable,
|
||||
functionTypeRef.annotations as MutableList<FirAnnotationCall>,
|
||||
functionTypeRef.receiverTypeRef,
|
||||
functionTypeRef.valueParameters as MutableList<FirValueParameter>,
|
||||
functionTypeRef.returnTypeRef,
|
||||
typeResolver.resolveType(functionTypeRef, towerScope, position)
|
||||
).compose()
|
||||
functionTypeRef.returnTypeRef
|
||||
).apply {
|
||||
annotations += functionTypeRef.annotations
|
||||
valueParameters += functionTypeRef.valueParameters
|
||||
}.compose()
|
||||
}
|
||||
|
||||
private fun transformType(typeRef: FirTypeRef, resolvedType: ConeKotlinType): CompositeTransformResult<FirTypeRef> {
|
||||
return FirResolvedTypeRefImpl(
|
||||
typeRef.psi,
|
||||
resolvedType,
|
||||
typeRef.annotations
|
||||
).compose()
|
||||
resolvedType
|
||||
).apply {
|
||||
annotations += typeRef.annotations
|
||||
}.compose()
|
||||
}
|
||||
|
||||
override fun transformResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: Nothing?): CompositeTransformResult<FirTypeRef> {
|
||||
|
||||
+12
-14
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
import org.jetbrains.kotlin.fir.visitors.compose
|
||||
|
||||
@@ -42,7 +43,7 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer(phase = FirResolv
|
||||
when {
|
||||
visibility == Visibilities.PRIVATE ->
|
||||
Modality.FINAL
|
||||
this is FirNamedFunction && body == null ->
|
||||
this is FirSimpleFunction && body == null ->
|
||||
Modality.ABSTRACT
|
||||
this is FirProperty && initializer == null && getter?.body == null && setter?.body == null ->
|
||||
Modality.ABSTRACT
|
||||
@@ -62,7 +63,7 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer(phase = FirResolv
|
||||
override lateinit var session: FirSession
|
||||
|
||||
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
||||
session = file.fileSession
|
||||
session = file.session
|
||||
return transformElement(file, data)
|
||||
}
|
||||
|
||||
@@ -108,10 +109,10 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer(phase = FirResolv
|
||||
return transformMemberDeclaration(typeAlias, data)
|
||||
}
|
||||
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
return storeClass(regularClass) {
|
||||
transformMemberDeclaration(regularClass, data)
|
||||
}
|
||||
} as CompositeTransformResult<FirStatement>
|
||||
}
|
||||
|
||||
override fun transformMemberDeclaration(
|
||||
@@ -126,10 +127,10 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer(phase = FirResolv
|
||||
override fun transformPropertyAccessor(
|
||||
propertyAccessor: FirPropertyAccessor,
|
||||
data: Nothing?
|
||||
): CompositeTransformResult<FirDeclaration> {
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
return storeDeclaration(propertyAccessor) {
|
||||
transformDeclaration(propertyAccessor, data)
|
||||
}
|
||||
} as CompositeTransformResult<FirStatement>
|
||||
}
|
||||
|
||||
override fun transformConstructor(
|
||||
@@ -141,12 +142,9 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer(phase = FirResolv
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformNamedFunction(
|
||||
namedFunction: FirNamedFunction,
|
||||
data: Nothing?
|
||||
): CompositeTransformResult<FirDeclaration> {
|
||||
return storeDeclaration(namedFunction) {
|
||||
transformDeclaration(namedFunction, data)
|
||||
override fun transformSimpleFunction(simpleFunction: FirSimpleFunction, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
return storeDeclaration(simpleFunction) {
|
||||
transformDeclaration(simpleFunction, data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +157,7 @@ class FirStatusResolveTransformer : FirAbstractTreeTransformer(phase = FirResolv
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformValueParameter(valueParameter: FirValueParameter, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
return transformDeclaration(valueParameter, data)
|
||||
override fun transformValueParameter(valueParameter: FirValueParameter, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
return (transformDeclaration(valueParameter, data).single as FirStatement).compose()
|
||||
}
|
||||
}
|
||||
+29
-18
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.scopes.FirPosition
|
||||
@@ -27,21 +28,24 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
|
||||
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
||||
initFromFile(file)
|
||||
return transformElement(file, data)
|
||||
return transformDeclaration(file, data) as CompositeTransformResult<FirFile>
|
||||
}
|
||||
|
||||
fun initFromFile(file: FirFile) {
|
||||
session = file.fileSession
|
||||
session = file.session
|
||||
this.file = file
|
||||
}
|
||||
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
val transformedClass = resolveSupertypesOrExpansions(regularClass) as? FirRegularClass ?: regularClass
|
||||
|
||||
// resolve supertypes for nested classes
|
||||
return transformElement(transformedClass, data)
|
||||
return transformDeclaration(transformedClass, data) as CompositeTransformResult<FirStatement>
|
||||
}
|
||||
|
||||
override fun transformEnumEntry(enumEntry: FirEnumEntry, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
return transformRegularClass(enumEntry, data)
|
||||
}
|
||||
|
||||
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
val result = resolveSupertypesOrExpansions(typeAlias)
|
||||
@@ -67,15 +71,15 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
return constructor.compose()
|
||||
}
|
||||
|
||||
override fun transformNamedFunction(namedFunction: FirNamedFunction, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
return namedFunction.compose()
|
||||
override fun transformSimpleFunction(simpleFunction: FirSimpleFunction, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
return simpleFunction.compose()
|
||||
}
|
||||
|
||||
override fun transformProperty(property: FirProperty, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
return property.compose()
|
||||
}
|
||||
|
||||
override fun <F : FirFunction<F>> transformFunction(function: FirFunction<F>, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun <F : FirFunction<F>> transformFunction(function: FirFunction<F>, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
return function.compose()
|
||||
}
|
||||
|
||||
@@ -106,7 +110,11 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
towerScope.addImportingScopes(file, session, scopeSession)
|
||||
}
|
||||
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformEnumEntry(enumEntry: FirEnumEntry, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
return transformRegularClass(enumEntry, data)
|
||||
}
|
||||
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
val classId = regularClass.classId
|
||||
if (!isOuterClass(classId, requestedClassId)) return regularClass.compose()
|
||||
val transformedClass = withScopeCleanup {
|
||||
@@ -115,10 +123,13 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
regularClass.addTypeParametersScope()
|
||||
|
||||
val transformer = FirSpecificTypeResolverTransformer(towerScope, FirPosition.SUPER_TYPE_OR_EXPANSION, session)
|
||||
val resolvedTypesRefs = regularClass.superTypeRefs.map { transformer.transformTypeRef(it, data).single }
|
||||
val resolvedTypesRefs = regularClass.superTypeRefs.map {
|
||||
transformer.transformTypeRef(it, data).single
|
||||
}
|
||||
|
||||
val resultingTypeRefs = resolveLoops(regularClass, classId, resolvedTypesRefs)
|
||||
regularClass.replaceSupertypes(resultingTypeRefs)
|
||||
regularClass.replaceSuperTypeRefs(resultingTypeRefs)
|
||||
regularClass
|
||||
}
|
||||
|
||||
if (regularClass.matchesRequestedDeclaration()) {
|
||||
@@ -146,9 +157,9 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
val resolvedTypesRef = transformer.transformTypeRef(typeAlias.expandedTypeRef, data).single
|
||||
val resultingTypeRef = resolveLoops(typeAlias, classId, listOf(resolvedTypesRef)).firstOrNull()
|
||||
|
||||
typeAlias.replaceExpandTypeRef(resultingTypeRef ?: resolvedTypesRef).also {
|
||||
resultingClass = it
|
||||
}
|
||||
typeAlias.replaceExpandedTypeRef(resultingTypeRef ?: resolvedTypesRef)
|
||||
resultingClass = typeAlias
|
||||
typeAlias
|
||||
}.compose()
|
||||
}
|
||||
|
||||
@@ -157,7 +168,7 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
classId: ClassId,
|
||||
resolvedTypesRefs: List<FirTypeRef>
|
||||
): List<FirTypeRef> {
|
||||
firClassLikeDeclaration.supertypesComputationStatus = FirClassLikeDeclaration.SupertypesComputationStatus.COMPUTING
|
||||
firClassLikeDeclaration.replaceSupertypesComputationStatus(SupertypesComputationStatus.COMPUTING)
|
||||
|
||||
val resultingTypeRefs = mutableListOf<FirTypeRef>()
|
||||
for (superTypeRef in resolvedTypesRefs) {
|
||||
@@ -196,7 +207,7 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
resultingTypeRefs.add(superTypeRef)
|
||||
}
|
||||
|
||||
firClassLikeDeclaration.supertypesComputationStatus = FirClassLikeDeclaration.SupertypesComputationStatus.COMPUTED
|
||||
firClassLikeDeclaration.replaceSupertypesComputationStatus(SupertypesComputationStatus.COMPUTED)
|
||||
return resultingTypeRefs
|
||||
}
|
||||
|
||||
@@ -208,7 +219,7 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
||||
private fun resolveNestedClassesSupertypes(
|
||||
regularClass: FirRegularClass,
|
||||
data: Nothing?
|
||||
): CompositeTransformResult<FirDeclaration> {
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
return withScopeCleanup {
|
||||
// ? Is it Ok to use original file session here ?
|
||||
val firProvider = FirProvider.getInstance(session)
|
||||
@@ -236,6 +247,6 @@ private fun isOuterClass(outerCandidate: ClassId, innerCandidate: ClassId) =
|
||||
private fun ClassId.outerClasses() = generateSequence(this, ClassId::getOuterClassId)
|
||||
|
||||
private fun FirClassLikeDeclaration<*>.areSupertypesComputed() =
|
||||
supertypesComputationStatus == FirClassLikeDeclaration.SupertypesComputationStatus.COMPUTED
|
||||
supertypesComputationStatus == SupertypesComputationStatus.COMPUTED
|
||||
private fun FirClassLikeDeclaration<*>.areSupertypesComputing() =
|
||||
supertypesComputationStatus == FirClassLikeDeclaration.SupertypesComputationStatus.COMPUTING
|
||||
supertypesComputationStatus == SupertypesComputationStatus.COMPUTING
|
||||
|
||||
+44
-34
@@ -10,19 +10,21 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.copy
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirMemberFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirSimpleFunctionImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirTypeParameterImpl
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirTryExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirStubReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirStubReference
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.SyntheticCallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||
@@ -32,12 +34,14 @@ import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
class FirSyntheticCallGenerator(private val transformer: FirBodyResolveTransformer) : BodyResolveComponents by transformer {
|
||||
private val whenSelectFunction: FirMemberFunctionImpl = generateSyntheticSelectFunction(SyntheticCallableId.WHEN)
|
||||
private val trySelectFunction: FirMemberFunctionImpl = generateSyntheticSelectFunction(SyntheticCallableId.TRY)
|
||||
private val whenSelectFunction: FirSimpleFunctionImpl = generateSyntheticSelectFunction(SyntheticCallableId.WHEN)
|
||||
private val trySelectFunction: FirSimpleFunctionImpl = generateSyntheticSelectFunction(SyntheticCallableId.TRY)
|
||||
|
||||
fun generateCalleeForWhenExpression(whenExpression: FirWhenExpression): FirWhenExpression? {
|
||||
val stubReference = whenExpression.calleeReference
|
||||
assert(stubReference is FirStubReference)
|
||||
// TODO: Investigate: assertion failed in ModularizedTest
|
||||
// assert(stubReference is FirStubReference)
|
||||
if (stubReference !is FirStubReference) return null
|
||||
|
||||
val arguments = whenExpression.branches.map { it.result }
|
||||
val reference = generateCalleeReferenceWithCandidate(
|
||||
@@ -72,7 +76,7 @@ class FirSyntheticCallGenerator(private val transformer: FirBodyResolveTransform
|
||||
}
|
||||
|
||||
private fun generateCalleeReferenceWithCandidate(
|
||||
function: FirMemberFunctionImpl,
|
||||
function: FirSimpleFunctionImpl,
|
||||
arguments: List<FirExpression>,
|
||||
name: Name
|
||||
): FirNamedReferenceWithCandidate? {
|
||||
@@ -86,7 +90,7 @@ class FirSyntheticCallGenerator(private val transformer: FirBodyResolveTransform
|
||||
return FirNamedReferenceWithCandidate(null, name, candidate)
|
||||
}
|
||||
|
||||
private fun generateCandidate(callInfo: CallInfo, function: FirMemberFunctionImpl): Candidate =
|
||||
private fun generateCandidate(callInfo: CallInfo, function: FirSimpleFunctionImpl): Candidate =
|
||||
CandidateFactory(transformer, callInfo).createCandidate(
|
||||
symbol = function.symbol,
|
||||
dispatchReceiverValue = null,
|
||||
@@ -105,15 +109,15 @@ class FirSyntheticCallGenerator(private val transformer: FirBodyResolveTransform
|
||||
container = container
|
||||
) { it.resultType }
|
||||
|
||||
private fun generateSyntheticSelectFunction(callableId: CallableId): FirMemberFunctionImpl {
|
||||
private fun generateSyntheticSelectFunction(callableId: CallableId): FirSimpleFunctionImpl {
|
||||
val functionSymbol = FirSyntheticFunctionSymbol(callableId)
|
||||
val typeParameterSymbol = FirTypeParameterSymbol()
|
||||
val typeParameter = FirTypeParameterImpl(session, null, typeParameterSymbol, Name.identifier("K"), Variance.INVARIANT, false)
|
||||
val typeParameter = FirTypeParameterImpl(null, session, Name.identifier("K"), typeParameterSymbol, Variance.INVARIANT, false)
|
||||
|
||||
val returnType = FirResolvedTypeRefImpl(null, ConeTypeParameterTypeImpl(typeParameterSymbol.toLookupTag(), false))
|
||||
|
||||
val argumentType = FirResolvedTypeRefImpl(null, returnType.coneTypeUnsafe<ConeKotlinType>().createArrayOf(session))
|
||||
val typeArgument = FirTypeProjectionWithVarianceImpl(null, Variance.INVARIANT, returnType)
|
||||
val typeArgument = FirTypeProjectionWithVarianceImpl(null, returnType, Variance.INVARIANT)
|
||||
|
||||
return generateMemberFunction(session, functionSymbol, callableId.callableName, typeArgument.typeRef).apply {
|
||||
typeParameters += typeParameter
|
||||
@@ -121,39 +125,45 @@ class FirSyntheticCallGenerator(private val transformer: FirBodyResolveTransform
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateMemberFunction(session: FirSession, symbol: FirNamedFunctionSymbol, name: Name, returnType: FirTypeRef) =
|
||||
FirMemberFunctionImpl(
|
||||
private fun generateMemberFunction(session: FirSession, symbol: FirNamedFunctionSymbol, name: Name, returnType: FirTypeRef): FirSimpleFunctionImpl {
|
||||
val status = FirDeclarationStatusImpl(Visibilities.PUBLIC, Modality.FINAL).apply {
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
isOperator = false
|
||||
isInfix = false
|
||||
isInline = false
|
||||
isTailRec = false
|
||||
isExternal = false
|
||||
isSuspend = false
|
||||
}
|
||||
return FirSimpleFunctionImpl(
|
||||
session = session,
|
||||
psi = null,
|
||||
symbol = symbol,
|
||||
name = name,
|
||||
visibility = Visibilities.PUBLIC,
|
||||
modality = Modality.FINAL,
|
||||
isExpect = false,
|
||||
isActual = false,
|
||||
isOverride = false,
|
||||
isOperator = false,
|
||||
isInfix = false,
|
||||
isInline = false,
|
||||
isTailRec = false,
|
||||
isExternal = false,
|
||||
isSuspend = false,
|
||||
status = status,
|
||||
receiverTypeRef = null,
|
||||
returnTypeRef = returnType
|
||||
).apply {
|
||||
this.resolvePhase = FirResolvePhase.BODY_RESOLVE
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirResolvedTypeRef.toValueParameter(session: FirSession, name: String, isVararg: Boolean = false) = FirValueParameterImpl(
|
||||
session = session,
|
||||
psi = null,
|
||||
name = Name.identifier(name),
|
||||
returnTypeRef = this,
|
||||
defaultValue = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isVararg = isVararg
|
||||
).apply {
|
||||
this.resolvePhase = FirResolvePhase.BODY_RESOLVE
|
||||
private fun FirResolvedTypeRef.toValueParameter(session: FirSession, name: String, isVararg: Boolean = false): FirValueParameterImpl {
|
||||
val name = Name.identifier(name)
|
||||
return FirValueParameterImpl(
|
||||
session = session,
|
||||
psi = null,
|
||||
name = name,
|
||||
returnTypeRef = this,
|
||||
defaultValue = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isVararg = isVararg,
|
||||
symbol = FirVariableSymbol(name)
|
||||
).apply {
|
||||
this.resolvePhase = FirResolvePhase.BODY_RESOLVE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+8
-7
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
@@ -27,7 +28,7 @@ open class FirTypeResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(
|
||||
override lateinit var session: FirSession
|
||||
|
||||
override fun transformFile(file: FirFile, data: Nothing?): CompositeTransformResult<FirFile> {
|
||||
session = file.fileSession
|
||||
session = file.session
|
||||
val scopeSession = ScopeSession()
|
||||
return withScopeCleanup {
|
||||
towerScope.addImportingScopes(file, session, scopeSession)
|
||||
@@ -35,7 +36,7 @@ open class FirTypeResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformRegularClass(regularClass: FirRegularClass, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
withScopeCleanup {
|
||||
regularClass.addTypeParametersScope()
|
||||
regularClass.typeParameters.forEach {
|
||||
@@ -58,7 +59,7 @@ open class FirTypeResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(
|
||||
towerScope.scopes += FirNestedClassifierScope(classId, firProvider)
|
||||
regularClass.addTypeParametersScope()
|
||||
|
||||
transformDeclaration(regularClass, data)
|
||||
transformDeclaration(regularClass, data) as CompositeTransformResult<FirStatement>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,10 +85,10 @@ open class FirTypeResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformNamedFunction(namedFunction: FirNamedFunction, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformSimpleFunction(simpleFunction: FirSimpleFunction, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
return withScopeCleanup {
|
||||
namedFunction.addTypeParametersScope()
|
||||
transformDeclaration(namedFunction, data)
|
||||
simpleFunction.addTypeParametersScope()
|
||||
transformDeclaration(simpleFunction, data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ open class FirTypeResolveTransformer : FirAbstractTreeTransformerWithSuperTypes(
|
||||
return FirSpecificTypeResolverTransformer(towerScope, FirPosition.OTHER, session).transformTypeRef(typeRef, data)
|
||||
}
|
||||
|
||||
override fun transformValueParameter(valueParameter: FirValueParameter, data: Nothing?): CompositeTransformResult<FirDeclaration> {
|
||||
override fun transformValueParameter(valueParameter: FirValueParameter, data: Nothing?): CompositeTransformResult<FirStatement> {
|
||||
val result = transformDeclaration(valueParameter, data).single as FirValueParameter
|
||||
if (result.isVararg) {
|
||||
val returnTypeRef = result.returnTypeRef
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ object InvocationKindTransformer : FirTransformer<InvocationKind?>() {
|
||||
override fun transformAnonymousFunction(
|
||||
anonymousFunction: FirAnonymousFunction,
|
||||
data: InvocationKind?
|
||||
): CompositeTransformResult<FirDeclaration> {
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
if (data != null) {
|
||||
anonymousFunction.replaceInvocationKind(data)
|
||||
}
|
||||
|
||||
+3
-2
@@ -6,12 +6,12 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolve.FirProvider
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
|
||||
@@ -27,7 +27,8 @@ fun <D> AbstractFirBasedSymbol<D>.phasedFir(
|
||||
is FirCallableSymbol<*> -> provider.getFirCallableContainerFile(this)
|
||||
is FirClassLikeSymbol<*> -> provider.getFirClassifierContainerFile(this)
|
||||
else -> null
|
||||
} ?: throw AssertionError("Cannot get container file by symbol: $this (${result.render()})")
|
||||
}
|
||||
?: throw AssertionError("Cannot get container file by symbol: $this (${result.render()})")
|
||||
containingFile.runResolve(toPhase = requiredPhase, fromPhase = availablePhase)
|
||||
}
|
||||
return result
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ class ReturnTypeCalculatorWithJump(val session: FirSession, val scopeSession: Sc
|
||||
|
||||
val transformer = FirDesignatedBodyResolveTransformer(
|
||||
(listOf(file) + outerClasses.filterNotNull().asReversed() + listOf(declaration)).iterator(),
|
||||
file.fileSession,
|
||||
file.session,
|
||||
scopeSession
|
||||
)
|
||||
|
||||
|
||||
+2
-2
@@ -6,10 +6,10 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirNamedReference
|
||||
import org.jetbrains.kotlin.fir.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedCallableReference
|
||||
import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ abstract class AbstractFirOverrideScope(val session: FirSession) : FirScope() {
|
||||
private fun isEqualTypes(a: FirTypeRef, b: FirTypeRef, substitution: ConeSubstitutor) =
|
||||
isEqualTypes(a.cast<FirResolvedTypeRef>().type, b.cast<FirResolvedTypeRef>().type, substitution)
|
||||
|
||||
private fun isOverriddenFunCheck(member: FirNamedFunction, self: FirNamedFunction): Boolean {
|
||||
private fun isOverriddenFunCheck(member: FirSimpleFunction, self: FirSimpleFunction): Boolean {
|
||||
if (member.valueParameters.size != self.valueParameters.size) return false
|
||||
if (member.typeParameters.size != self.typeParameters.size) return false
|
||||
|
||||
@@ -63,7 +63,7 @@ abstract class AbstractFirOverrideScope(val session: FirSession) : FirScope() {
|
||||
|
||||
fun similarFunctionsOrBothProperties(declaration: FirCallableDeclaration<*>, self: FirCallableDeclaration<*>): Boolean {
|
||||
return when (declaration) {
|
||||
is FirNamedFunction -> self is FirNamedFunction && isOverriddenFunCheck(declaration, self)
|
||||
is FirSimpleFunction -> self is FirSimpleFunction && isOverriddenFunCheck(declaration, self)
|
||||
is FirConstructor -> false
|
||||
is FirProperty -> self is FirProperty && sameReceivers(
|
||||
declaration.receiverTypeRef,
|
||||
|
||||
+30
-16
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
@@ -105,7 +105,7 @@ class FirClassSubstitutionScope(
|
||||
companion object {
|
||||
fun createFakeOverrideFunction(
|
||||
session: FirSession,
|
||||
baseFunction: FirNamedFunction,
|
||||
baseFunction: FirSimpleFunction,
|
||||
baseSymbol: FirNamedFunctionSymbol,
|
||||
newReceiverType: ConeKotlinType? = null,
|
||||
newReturnType: ConeKotlinType? = null,
|
||||
@@ -115,23 +115,30 @@ class FirClassSubstitutionScope(
|
||||
with(baseFunction) {
|
||||
// TODO: consider using here some light-weight functions instead of pseudo-real FirMemberFunctionImpl
|
||||
// As second alternative, we can invent some light-weight kind of FirRegularClass
|
||||
FirMemberFunctionImpl(
|
||||
FirSimpleFunctionImpl(
|
||||
psi,
|
||||
session,
|
||||
psi, symbol, name,
|
||||
baseFunction.returnTypeRef.withReplacedConeType(newReturnType),
|
||||
baseFunction.receiverTypeRef?.withReplacedConeType(newReceiverType),
|
||||
baseFunction.returnTypeRef.withReplacedConeType(newReturnType)
|
||||
name,
|
||||
baseFunction.status,
|
||||
symbol
|
||||
).apply {
|
||||
resolvePhase = baseFunction.resolvePhase
|
||||
status = baseFunction.status as FirDeclarationStatusImpl
|
||||
valueParameters += baseFunction.valueParameters.zip(
|
||||
newParameterTypes ?: List(baseFunction.valueParameters.size) { null }
|
||||
) { valueParameter, newType ->
|
||||
with(valueParameter) {
|
||||
FirValueParameterImpl(
|
||||
session, psi,
|
||||
name, this.returnTypeRef.withReplacedConeType(newType),
|
||||
defaultValue, isCrossinline, isNoinline, isVararg,
|
||||
FirVariableSymbol(valueParameter.symbol.callableId)
|
||||
psi,
|
||||
session,
|
||||
this.returnTypeRef.withReplacedConeType(newType),
|
||||
name,
|
||||
FirVariableSymbol(valueParameter.symbol.callableId),
|
||||
defaultValue,
|
||||
isCrossinline,
|
||||
isNoinline,
|
||||
isVararg
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -149,15 +156,20 @@ class FirClassSubstitutionScope(
|
||||
): FirPropertySymbol {
|
||||
val symbol = FirPropertySymbol(baseSymbol.callableId, true, baseSymbol)
|
||||
with(baseProperty) {
|
||||
FirMemberPropertyImpl(
|
||||
FirPropertyImpl(
|
||||
psi,
|
||||
session,
|
||||
psi, symbol, name,
|
||||
baseProperty.receiverTypeRef?.withReplacedConeType(newReceiverType),
|
||||
baseProperty.returnTypeRef.withReplacedConeType(newReturnType),
|
||||
isVar, initializer = null, delegate = null
|
||||
baseProperty.receiverTypeRef?.withReplacedConeType(newReceiverType),
|
||||
name,
|
||||
null,
|
||||
null,
|
||||
isVar,
|
||||
symbol,
|
||||
false,
|
||||
baseProperty.status
|
||||
).apply {
|
||||
resolvePhase = baseProperty.resolvePhase
|
||||
status = baseProperty.status as FirDeclarationStatusImpl
|
||||
}
|
||||
}
|
||||
return symbol
|
||||
@@ -170,6 +182,8 @@ fun FirTypeRef.withReplacedConeType(newType: ConeKotlinType?): FirResolvedTypeRe
|
||||
require(this is FirResolvedTypeRef)
|
||||
if (newType == null) return this
|
||||
|
||||
return FirResolvedTypeRefImpl(psi, newType, annotations = annotations)
|
||||
return FirResolvedTypeRefImpl(psi, newType).apply {
|
||||
annotations += this@withReplacedConeType.annotations
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,11 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirBackingFieldReference
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.expressions.FirVariable
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.NAME_FOR_BACKING_FIELD
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
@@ -26,12 +23,12 @@ class FirLocalScope : FirScope() {
|
||||
fun storeDeclaration(declaration: FirNamedDeclaration) {
|
||||
when (declaration) {
|
||||
is FirVariable<*> -> properties[declaration.name] = declaration.symbol
|
||||
is FirNamedFunction -> functions[declaration.name] = declaration.symbol as FirNamedFunctionSymbol
|
||||
is FirSimpleFunction -> functions[declaration.name] = declaration.symbol as FirNamedFunctionSymbol
|
||||
}
|
||||
}
|
||||
|
||||
fun storeBackingField(property: FirProperty) {
|
||||
properties[FirBackingFieldReference.NAME] = property.backingFieldSymbol
|
||||
properties[NAME_FOR_BACKING_FIELD] = property.backingFieldSymbol
|
||||
}
|
||||
|
||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> ProcessorAction): ProcessorAction {
|
||||
|
||||
@@ -9,9 +9,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.expandedConeType
|
||||
import org.jetbrains.kotlin.fir.declarations.superConeTypes
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeTypeVariableTypeConstructor
|
||||
|
||||
@@ -5,18 +5,26 @@ digraph initBlockAndInPlaceLambda_kt {
|
||||
|
||||
subgraph cluster_0 {
|
||||
color=red
|
||||
0 [label="Enter property" style="filled" fillcolor=red];
|
||||
1 [label="Exit property" style="filled" fillcolor=red];
|
||||
0 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
1 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
0 -> {1};
|
||||
|
||||
subgraph cluster_1 {
|
||||
color=red
|
||||
2 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
3 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
2 [label="Enter property" style="filled" fillcolor=red];
|
||||
3 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
2 -> {3};
|
||||
|
||||
subgraph cluster_2 {
|
||||
color=red
|
||||
4 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
5 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
4 -> {5};
|
||||
|
||||
}
|
||||
|
||||
+53
-53
@@ -107,15 +107,45 @@ digraph lambdas_kt {
|
||||
|
||||
subgraph cluster_11 {
|
||||
color=red
|
||||
32 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||
32 [label="Enter function test_2" style="filled" fillcolor=red];
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
33 [label="Enter block"];
|
||||
34 [label="Access variable R|<local>/x|"];
|
||||
35 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
|
||||
36 [label="Exit block"];
|
||||
subgraph cluster_13 {
|
||||
color=blue
|
||||
34 [label="Enter when"];
|
||||
subgraph cluster_14 {
|
||||
color=blue
|
||||
35 [label="Enter when branch condition "];
|
||||
36 [label="Access variable R|<local>/x|"];
|
||||
37 [label="Type operator: x is Int"];
|
||||
38 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_15 {
|
||||
color=blue
|
||||
39 [label="Enter when branch condition else"];
|
||||
40 [label="Exit when branch condition"];
|
||||
}
|
||||
41 [label="Enter when branch result"];
|
||||
subgraph cluster_16 {
|
||||
color=blue
|
||||
42 [label="Enter block"];
|
||||
43 [label="Exit block"];
|
||||
}
|
||||
44 [label="Exit when branch result"];
|
||||
45 [label="Enter when branch result"];
|
||||
subgraph cluster_17 {
|
||||
color=blue
|
||||
46 [label="Enter block"];
|
||||
47 [label="Variable declaration: lval lambda: R|kotlin/Function0<kotlin/Int>|"];
|
||||
48 [label="Exit block"];
|
||||
}
|
||||
49 [label="Exit when branch result"];
|
||||
50 [label="Exit when"];
|
||||
}
|
||||
51 [label="Exit block"];
|
||||
}
|
||||
37 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||
52 [label="Exit function test_2" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
32 -> {33};
|
||||
@@ -123,65 +153,35 @@ digraph lambdas_kt {
|
||||
34 -> {35};
|
||||
35 -> {36};
|
||||
36 -> {37};
|
||||
|
||||
subgraph cluster_13 {
|
||||
color=red
|
||||
38 [label="Enter function test_2" style="filled" fillcolor=red];
|
||||
subgraph cluster_14 {
|
||||
color=blue
|
||||
39 [label="Enter block"];
|
||||
subgraph cluster_15 {
|
||||
color=blue
|
||||
40 [label="Enter when"];
|
||||
subgraph cluster_16 {
|
||||
color=blue
|
||||
41 [label="Enter when branch condition "];
|
||||
42 [label="Access variable R|<local>/x|"];
|
||||
43 [label="Type operator: x is Int"];
|
||||
44 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_17 {
|
||||
color=blue
|
||||
45 [label="Enter when branch condition else"];
|
||||
46 [label="Exit when branch condition"];
|
||||
}
|
||||
47 [label="Enter when branch result"];
|
||||
subgraph cluster_18 {
|
||||
color=blue
|
||||
48 [label="Enter block"];
|
||||
49 [label="Exit block"];
|
||||
}
|
||||
50 [label="Exit when branch result"];
|
||||
51 [label="Enter when branch result"];
|
||||
subgraph cluster_19 {
|
||||
color=blue
|
||||
52 [label="Enter block"];
|
||||
53 [label="Variable declaration: lval lambda: R|kotlin/Function0<kotlin/Int>|"];
|
||||
54 [label="Exit block"];
|
||||
}
|
||||
55 [label="Exit when branch result"];
|
||||
56 [label="Exit when"];
|
||||
}
|
||||
57 [label="Exit block"];
|
||||
}
|
||||
58 [label="Exit function test_2" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
38 -> {39};
|
||||
37 -> {38};
|
||||
38 -> {45 39};
|
||||
39 -> {40};
|
||||
40 -> {41};
|
||||
41 -> {42};
|
||||
42 -> {43};
|
||||
43 -> {44};
|
||||
44 -> {51 45};
|
||||
44 -> {50};
|
||||
45 -> {46};
|
||||
46 -> {47};
|
||||
47 -> {48};
|
||||
48 -> {49};
|
||||
49 -> {50};
|
||||
50 -> {56};
|
||||
50 -> {51};
|
||||
51 -> {52};
|
||||
52 -> {53};
|
||||
|
||||
subgraph cluster_18 {
|
||||
color=red
|
||||
53 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||
subgraph cluster_19 {
|
||||
color=blue
|
||||
54 [label="Enter block"];
|
||||
55 [label="Access variable R|<local>/x|"];
|
||||
56 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
|
||||
57 [label="Exit block"];
|
||||
}
|
||||
58 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
53 -> {54};
|
||||
54 -> {55};
|
||||
55 -> {56};
|
||||
|
||||
+147
-131
@@ -22,143 +22,151 @@ digraph propertiesAndInitBlocks_kt {
|
||||
|
||||
subgraph cluster_2 {
|
||||
color=red
|
||||
5 [label="Enter property" style="filled" fillcolor=red];
|
||||
6 [label="Const: Int(1)"];
|
||||
7 [label="Exit property" style="filled" fillcolor=red];
|
||||
5 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
6 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
5 -> {6};
|
||||
6 -> {7};
|
||||
|
||||
subgraph cluster_3 {
|
||||
color=red
|
||||
8 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
subgraph cluster_4 {
|
||||
color=blue
|
||||
9 [label="Enter block"];
|
||||
10 [label="Const: Int(1)"];
|
||||
11 [label="Jump: ^ Int(1)"];
|
||||
12 [label="Stub" style="filled" fillcolor=gray];
|
||||
13 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
14 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
7 [label="Enter property" style="filled" fillcolor=red];
|
||||
8 [label="Const: Int(1)"];
|
||||
9 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
7 -> {8};
|
||||
8 -> {9};
|
||||
9 -> {10};
|
||||
10 -> {11};
|
||||
11 -> {14};
|
||||
11 -> {12} [style=dotted];
|
||||
12 -> {13} [style=dotted];
|
||||
13 -> {14} [style=dotted];
|
||||
|
||||
subgraph cluster_5 {
|
||||
subgraph cluster_4 {
|
||||
color=red
|
||||
15 [label="Enter function setter" style="filled" fillcolor=red];
|
||||
subgraph cluster_6 {
|
||||
10 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
subgraph cluster_5 {
|
||||
color=blue
|
||||
16 [label="Enter block"];
|
||||
17 [label="Const: Int(1)"];
|
||||
18 [label="Assignmenet: F|/x2|"];
|
||||
19 [label="Exit block"];
|
||||
11 [label="Enter block"];
|
||||
12 [label="Const: Int(1)"];
|
||||
13 [label="Jump: ^ Int(1)"];
|
||||
14 [label="Stub" style="filled" fillcolor=gray];
|
||||
15 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
20 [label="Exit function setter" style="filled" fillcolor=red];
|
||||
16 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
10 -> {11};
|
||||
11 -> {12};
|
||||
12 -> {13};
|
||||
13 -> {16};
|
||||
13 -> {14} [style=dotted];
|
||||
14 -> {15} [style=dotted];
|
||||
15 -> {16} [style=dotted];
|
||||
|
||||
subgraph cluster_6 {
|
||||
color=red
|
||||
17 [label="Enter function setter" style="filled" fillcolor=red];
|
||||
subgraph cluster_7 {
|
||||
color=blue
|
||||
18 [label="Enter block"];
|
||||
19 [label="Const: Int(1)"];
|
||||
20 [label="Assignmenet: F|/x2|"];
|
||||
21 [label="Exit block"];
|
||||
}
|
||||
22 [label="Exit function setter" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
15 -> {16};
|
||||
16 -> {17};
|
||||
17 -> {18};
|
||||
18 -> {19};
|
||||
19 -> {20};
|
||||
|
||||
subgraph cluster_7 {
|
||||
color=red
|
||||
21 [label="Enter property" style="filled" fillcolor=red];
|
||||
22 [label="Const: Int(1)"];
|
||||
23 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
20 -> {21};
|
||||
21 -> {22};
|
||||
22 -> {23};
|
||||
|
||||
subgraph cluster_8 {
|
||||
color=red
|
||||
24 [label="Enter function foo" style="filled" fillcolor=red];
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
25 [label="Enter block"];
|
||||
26 [label="Const: Int(1)"];
|
||||
27 [label="Const: Int(1)"];
|
||||
28 [label="Function call: Int(1).R|kotlin/Int.plus|(Int(1))"];
|
||||
29 [label="Variable declaration: lval c: R|kotlin/Int|"];
|
||||
30 [label="Function call: R|java/lang/Exception.Exception|()"];
|
||||
31 [label="Throw: throw R|java/lang/Exception.Exception|()"];
|
||||
32 [label="Stub" style="filled" fillcolor=gray];
|
||||
33 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
34 [label="Exit function foo" style="filled" fillcolor=red];
|
||||
23 [label="Enter property" style="filled" fillcolor=red];
|
||||
24 [label="Const: Int(1)"];
|
||||
25 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
23 -> {24};
|
||||
24 -> {25};
|
||||
25 -> {26};
|
||||
|
||||
subgraph cluster_9 {
|
||||
color=red
|
||||
26 [label="Enter function foo" style="filled" fillcolor=red];
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
27 [label="Enter block"];
|
||||
28 [label="Const: Int(1)"];
|
||||
29 [label="Const: Int(1)"];
|
||||
30 [label="Function call: Int(1).R|kotlin/Int.plus|(Int(1))"];
|
||||
31 [label="Variable declaration: lval c: R|kotlin/Int|"];
|
||||
32 [label="Function call: R|java/lang/Exception.Exception|()"];
|
||||
33 [label="Throw: throw R|java/lang/Exception.Exception|()"];
|
||||
34 [label="Stub" style="filled" fillcolor=gray];
|
||||
35 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
36 [label="Exit function foo" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
26 -> {27};
|
||||
27 -> {28};
|
||||
28 -> {29};
|
||||
29 -> {30};
|
||||
30 -> {31};
|
||||
31 -> {34};
|
||||
31 -> {32} [style=dotted];
|
||||
32 -> {33} [style=dotted];
|
||||
31 -> {32};
|
||||
32 -> {33};
|
||||
33 -> {36};
|
||||
33 -> {34} [style=dotted];
|
||||
|
||||
subgraph cluster_10 {
|
||||
color=red
|
||||
35 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
36 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
35 -> {36};
|
||||
34 -> {35} [style=dotted];
|
||||
35 -> {36} [style=dotted];
|
||||
|
||||
subgraph cluster_11 {
|
||||
color=red
|
||||
37 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
38 [label="Enter block"];
|
||||
39 [label="Exit block"];
|
||||
}
|
||||
40 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
37 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
38 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
37 -> {38};
|
||||
38 -> {39};
|
||||
39 -> {40};
|
||||
|
||||
subgraph cluster_13 {
|
||||
subgraph cluster_12 {
|
||||
color=red
|
||||
41 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
42 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
39 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
subgraph cluster_13 {
|
||||
color=blue
|
||||
40 [label="Enter block"];
|
||||
41 [label="Exit block"];
|
||||
}
|
||||
42 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
39 -> {40};
|
||||
40 -> {41};
|
||||
41 -> {42};
|
||||
|
||||
subgraph cluster_14 {
|
||||
color=red
|
||||
43 [label="Enter property" style="filled" fillcolor=red];
|
||||
subgraph cluster_15 {
|
||||
43 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
44 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
43 -> {44};
|
||||
|
||||
subgraph cluster_15 {
|
||||
color=red
|
||||
45 [label="Enter property" style="filled" fillcolor=red];
|
||||
subgraph cluster_16 {
|
||||
color=blue
|
||||
44 [label="Enter function anonymousFunction"];
|
||||
subgraph cluster_16 {
|
||||
46 [label="Enter function anonymousFunction"];
|
||||
subgraph cluster_17 {
|
||||
color=blue
|
||||
45 [label="Enter block"];
|
||||
46 [label="Function call: R|java/lang/Exception.Exception|()"];
|
||||
47 [label="Throw: throw R|java/lang/Exception.Exception|()"];
|
||||
48 [label="Stub" style="filled" fillcolor=gray];
|
||||
49 [label="Exit block" style="filled" fillcolor=gray];
|
||||
47 [label="Enter block"];
|
||||
48 [label="Function call: R|java/lang/Exception.Exception|()"];
|
||||
49 [label="Throw: throw R|java/lang/Exception.Exception|()"];
|
||||
50 [label="Stub" style="filled" fillcolor=gray];
|
||||
51 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
50 [label="Exit function anonymousFunction" style="filled" fillcolor=gray];
|
||||
52 [label="Exit function anonymousFunction" style="filled" fillcolor=gray];
|
||||
}
|
||||
51 [label="Function call: R|/run|(<L> = run@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||
53 [label="Function call: R|/run|(<L> = run@fun <anonymous>(): R|kotlin/Unit| <kind=EXACTLY_ONCE> {
|
||||
local final fun foo(): R|kotlin/Unit| {
|
||||
lval c: R|kotlin/Int| = Int(1).R|kotlin/Int.plus|(Int(1))
|
||||
throw R|java/lang/Exception.Exception|()
|
||||
@@ -179,81 +187,89 @@ digraph propertiesAndInitBlocks_kt {
|
||||
throw R|java/lang/Exception.Exception|()
|
||||
}
|
||||
)" style="filled" fillcolor=gray];
|
||||
52 [label="Exit property" style="filled" fillcolor=red];
|
||||
54 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
43 -> {44};
|
||||
44 -> {45};
|
||||
45 -> {46};
|
||||
46 -> {47};
|
||||
47 -> {52};
|
||||
47 -> {48} [style=dotted];
|
||||
48 -> {49} [style=dotted];
|
||||
47 -> {48};
|
||||
48 -> {49};
|
||||
49 -> {54};
|
||||
49 -> {50} [style=dotted];
|
||||
50 -> {51} [style=dotted];
|
||||
51 -> {52} [style=dotted];
|
||||
52 -> {53} [style=dotted];
|
||||
53 -> {54} [style=dotted];
|
||||
|
||||
subgraph cluster_17 {
|
||||
subgraph cluster_18 {
|
||||
color=red
|
||||
53 [label="Enter property" style="filled" fillcolor=red];
|
||||
subgraph cluster_18 {
|
||||
55 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
56 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
55 -> {56};
|
||||
|
||||
subgraph cluster_19 {
|
||||
color=red
|
||||
57 [label="Enter property" style="filled" fillcolor=red];
|
||||
subgraph cluster_20 {
|
||||
color=blue
|
||||
54 [label="Try expression enter"];
|
||||
subgraph cluster_19 {
|
||||
color=blue
|
||||
55 [label="Try main block enter"];
|
||||
subgraph cluster_20 {
|
||||
color=blue
|
||||
56 [label="Enter block"];
|
||||
57 [label="Const: Int(1)"];
|
||||
58 [label="Exit block"];
|
||||
}
|
||||
59 [label="Try main block exit"];
|
||||
}
|
||||
58 [label="Try expression enter"];
|
||||
subgraph cluster_21 {
|
||||
color=blue
|
||||
60 [label="Enter finally"];
|
||||
59 [label="Try main block enter"];
|
||||
subgraph cluster_22 {
|
||||
color=blue
|
||||
61 [label="Enter block"];
|
||||
62 [label="Const: Int(0)"];
|
||||
63 [label="Exit block"];
|
||||
60 [label="Enter block"];
|
||||
61 [label="Const: Int(1)"];
|
||||
62 [label="Exit block"];
|
||||
}
|
||||
64 [label="Exit finally"];
|
||||
63 [label="Try main block exit"];
|
||||
}
|
||||
subgraph cluster_23 {
|
||||
color=blue
|
||||
65 [label="Catch enter"];
|
||||
64 [label="Enter finally"];
|
||||
subgraph cluster_24 {
|
||||
color=blue
|
||||
66 [label="Enter block"];
|
||||
67 [label="Const: Int(2)"];
|
||||
68 [label="Exit block"];
|
||||
65 [label="Enter block"];
|
||||
66 [label="Const: Int(0)"];
|
||||
67 [label="Exit block"];
|
||||
}
|
||||
69 [label="Catch exit"];
|
||||
68 [label="Exit finally"];
|
||||
}
|
||||
70 [label="Try expression exit"];
|
||||
subgraph cluster_25 {
|
||||
color=blue
|
||||
69 [label="Catch enter"];
|
||||
subgraph cluster_26 {
|
||||
color=blue
|
||||
70 [label="Enter block"];
|
||||
71 [label="Const: Int(2)"];
|
||||
72 [label="Exit block"];
|
||||
}
|
||||
73 [label="Catch exit"];
|
||||
}
|
||||
74 [label="Try expression exit"];
|
||||
}
|
||||
71 [label="Exit property" style="filled" fillcolor=red];
|
||||
75 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
53 -> {54};
|
||||
54 -> {55};
|
||||
55 -> {71 65 60 56};
|
||||
56 -> {57};
|
||||
57 -> {58};
|
||||
58 -> {59};
|
||||
59 -> {70};
|
||||
59 -> {75 69 64 60};
|
||||
60 -> {61};
|
||||
61 -> {62};
|
||||
62 -> {63};
|
||||
63 -> {64};
|
||||
64 -> {70};
|
||||
65 -> {71 66};
|
||||
63 -> {74};
|
||||
64 -> {65};
|
||||
65 -> {66};
|
||||
66 -> {67};
|
||||
67 -> {68};
|
||||
68 -> {69};
|
||||
69 -> {70};
|
||||
68 -> {74};
|
||||
69 -> {75 70};
|
||||
70 -> {71};
|
||||
71 -> {72};
|
||||
72 -> {73};
|
||||
73 -> {74};
|
||||
74 -> {75};
|
||||
|
||||
}
|
||||
|
||||
+98
-90
@@ -13,93 +13,99 @@ digraph elvis_kt {
|
||||
|
||||
subgraph cluster_1 {
|
||||
color=red
|
||||
2 [label="Enter property" style="filled" fillcolor=red];
|
||||
3 [label="Exit property" style="filled" fillcolor=red];
|
||||
2 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
3 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
2 -> {3};
|
||||
|
||||
subgraph cluster_2 {
|
||||
color=red
|
||||
4 [label="Enter function test_1" style="filled" fillcolor=red];
|
||||
subgraph cluster_3 {
|
||||
color=blue
|
||||
5 [label="Enter block"];
|
||||
subgraph cluster_4 {
|
||||
color=blue
|
||||
6 [label="Enter when"];
|
||||
subgraph cluster_5 {
|
||||
color=blue
|
||||
7 [label="Enter when branch condition "];
|
||||
subgraph cluster_6 {
|
||||
color=blue
|
||||
8 [label="Enter when"];
|
||||
9 [label="Access variable R|<local>/x|"];
|
||||
10 [label="Access variable R|/A.b|"];
|
||||
11 [label="Variable declaration: lval <elvis>: R|kotlin/Boolean?|"];
|
||||
subgraph cluster_7 {
|
||||
color=blue
|
||||
12 [label="Enter when branch condition "];
|
||||
13 [label="Const: Null(null)"];
|
||||
14 [label="Operator =="];
|
||||
15 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_8 {
|
||||
color=blue
|
||||
16 [label="Enter when branch condition else"];
|
||||
17 [label="Exit when branch condition"];
|
||||
}
|
||||
18 [label="Enter when branch result"];
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
19 [label="Enter block"];
|
||||
20 [label="Access variable R|<local>/<elvis>|"];
|
||||
21 [label="Exit block"];
|
||||
}
|
||||
22 [label="Exit when branch result"];
|
||||
23 [label="Enter when branch result"];
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
24 [label="Enter block"];
|
||||
25 [label="Jump: ^test_1 Unit"];
|
||||
26 [label="Stub" style="filled" fillcolor=gray];
|
||||
27 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
28 [label="Exit when branch result" style="filled" fillcolor=gray];
|
||||
29 [label="Exit when"];
|
||||
}
|
||||
30 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
31 [label="Enter when branch condition else"];
|
||||
32 [label="Exit when branch condition"];
|
||||
}
|
||||
33 [label="Enter when branch result"];
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
34 [label="Enter block"];
|
||||
35 [label="Exit block"];
|
||||
}
|
||||
36 [label="Exit when branch result"];
|
||||
37 [label="Enter when branch result"];
|
||||
subgraph cluster_13 {
|
||||
color=blue
|
||||
38 [label="Enter block"];
|
||||
39 [label="Access variable R|<local>/x|"];
|
||||
40 [label="Function call: R|<local>/x|.R|/A.foo|()"];
|
||||
41 [label="Exit block"];
|
||||
}
|
||||
42 [label="Exit when branch result"];
|
||||
43 [label="Exit when"];
|
||||
}
|
||||
44 [label="Exit block"];
|
||||
}
|
||||
45 [label="Exit function test_1" style="filled" fillcolor=red];
|
||||
4 [label="Enter property" style="filled" fillcolor=red];
|
||||
5 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
4 -> {5};
|
||||
5 -> {6};
|
||||
|
||||
subgraph cluster_3 {
|
||||
color=red
|
||||
6 [label="Enter function test_1" style="filled" fillcolor=red];
|
||||
subgraph cluster_4 {
|
||||
color=blue
|
||||
7 [label="Enter block"];
|
||||
subgraph cluster_5 {
|
||||
color=blue
|
||||
8 [label="Enter when"];
|
||||
subgraph cluster_6 {
|
||||
color=blue
|
||||
9 [label="Enter when branch condition "];
|
||||
subgraph cluster_7 {
|
||||
color=blue
|
||||
10 [label="Enter when"];
|
||||
11 [label="Access variable R|<local>/x|"];
|
||||
12 [label="Access variable R|/A.b|"];
|
||||
13 [label="Variable declaration: lval <elvis>: R|kotlin/Boolean?|"];
|
||||
subgraph cluster_8 {
|
||||
color=blue
|
||||
14 [label="Enter when branch condition "];
|
||||
15 [label="Const: Null(null)"];
|
||||
16 [label="Operator =="];
|
||||
17 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
18 [label="Enter when branch condition else"];
|
||||
19 [label="Exit when branch condition"];
|
||||
}
|
||||
20 [label="Enter when branch result"];
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
21 [label="Enter block"];
|
||||
22 [label="Access variable R|<local>/<elvis>|"];
|
||||
23 [label="Exit block"];
|
||||
}
|
||||
24 [label="Exit when branch result"];
|
||||
25 [label="Enter when branch result"];
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
26 [label="Enter block"];
|
||||
27 [label="Jump: ^test_1 Unit"];
|
||||
28 [label="Stub" style="filled" fillcolor=gray];
|
||||
29 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
30 [label="Exit when branch result" style="filled" fillcolor=gray];
|
||||
31 [label="Exit when"];
|
||||
}
|
||||
32 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
33 [label="Enter when branch condition else"];
|
||||
34 [label="Exit when branch condition"];
|
||||
}
|
||||
35 [label="Enter when branch result"];
|
||||
subgraph cluster_13 {
|
||||
color=blue
|
||||
36 [label="Enter block"];
|
||||
37 [label="Exit block"];
|
||||
}
|
||||
38 [label="Exit when branch result"];
|
||||
39 [label="Enter when branch result"];
|
||||
subgraph cluster_14 {
|
||||
color=blue
|
||||
40 [label="Enter block"];
|
||||
41 [label="Access variable R|<local>/x|"];
|
||||
42 [label="Function call: R|<local>/x|.R|/A.foo|()"];
|
||||
43 [label="Exit block"];
|
||||
}
|
||||
44 [label="Exit when branch result"];
|
||||
45 [label="Exit when"];
|
||||
}
|
||||
46 [label="Exit block"];
|
||||
}
|
||||
47 [label="Exit function test_1" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
6 -> {7};
|
||||
7 -> {8};
|
||||
8 -> {9};
|
||||
@@ -109,36 +115,38 @@ digraph elvis_kt {
|
||||
12 -> {13};
|
||||
13 -> {14};
|
||||
14 -> {15};
|
||||
15 -> {23 16};
|
||||
15 -> {16};
|
||||
16 -> {17};
|
||||
17 -> {18};
|
||||
17 -> {25 18};
|
||||
18 -> {19};
|
||||
19 -> {20};
|
||||
20 -> {21};
|
||||
21 -> {22};
|
||||
22 -> {29};
|
||||
22 -> {23};
|
||||
23 -> {24};
|
||||
24 -> {25};
|
||||
25 -> {45};
|
||||
25 -> {26} [style=dotted];
|
||||
26 -> {27} [style=dotted];
|
||||
24 -> {31};
|
||||
25 -> {26};
|
||||
26 -> {27};
|
||||
27 -> {47};
|
||||
27 -> {28} [style=dotted];
|
||||
28 -> {29} [style=dotted];
|
||||
29 -> {30};
|
||||
30 -> {37 31};
|
||||
29 -> {30} [style=dotted];
|
||||
30 -> {31} [style=dotted];
|
||||
31 -> {32};
|
||||
32 -> {33};
|
||||
32 -> {39 33};
|
||||
33 -> {34};
|
||||
34 -> {35};
|
||||
35 -> {36};
|
||||
36 -> {43};
|
||||
36 -> {37};
|
||||
37 -> {38};
|
||||
38 -> {39};
|
||||
38 -> {45};
|
||||
39 -> {40};
|
||||
40 -> {41};
|
||||
41 -> {42};
|
||||
42 -> {43};
|
||||
43 -> {44};
|
||||
44 -> {45};
|
||||
45 -> {46};
|
||||
46 -> {47};
|
||||
|
||||
}
|
||||
|
||||
+326
-318
@@ -13,63 +13,69 @@ digraph equalsToBoolean_kt {
|
||||
|
||||
subgraph cluster_1 {
|
||||
color=red
|
||||
2 [label="Enter property" style="filled" fillcolor=red];
|
||||
3 [label="Exit property" style="filled" fillcolor=red];
|
||||
2 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
3 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
2 -> {3};
|
||||
|
||||
subgraph cluster_2 {
|
||||
color=red
|
||||
4 [label="Enter function test_1" style="filled" fillcolor=red];
|
||||
subgraph cluster_3 {
|
||||
color=blue
|
||||
5 [label="Enter block"];
|
||||
subgraph cluster_4 {
|
||||
color=blue
|
||||
6 [label="Enter when"];
|
||||
subgraph cluster_5 {
|
||||
color=blue
|
||||
7 [label="Enter when branch condition "];
|
||||
8 [label="Access variable R|<local>/b|"];
|
||||
9 [label="Const: Boolean(true)"];
|
||||
10 [label="Operator =="];
|
||||
11 [label="Const: Boolean(true)"];
|
||||
12 [label="Operator =="];
|
||||
13 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_6 {
|
||||
color=blue
|
||||
14 [label="Enter when branch condition else"];
|
||||
15 [label="Exit when branch condition"];
|
||||
}
|
||||
16 [label="Enter when branch result"];
|
||||
subgraph cluster_7 {
|
||||
color=blue
|
||||
17 [label="Enter block"];
|
||||
18 [label="Access variable R|<local>/b|"];
|
||||
19 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
20 [label="Exit block"];
|
||||
}
|
||||
21 [label="Exit when branch result"];
|
||||
22 [label="Enter when branch result"];
|
||||
subgraph cluster_8 {
|
||||
color=blue
|
||||
23 [label="Enter block"];
|
||||
24 [label="Access variable R|<local>/b|"];
|
||||
25 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
26 [label="Exit block"];
|
||||
}
|
||||
27 [label="Exit when branch result"];
|
||||
28 [label="Exit when"];
|
||||
}
|
||||
29 [label="Exit block"];
|
||||
}
|
||||
30 [label="Exit function test_1" style="filled" fillcolor=red];
|
||||
4 [label="Enter property" style="filled" fillcolor=red];
|
||||
5 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
4 -> {5};
|
||||
5 -> {6};
|
||||
|
||||
subgraph cluster_3 {
|
||||
color=red
|
||||
6 [label="Enter function test_1" style="filled" fillcolor=red];
|
||||
subgraph cluster_4 {
|
||||
color=blue
|
||||
7 [label="Enter block"];
|
||||
subgraph cluster_5 {
|
||||
color=blue
|
||||
8 [label="Enter when"];
|
||||
subgraph cluster_6 {
|
||||
color=blue
|
||||
9 [label="Enter when branch condition "];
|
||||
10 [label="Access variable R|<local>/b|"];
|
||||
11 [label="Const: Boolean(true)"];
|
||||
12 [label="Operator =="];
|
||||
13 [label="Const: Boolean(true)"];
|
||||
14 [label="Operator =="];
|
||||
15 [label="Exit when branch condition"];
|
||||
}
|
||||
subgraph cluster_7 {
|
||||
color=blue
|
||||
16 [label="Enter when branch condition else"];
|
||||
17 [label="Exit when branch condition"];
|
||||
}
|
||||
18 [label="Enter when branch result"];
|
||||
subgraph cluster_8 {
|
||||
color=blue
|
||||
19 [label="Enter block"];
|
||||
20 [label="Access variable R|<local>/b|"];
|
||||
21 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
22 [label="Exit block"];
|
||||
}
|
||||
23 [label="Exit when branch result"];
|
||||
24 [label="Enter when branch result"];
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
25 [label="Enter block"];
|
||||
26 [label="Access variable R|<local>/b|"];
|
||||
27 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
28 [label="Exit block"];
|
||||
}
|
||||
29 [label="Exit when branch result"];
|
||||
30 [label="Exit when"];
|
||||
}
|
||||
31 [label="Exit block"];
|
||||
}
|
||||
32 [label="Exit function test_1" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
6 -> {7};
|
||||
7 -> {8};
|
||||
8 -> {9};
|
||||
@@ -77,75 +83,75 @@ digraph equalsToBoolean_kt {
|
||||
10 -> {11};
|
||||
11 -> {12};
|
||||
12 -> {13};
|
||||
13 -> {22 14};
|
||||
13 -> {14};
|
||||
14 -> {15};
|
||||
15 -> {16};
|
||||
15 -> {24 16};
|
||||
16 -> {17};
|
||||
17 -> {18};
|
||||
18 -> {19};
|
||||
19 -> {20};
|
||||
20 -> {21};
|
||||
21 -> {28};
|
||||
21 -> {22};
|
||||
22 -> {23};
|
||||
23 -> {24};
|
||||
23 -> {30};
|
||||
24 -> {25};
|
||||
25 -> {26};
|
||||
26 -> {27};
|
||||
27 -> {28};
|
||||
28 -> {29};
|
||||
29 -> {30};
|
||||
30 -> {31};
|
||||
31 -> {32};
|
||||
|
||||
subgraph cluster_9 {
|
||||
subgraph cluster_10 {
|
||||
color=red
|
||||
31 [label="Enter function test_2" style="filled" fillcolor=red];
|
||||
subgraph cluster_10 {
|
||||
33 [label="Enter function test_2" style="filled" fillcolor=red];
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
32 [label="Enter block"];
|
||||
subgraph cluster_11 {
|
||||
34 [label="Enter block"];
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
33 [label="Enter when"];
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
34 [label="Enter when branch condition "];
|
||||
35 [label="Access variable R|<local>/b|"];
|
||||
36 [label="Const: Boolean(true)"];
|
||||
37 [label="Operator =="];
|
||||
38 [label="Const: Boolean(true)"];
|
||||
39 [label="Operator !="];
|
||||
40 [label="Exit when branch condition"];
|
||||
}
|
||||
35 [label="Enter when"];
|
||||
subgraph cluster_13 {
|
||||
color=blue
|
||||
41 [label="Enter when branch condition else"];
|
||||
36 [label="Enter when branch condition "];
|
||||
37 [label="Access variable R|<local>/b|"];
|
||||
38 [label="Const: Boolean(true)"];
|
||||
39 [label="Operator =="];
|
||||
40 [label="Const: Boolean(true)"];
|
||||
41 [label="Operator !="];
|
||||
42 [label="Exit when branch condition"];
|
||||
}
|
||||
43 [label="Enter when branch result"];
|
||||
subgraph cluster_14 {
|
||||
color=blue
|
||||
44 [label="Enter block"];
|
||||
45 [label="Access variable R|<local>/b|"];
|
||||
46 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
47 [label="Exit block"];
|
||||
43 [label="Enter when branch condition else"];
|
||||
44 [label="Exit when branch condition"];
|
||||
}
|
||||
48 [label="Exit when branch result"];
|
||||
49 [label="Enter when branch result"];
|
||||
45 [label="Enter when branch result"];
|
||||
subgraph cluster_15 {
|
||||
color=blue
|
||||
50 [label="Enter block"];
|
||||
51 [label="Access variable R|<local>/b|"];
|
||||
52 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
53 [label="Exit block"];
|
||||
46 [label="Enter block"];
|
||||
47 [label="Access variable R|<local>/b|"];
|
||||
48 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
49 [label="Exit block"];
|
||||
}
|
||||
54 [label="Exit when branch result"];
|
||||
55 [label="Exit when"];
|
||||
50 [label="Exit when branch result"];
|
||||
51 [label="Enter when branch result"];
|
||||
subgraph cluster_16 {
|
||||
color=blue
|
||||
52 [label="Enter block"];
|
||||
53 [label="Access variable R|<local>/b|"];
|
||||
54 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
55 [label="Exit block"];
|
||||
}
|
||||
56 [label="Exit when branch result"];
|
||||
57 [label="Exit when"];
|
||||
}
|
||||
56 [label="Exit block"];
|
||||
58 [label="Exit block"];
|
||||
}
|
||||
57 [label="Exit function test_2" style="filled" fillcolor=red];
|
||||
59 [label="Exit function test_2" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
31 -> {32};
|
||||
32 -> {33};
|
||||
33 -> {34};
|
||||
34 -> {35};
|
||||
35 -> {36};
|
||||
@@ -153,75 +159,75 @@ digraph equalsToBoolean_kt {
|
||||
37 -> {38};
|
||||
38 -> {39};
|
||||
39 -> {40};
|
||||
40 -> {49 41};
|
||||
40 -> {41};
|
||||
41 -> {42};
|
||||
42 -> {43};
|
||||
42 -> {51 43};
|
||||
43 -> {44};
|
||||
44 -> {45};
|
||||
45 -> {46};
|
||||
46 -> {47};
|
||||
47 -> {48};
|
||||
48 -> {55};
|
||||
48 -> {49};
|
||||
49 -> {50};
|
||||
50 -> {51};
|
||||
50 -> {57};
|
||||
51 -> {52};
|
||||
52 -> {53};
|
||||
53 -> {54};
|
||||
54 -> {55};
|
||||
55 -> {56};
|
||||
56 -> {57};
|
||||
57 -> {58};
|
||||
58 -> {59};
|
||||
|
||||
subgraph cluster_16 {
|
||||
subgraph cluster_17 {
|
||||
color=red
|
||||
58 [label="Enter function test_3" style="filled" fillcolor=red];
|
||||
subgraph cluster_17 {
|
||||
60 [label="Enter function test_3" style="filled" fillcolor=red];
|
||||
subgraph cluster_18 {
|
||||
color=blue
|
||||
59 [label="Enter block"];
|
||||
subgraph cluster_18 {
|
||||
61 [label="Enter block"];
|
||||
subgraph cluster_19 {
|
||||
color=blue
|
||||
60 [label="Enter when"];
|
||||
subgraph cluster_19 {
|
||||
color=blue
|
||||
61 [label="Enter when branch condition "];
|
||||
62 [label="Access variable R|<local>/b|"];
|
||||
63 [label="Const: Boolean(true)"];
|
||||
64 [label="Operator =="];
|
||||
65 [label="Const: Boolean(false)"];
|
||||
66 [label="Operator =="];
|
||||
67 [label="Exit when branch condition"];
|
||||
}
|
||||
62 [label="Enter when"];
|
||||
subgraph cluster_20 {
|
||||
color=blue
|
||||
68 [label="Enter when branch condition else"];
|
||||
63 [label="Enter when branch condition "];
|
||||
64 [label="Access variable R|<local>/b|"];
|
||||
65 [label="Const: Boolean(true)"];
|
||||
66 [label="Operator =="];
|
||||
67 [label="Const: Boolean(false)"];
|
||||
68 [label="Operator =="];
|
||||
69 [label="Exit when branch condition"];
|
||||
}
|
||||
70 [label="Enter when branch result"];
|
||||
subgraph cluster_21 {
|
||||
color=blue
|
||||
71 [label="Enter block"];
|
||||
72 [label="Access variable R|<local>/b|"];
|
||||
73 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
74 [label="Exit block"];
|
||||
70 [label="Enter when branch condition else"];
|
||||
71 [label="Exit when branch condition"];
|
||||
}
|
||||
75 [label="Exit when branch result"];
|
||||
76 [label="Enter when branch result"];
|
||||
72 [label="Enter when branch result"];
|
||||
subgraph cluster_22 {
|
||||
color=blue
|
||||
77 [label="Enter block"];
|
||||
78 [label="Access variable R|<local>/b|"];
|
||||
79 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
80 [label="Exit block"];
|
||||
73 [label="Enter block"];
|
||||
74 [label="Access variable R|<local>/b|"];
|
||||
75 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
76 [label="Exit block"];
|
||||
}
|
||||
81 [label="Exit when branch result"];
|
||||
82 [label="Exit when"];
|
||||
77 [label="Exit when branch result"];
|
||||
78 [label="Enter when branch result"];
|
||||
subgraph cluster_23 {
|
||||
color=blue
|
||||
79 [label="Enter block"];
|
||||
80 [label="Access variable R|<local>/b|"];
|
||||
81 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
82 [label="Exit block"];
|
||||
}
|
||||
83 [label="Exit when branch result"];
|
||||
84 [label="Exit when"];
|
||||
}
|
||||
83 [label="Exit block"];
|
||||
85 [label="Exit block"];
|
||||
}
|
||||
84 [label="Exit function test_3" style="filled" fillcolor=red];
|
||||
86 [label="Exit function test_3" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
58 -> {59};
|
||||
59 -> {60};
|
||||
60 -> {61};
|
||||
61 -> {62};
|
||||
62 -> {63};
|
||||
@@ -229,75 +235,75 @@ digraph equalsToBoolean_kt {
|
||||
64 -> {65};
|
||||
65 -> {66};
|
||||
66 -> {67};
|
||||
67 -> {76 68};
|
||||
67 -> {68};
|
||||
68 -> {69};
|
||||
69 -> {70};
|
||||
69 -> {78 70};
|
||||
70 -> {71};
|
||||
71 -> {72};
|
||||
72 -> {73};
|
||||
73 -> {74};
|
||||
74 -> {75};
|
||||
75 -> {82};
|
||||
75 -> {76};
|
||||
76 -> {77};
|
||||
77 -> {78};
|
||||
77 -> {84};
|
||||
78 -> {79};
|
||||
79 -> {80};
|
||||
80 -> {81};
|
||||
81 -> {82};
|
||||
82 -> {83};
|
||||
83 -> {84};
|
||||
84 -> {85};
|
||||
85 -> {86};
|
||||
|
||||
subgraph cluster_23 {
|
||||
subgraph cluster_24 {
|
||||
color=red
|
||||
85 [label="Enter function test_4" style="filled" fillcolor=red];
|
||||
subgraph cluster_24 {
|
||||
87 [label="Enter function test_4" style="filled" fillcolor=red];
|
||||
subgraph cluster_25 {
|
||||
color=blue
|
||||
86 [label="Enter block"];
|
||||
subgraph cluster_25 {
|
||||
88 [label="Enter block"];
|
||||
subgraph cluster_26 {
|
||||
color=blue
|
||||
87 [label="Enter when"];
|
||||
subgraph cluster_26 {
|
||||
color=blue
|
||||
88 [label="Enter when branch condition "];
|
||||
89 [label="Access variable R|<local>/b|"];
|
||||
90 [label="Const: Boolean(true)"];
|
||||
91 [label="Operator =="];
|
||||
92 [label="Const: Boolean(false)"];
|
||||
93 [label="Operator !="];
|
||||
94 [label="Exit when branch condition"];
|
||||
}
|
||||
89 [label="Enter when"];
|
||||
subgraph cluster_27 {
|
||||
color=blue
|
||||
95 [label="Enter when branch condition else"];
|
||||
90 [label="Enter when branch condition "];
|
||||
91 [label="Access variable R|<local>/b|"];
|
||||
92 [label="Const: Boolean(true)"];
|
||||
93 [label="Operator =="];
|
||||
94 [label="Const: Boolean(false)"];
|
||||
95 [label="Operator !="];
|
||||
96 [label="Exit when branch condition"];
|
||||
}
|
||||
97 [label="Enter when branch result"];
|
||||
subgraph cluster_28 {
|
||||
color=blue
|
||||
98 [label="Enter block"];
|
||||
99 [label="Access variable R|<local>/b|"];
|
||||
100 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
101 [label="Exit block"];
|
||||
97 [label="Enter when branch condition else"];
|
||||
98 [label="Exit when branch condition"];
|
||||
}
|
||||
102 [label="Exit when branch result"];
|
||||
103 [label="Enter when branch result"];
|
||||
99 [label="Enter when branch result"];
|
||||
subgraph cluster_29 {
|
||||
color=blue
|
||||
104 [label="Enter block"];
|
||||
105 [label="Access variable R|<local>/b|"];
|
||||
106 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
107 [label="Exit block"];
|
||||
100 [label="Enter block"];
|
||||
101 [label="Access variable R|<local>/b|"];
|
||||
102 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
103 [label="Exit block"];
|
||||
}
|
||||
108 [label="Exit when branch result"];
|
||||
109 [label="Exit when"];
|
||||
104 [label="Exit when branch result"];
|
||||
105 [label="Enter when branch result"];
|
||||
subgraph cluster_30 {
|
||||
color=blue
|
||||
106 [label="Enter block"];
|
||||
107 [label="Access variable R|<local>/b|"];
|
||||
108 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
109 [label="Exit block"];
|
||||
}
|
||||
110 [label="Exit when branch result"];
|
||||
111 [label="Exit when"];
|
||||
}
|
||||
110 [label="Exit block"];
|
||||
112 [label="Exit block"];
|
||||
}
|
||||
111 [label="Exit function test_4" style="filled" fillcolor=red];
|
||||
113 [label="Exit function test_4" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
85 -> {86};
|
||||
86 -> {87};
|
||||
87 -> {88};
|
||||
88 -> {89};
|
||||
89 -> {90};
|
||||
@@ -305,75 +311,75 @@ digraph equalsToBoolean_kt {
|
||||
91 -> {92};
|
||||
92 -> {93};
|
||||
93 -> {94};
|
||||
94 -> {103 95};
|
||||
94 -> {95};
|
||||
95 -> {96};
|
||||
96 -> {97};
|
||||
96 -> {105 97};
|
||||
97 -> {98};
|
||||
98 -> {99};
|
||||
99 -> {100};
|
||||
100 -> {101};
|
||||
101 -> {102};
|
||||
102 -> {109};
|
||||
102 -> {103};
|
||||
103 -> {104};
|
||||
104 -> {105};
|
||||
104 -> {111};
|
||||
105 -> {106};
|
||||
106 -> {107};
|
||||
107 -> {108};
|
||||
108 -> {109};
|
||||
109 -> {110};
|
||||
110 -> {111};
|
||||
111 -> {112};
|
||||
112 -> {113};
|
||||
|
||||
subgraph cluster_30 {
|
||||
subgraph cluster_31 {
|
||||
color=red
|
||||
112 [label="Enter function test_5" style="filled" fillcolor=red];
|
||||
subgraph cluster_31 {
|
||||
114 [label="Enter function test_5" style="filled" fillcolor=red];
|
||||
subgraph cluster_32 {
|
||||
color=blue
|
||||
113 [label="Enter block"];
|
||||
subgraph cluster_32 {
|
||||
115 [label="Enter block"];
|
||||
subgraph cluster_33 {
|
||||
color=blue
|
||||
114 [label="Enter when"];
|
||||
subgraph cluster_33 {
|
||||
color=blue
|
||||
115 [label="Enter when branch condition "];
|
||||
116 [label="Access variable R|<local>/b|"];
|
||||
117 [label="Const: Boolean(true)"];
|
||||
118 [label="Operator !="];
|
||||
119 [label="Const: Boolean(true)"];
|
||||
120 [label="Operator =="];
|
||||
121 [label="Exit when branch condition"];
|
||||
}
|
||||
116 [label="Enter when"];
|
||||
subgraph cluster_34 {
|
||||
color=blue
|
||||
122 [label="Enter when branch condition else"];
|
||||
117 [label="Enter when branch condition "];
|
||||
118 [label="Access variable R|<local>/b|"];
|
||||
119 [label="Const: Boolean(true)"];
|
||||
120 [label="Operator !="];
|
||||
121 [label="Const: Boolean(true)"];
|
||||
122 [label="Operator =="];
|
||||
123 [label="Exit when branch condition"];
|
||||
}
|
||||
124 [label="Enter when branch result"];
|
||||
subgraph cluster_35 {
|
||||
color=blue
|
||||
125 [label="Enter block"];
|
||||
126 [label="Access variable R|<local>/b|"];
|
||||
127 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
128 [label="Exit block"];
|
||||
124 [label="Enter when branch condition else"];
|
||||
125 [label="Exit when branch condition"];
|
||||
}
|
||||
129 [label="Exit when branch result"];
|
||||
130 [label="Enter when branch result"];
|
||||
126 [label="Enter when branch result"];
|
||||
subgraph cluster_36 {
|
||||
color=blue
|
||||
131 [label="Enter block"];
|
||||
132 [label="Access variable R|<local>/b|"];
|
||||
133 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
134 [label="Exit block"];
|
||||
127 [label="Enter block"];
|
||||
128 [label="Access variable R|<local>/b|"];
|
||||
129 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
130 [label="Exit block"];
|
||||
}
|
||||
135 [label="Exit when branch result"];
|
||||
136 [label="Exit when"];
|
||||
131 [label="Exit when branch result"];
|
||||
132 [label="Enter when branch result"];
|
||||
subgraph cluster_37 {
|
||||
color=blue
|
||||
133 [label="Enter block"];
|
||||
134 [label="Access variable R|<local>/b|"];
|
||||
135 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
136 [label="Exit block"];
|
||||
}
|
||||
137 [label="Exit when branch result"];
|
||||
138 [label="Exit when"];
|
||||
}
|
||||
137 [label="Exit block"];
|
||||
139 [label="Exit block"];
|
||||
}
|
||||
138 [label="Exit function test_5" style="filled" fillcolor=red];
|
||||
140 [label="Exit function test_5" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
112 -> {113};
|
||||
113 -> {114};
|
||||
114 -> {115};
|
||||
115 -> {116};
|
||||
116 -> {117};
|
||||
@@ -381,75 +387,75 @@ digraph equalsToBoolean_kt {
|
||||
118 -> {119};
|
||||
119 -> {120};
|
||||
120 -> {121};
|
||||
121 -> {130 122};
|
||||
121 -> {122};
|
||||
122 -> {123};
|
||||
123 -> {124};
|
||||
123 -> {132 124};
|
||||
124 -> {125};
|
||||
125 -> {126};
|
||||
126 -> {127};
|
||||
127 -> {128};
|
||||
128 -> {129};
|
||||
129 -> {136};
|
||||
129 -> {130};
|
||||
130 -> {131};
|
||||
131 -> {132};
|
||||
131 -> {138};
|
||||
132 -> {133};
|
||||
133 -> {134};
|
||||
134 -> {135};
|
||||
135 -> {136};
|
||||
136 -> {137};
|
||||
137 -> {138};
|
||||
138 -> {139};
|
||||
139 -> {140};
|
||||
|
||||
subgraph cluster_37 {
|
||||
subgraph cluster_38 {
|
||||
color=red
|
||||
139 [label="Enter function test_6" style="filled" fillcolor=red];
|
||||
subgraph cluster_38 {
|
||||
141 [label="Enter function test_6" style="filled" fillcolor=red];
|
||||
subgraph cluster_39 {
|
||||
color=blue
|
||||
140 [label="Enter block"];
|
||||
subgraph cluster_39 {
|
||||
142 [label="Enter block"];
|
||||
subgraph cluster_40 {
|
||||
color=blue
|
||||
141 [label="Enter when"];
|
||||
subgraph cluster_40 {
|
||||
color=blue
|
||||
142 [label="Enter when branch condition "];
|
||||
143 [label="Access variable R|<local>/b|"];
|
||||
144 [label="Const: Boolean(true)"];
|
||||
145 [label="Operator !="];
|
||||
146 [label="Const: Boolean(true)"];
|
||||
147 [label="Operator !="];
|
||||
148 [label="Exit when branch condition"];
|
||||
}
|
||||
143 [label="Enter when"];
|
||||
subgraph cluster_41 {
|
||||
color=blue
|
||||
149 [label="Enter when branch condition else"];
|
||||
144 [label="Enter when branch condition "];
|
||||
145 [label="Access variable R|<local>/b|"];
|
||||
146 [label="Const: Boolean(true)"];
|
||||
147 [label="Operator !="];
|
||||
148 [label="Const: Boolean(true)"];
|
||||
149 [label="Operator !="];
|
||||
150 [label="Exit when branch condition"];
|
||||
}
|
||||
151 [label="Enter when branch result"];
|
||||
subgraph cluster_42 {
|
||||
color=blue
|
||||
152 [label="Enter block"];
|
||||
153 [label="Access variable R|<local>/b|"];
|
||||
154 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
155 [label="Exit block"];
|
||||
151 [label="Enter when branch condition else"];
|
||||
152 [label="Exit when branch condition"];
|
||||
}
|
||||
156 [label="Exit when branch result"];
|
||||
157 [label="Enter when branch result"];
|
||||
153 [label="Enter when branch result"];
|
||||
subgraph cluster_43 {
|
||||
color=blue
|
||||
158 [label="Enter block"];
|
||||
159 [label="Access variable R|<local>/b|"];
|
||||
160 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
161 [label="Exit block"];
|
||||
154 [label="Enter block"];
|
||||
155 [label="Access variable R|<local>/b|"];
|
||||
156 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
157 [label="Exit block"];
|
||||
}
|
||||
162 [label="Exit when branch result"];
|
||||
163 [label="Exit when"];
|
||||
158 [label="Exit when branch result"];
|
||||
159 [label="Enter when branch result"];
|
||||
subgraph cluster_44 {
|
||||
color=blue
|
||||
160 [label="Enter block"];
|
||||
161 [label="Access variable R|<local>/b|"];
|
||||
162 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
163 [label="Exit block"];
|
||||
}
|
||||
164 [label="Exit when branch result"];
|
||||
165 [label="Exit when"];
|
||||
}
|
||||
164 [label="Exit block"];
|
||||
166 [label="Exit block"];
|
||||
}
|
||||
165 [label="Exit function test_6" style="filled" fillcolor=red];
|
||||
167 [label="Exit function test_6" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
139 -> {140};
|
||||
140 -> {141};
|
||||
141 -> {142};
|
||||
142 -> {143};
|
||||
143 -> {144};
|
||||
@@ -457,75 +463,75 @@ digraph equalsToBoolean_kt {
|
||||
145 -> {146};
|
||||
146 -> {147};
|
||||
147 -> {148};
|
||||
148 -> {157 149};
|
||||
148 -> {149};
|
||||
149 -> {150};
|
||||
150 -> {151};
|
||||
150 -> {159 151};
|
||||
151 -> {152};
|
||||
152 -> {153};
|
||||
153 -> {154};
|
||||
154 -> {155};
|
||||
155 -> {156};
|
||||
156 -> {163};
|
||||
156 -> {157};
|
||||
157 -> {158};
|
||||
158 -> {159};
|
||||
158 -> {165};
|
||||
159 -> {160};
|
||||
160 -> {161};
|
||||
161 -> {162};
|
||||
162 -> {163};
|
||||
163 -> {164};
|
||||
164 -> {165};
|
||||
165 -> {166};
|
||||
166 -> {167};
|
||||
|
||||
subgraph cluster_44 {
|
||||
subgraph cluster_45 {
|
||||
color=red
|
||||
166 [label="Enter function test_7" style="filled" fillcolor=red];
|
||||
subgraph cluster_45 {
|
||||
168 [label="Enter function test_7" style="filled" fillcolor=red];
|
||||
subgraph cluster_46 {
|
||||
color=blue
|
||||
167 [label="Enter block"];
|
||||
subgraph cluster_46 {
|
||||
169 [label="Enter block"];
|
||||
subgraph cluster_47 {
|
||||
color=blue
|
||||
168 [label="Enter when"];
|
||||
subgraph cluster_47 {
|
||||
color=blue
|
||||
169 [label="Enter when branch condition "];
|
||||
170 [label="Access variable R|<local>/b|"];
|
||||
171 [label="Const: Boolean(true)"];
|
||||
172 [label="Operator !="];
|
||||
173 [label="Const: Boolean(false)"];
|
||||
174 [label="Operator =="];
|
||||
175 [label="Exit when branch condition"];
|
||||
}
|
||||
170 [label="Enter when"];
|
||||
subgraph cluster_48 {
|
||||
color=blue
|
||||
176 [label="Enter when branch condition else"];
|
||||
171 [label="Enter when branch condition "];
|
||||
172 [label="Access variable R|<local>/b|"];
|
||||
173 [label="Const: Boolean(true)"];
|
||||
174 [label="Operator !="];
|
||||
175 [label="Const: Boolean(false)"];
|
||||
176 [label="Operator =="];
|
||||
177 [label="Exit when branch condition"];
|
||||
}
|
||||
178 [label="Enter when branch result"];
|
||||
subgraph cluster_49 {
|
||||
color=blue
|
||||
179 [label="Enter block"];
|
||||
180 [label="Access variable R|<local>/b|"];
|
||||
181 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
182 [label="Exit block"];
|
||||
178 [label="Enter when branch condition else"];
|
||||
179 [label="Exit when branch condition"];
|
||||
}
|
||||
183 [label="Exit when branch result"];
|
||||
184 [label="Enter when branch result"];
|
||||
180 [label="Enter when branch result"];
|
||||
subgraph cluster_50 {
|
||||
color=blue
|
||||
185 [label="Enter block"];
|
||||
186 [label="Access variable R|<local>/b|"];
|
||||
187 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
188 [label="Exit block"];
|
||||
181 [label="Enter block"];
|
||||
182 [label="Access variable R|<local>/b|"];
|
||||
183 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
184 [label="Exit block"];
|
||||
}
|
||||
189 [label="Exit when branch result"];
|
||||
190 [label="Exit when"];
|
||||
185 [label="Exit when branch result"];
|
||||
186 [label="Enter when branch result"];
|
||||
subgraph cluster_51 {
|
||||
color=blue
|
||||
187 [label="Enter block"];
|
||||
188 [label="Access variable R|<local>/b|"];
|
||||
189 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
190 [label="Exit block"];
|
||||
}
|
||||
191 [label="Exit when branch result"];
|
||||
192 [label="Exit when"];
|
||||
}
|
||||
191 [label="Exit block"];
|
||||
193 [label="Exit block"];
|
||||
}
|
||||
192 [label="Exit function test_7" style="filled" fillcolor=red];
|
||||
194 [label="Exit function test_7" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
166 -> {167};
|
||||
167 -> {168};
|
||||
168 -> {169};
|
||||
169 -> {170};
|
||||
170 -> {171};
|
||||
@@ -533,75 +539,75 @@ digraph equalsToBoolean_kt {
|
||||
172 -> {173};
|
||||
173 -> {174};
|
||||
174 -> {175};
|
||||
175 -> {184 176};
|
||||
175 -> {176};
|
||||
176 -> {177};
|
||||
177 -> {178};
|
||||
177 -> {186 178};
|
||||
178 -> {179};
|
||||
179 -> {180};
|
||||
180 -> {181};
|
||||
181 -> {182};
|
||||
182 -> {183};
|
||||
183 -> {190};
|
||||
183 -> {184};
|
||||
184 -> {185};
|
||||
185 -> {186};
|
||||
185 -> {192};
|
||||
186 -> {187};
|
||||
187 -> {188};
|
||||
188 -> {189};
|
||||
189 -> {190};
|
||||
190 -> {191};
|
||||
191 -> {192};
|
||||
192 -> {193};
|
||||
193 -> {194};
|
||||
|
||||
subgraph cluster_51 {
|
||||
subgraph cluster_52 {
|
||||
color=red
|
||||
193 [label="Enter function test_8" style="filled" fillcolor=red];
|
||||
subgraph cluster_52 {
|
||||
195 [label="Enter function test_8" style="filled" fillcolor=red];
|
||||
subgraph cluster_53 {
|
||||
color=blue
|
||||
194 [label="Enter block"];
|
||||
subgraph cluster_53 {
|
||||
196 [label="Enter block"];
|
||||
subgraph cluster_54 {
|
||||
color=blue
|
||||
195 [label="Enter when"];
|
||||
subgraph cluster_54 {
|
||||
color=blue
|
||||
196 [label="Enter when branch condition "];
|
||||
197 [label="Access variable R|<local>/b|"];
|
||||
198 [label="Const: Boolean(true)"];
|
||||
199 [label="Operator !="];
|
||||
200 [label="Const: Boolean(false)"];
|
||||
201 [label="Operator !="];
|
||||
202 [label="Exit when branch condition"];
|
||||
}
|
||||
197 [label="Enter when"];
|
||||
subgraph cluster_55 {
|
||||
color=blue
|
||||
203 [label="Enter when branch condition else"];
|
||||
198 [label="Enter when branch condition "];
|
||||
199 [label="Access variable R|<local>/b|"];
|
||||
200 [label="Const: Boolean(true)"];
|
||||
201 [label="Operator !="];
|
||||
202 [label="Const: Boolean(false)"];
|
||||
203 [label="Operator !="];
|
||||
204 [label="Exit when branch condition"];
|
||||
}
|
||||
205 [label="Enter when branch result"];
|
||||
subgraph cluster_56 {
|
||||
color=blue
|
||||
206 [label="Enter block"];
|
||||
207 [label="Access variable R|<local>/b|"];
|
||||
208 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
209 [label="Exit block"];
|
||||
205 [label="Enter when branch condition else"];
|
||||
206 [label="Exit when branch condition"];
|
||||
}
|
||||
210 [label="Exit when branch result"];
|
||||
211 [label="Enter when branch result"];
|
||||
207 [label="Enter when branch result"];
|
||||
subgraph cluster_57 {
|
||||
color=blue
|
||||
212 [label="Enter block"];
|
||||
213 [label="Access variable R|<local>/b|"];
|
||||
214 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
215 [label="Exit block"];
|
||||
208 [label="Enter block"];
|
||||
209 [label="Access variable R|<local>/b|"];
|
||||
210 [label="Function call: R|<local>/b|.R|kotlin/Boolean.not|()"];
|
||||
211 [label="Exit block"];
|
||||
}
|
||||
216 [label="Exit when branch result"];
|
||||
217 [label="Exit when"];
|
||||
212 [label="Exit when branch result"];
|
||||
213 [label="Enter when branch result"];
|
||||
subgraph cluster_58 {
|
||||
color=blue
|
||||
214 [label="Enter block"];
|
||||
215 [label="Access variable R|<local>/b|"];
|
||||
216 [label="Function call: R|<local>/b|.<Inapplicable(WRONG_RECEIVER): [kotlin/Boolean.not]>#()"];
|
||||
217 [label="Exit block"];
|
||||
}
|
||||
218 [label="Exit when branch result"];
|
||||
219 [label="Exit when"];
|
||||
}
|
||||
218 [label="Exit block"];
|
||||
220 [label="Exit block"];
|
||||
}
|
||||
219 [label="Exit function test_8" style="filled" fillcolor=red];
|
||||
221 [label="Exit function test_8" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
193 -> {194};
|
||||
194 -> {195};
|
||||
195 -> {196};
|
||||
196 -> {197};
|
||||
197 -> {198};
|
||||
@@ -609,22 +615,24 @@ digraph equalsToBoolean_kt {
|
||||
199 -> {200};
|
||||
200 -> {201};
|
||||
201 -> {202};
|
||||
202 -> {211 203};
|
||||
202 -> {203};
|
||||
203 -> {204};
|
||||
204 -> {205};
|
||||
204 -> {213 205};
|
||||
205 -> {206};
|
||||
206 -> {207};
|
||||
207 -> {208};
|
||||
208 -> {209};
|
||||
209 -> {210};
|
||||
210 -> {217};
|
||||
210 -> {211};
|
||||
211 -> {212};
|
||||
212 -> {213};
|
||||
212 -> {219};
|
||||
213 -> {214};
|
||||
214 -> {215};
|
||||
215 -> {216};
|
||||
216 -> {217};
|
||||
217 -> {218};
|
||||
218 -> {219};
|
||||
219 -> {220};
|
||||
220 -> {221};
|
||||
|
||||
}
|
||||
|
||||
+847
-831
File diff suppressed because it is too large
Load Diff
@@ -12,7 +12,7 @@ FILE: simpleDelegatedToMap.kt
|
||||
^ D|/C.foo|.<Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>#(this@R|/C|, ::R|/C.foo|)
|
||||
}
|
||||
public set(<set-?>: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>): R|kotlin/Unit| {
|
||||
D|/C.foo|.<Inapplicable(INAPPLICABLE): [kotlin/collections/setValue]>#(this@R|/C|, ::R|/C.foo|, R|<local>/<set-?>|)
|
||||
D|/C.foo|.<Inapplicable(INAPPLICABLE): [kotlin/collections/setValue]>#(this@R|/C|, ::R|/C.foo|, R|<local>/foo|)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,5 +21,5 @@ FILE: simpleDelegatedToMap.kt
|
||||
^ D|/bar|.<Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>#(Null(null), ::R|/bar|)
|
||||
}
|
||||
public set(<set-?>: <ERROR TYPE REF: Ambiguity: getValue, [kotlin/collections/getValue, kotlin/collections/getValue, kotlin/collections/getValue]>): R|kotlin/Unit| {
|
||||
D|/bar|.<Inapplicable(INAPPLICABLE): [kotlin/collections/setValue]>#(Null(null), ::R|/bar|, R|<local>/<set-?>|)
|
||||
D|/bar|.<Inapplicable(INAPPLICABLE): [kotlin/collections/setValue]>#(Null(null), ::R|/bar|, R|<local>/bar|)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import kotlin.system.measureNanoTime
|
||||
|
||||
|
||||
fun checkFirProvidersConsistency(firFiles: List<FirFile>) {
|
||||
for ((session, files) in firFiles.groupBy { it.fileSession }) {
|
||||
for ((session, files) in firFiles.groupBy { it.session }) {
|
||||
val provider = session.firProvider as FirProviderImpl
|
||||
provider.ensureConsistent(files)
|
||||
}
|
||||
|
||||
+4
-6
@@ -5,10 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
abstract class FirPureAbstractElement : FirElement
|
||||
|
||||
abstract class FirAbstractElement(
|
||||
final override val psi: PsiElement?
|
||||
) : FirPureAbstractElement()
|
||||
val NAME_FOR_BACKING_FIELD = Name.identifier("field")
|
||||
val NAME_FOR_DEFAULT_VALUE_PARAMETER = Name.identifier("value")
|
||||
val CONSTRUCTOR_NAME = Name.special("<init>")
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.fir
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
interface FirAnnotationContainer : FirElement {
|
||||
override val psi: PsiElement?
|
||||
val annotations: List<FirAnnotationCall>
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitAnnotationContainer(this, data)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.fir
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
interface FirControlFlowGraphOwner : FirElement {
|
||||
override val psi: PsiElement?
|
||||
val controlFlowGraphReference: FirControlFlowGraphReference
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitControlFlowGraphOwner(this, data)
|
||||
|
||||
fun <D> transformControlFlowGraphReference(transformer: FirTransformer<D>, data: D): FirControlFlowGraphOwner
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2019 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.
|
||||
*/
|
||||
|
||||
@@ -7,27 +7,27 @@ package org.jetbrains.kotlin.fir
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
interface FirElement {
|
||||
val psi: PsiElement?
|
||||
|
||||
fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
||||
visitor.visitElement(this, data)
|
||||
fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitElement(this, data)
|
||||
|
||||
fun accept(visitor: FirVisitorVoid) =
|
||||
accept(visitor, null)
|
||||
fun accept(visitor: FirVisitorVoid) = accept(visitor, null)
|
||||
|
||||
fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {}
|
||||
fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D)
|
||||
|
||||
fun acceptChildren(visitor: FirVisitorVoid) =
|
||||
acceptChildren(visitor, null)
|
||||
fun acceptChildren(visitor: FirVisitorVoid) = acceptChildren(visitor, null)
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <E : FirElement, D> transform(visitor: FirTransformer<D>, data: D): CompositeTransformResult<E> =
|
||||
accept(visitor, data) as CompositeTransformResult<E>
|
||||
|
||||
fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement = this
|
||||
}
|
||||
fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirElement
|
||||
}
|
||||
@@ -5,11 +5,17 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.visitors.*
|
||||
|
||||
/*
|
||||
* This file was generated automatically
|
||||
* DO NOT MODIFY IT MANUALLY
|
||||
*/
|
||||
|
||||
interface FirLabel : FirElement {
|
||||
override val psi: PsiElement?
|
||||
val name: String
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
||||
visitor.visitLabel(this, data)
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitLabel(this, data)
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 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.fir
|
||||
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
|
||||
// Target element which may have label
|
||||
interface FirLabeledElement : FirTargetElement {
|
||||
val label: FirLabel? get() = null
|
||||
|
||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R =
|
||||
visitor.visitLabeledElement(this, data)
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
label?.accept(visitor, data)
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user