diff --git a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt index 25ea7861f95..b96eb2ba4cb 100644 --- a/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt +++ b/compiler/fir/dump/src/org/jetbrains/kotlin/fir/dump/HtmlFirDump.kt @@ -22,9 +22,7 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirUncheckedNotNullCastImpl 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.resolve.directExpansionType -import org.jetbrains.kotlin.fir.resolve.toSymbol -import org.jetbrains.kotlin.fir.resolve.withNullability +import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.symbols.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.FirTypePlaceholderProjection @@ -1167,6 +1165,20 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver keyword("class") } + private fun FlowContent.generate(resolvedQualifier: FirResolvedQualifier) { + resolved { + val symbolProvider = session.service() + val classId = resolvedQualifier.classId + if (classId != null) { + symbolRef(symbolProvider.getClassLikeSymbolByFqName(classId)) { + fqn(classId.relativeClassName) + } + } else { + fqn(resolvedQualifier.packageFqName) + } + } + } + private fun FlowContent.generate(expression: FirExpression) { exprType(expression.typeRef) { when (expression) { @@ -1195,6 +1207,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver is FirFunctionCall -> { generate(expression) } + is FirResolvedQualifier -> generate(expression) is FirQualifiedAccessExpression -> generate(expression) is FirNamedArgumentExpression -> { simpleName(expression.name) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 6b13e78b264..b68c8bff328 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -21,6 +21,9 @@ import org.jetbrains.kotlin.fir.resolve.buildUseSiteScope import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.impl.FirClassSubstitutionScope +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag +import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTagImpl +import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol @@ -1160,4 +1163,19 @@ internal class Fir2IrVisitor( ) } } + + override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: Any?): IrElement { + val classId = resolvedQualifier.classId + if (classId != null) { + val classSymbol = ConeClassLikeLookupTagImpl(classId).toSymbol(session)!! + return resolvedQualifier.convertWithOffsets { startOffset, endOffset -> + IrGetObjectValueImpl( + startOffset, endOffset, + resolvedQualifier.typeRef.toIrType(session, declarationStorage), + classSymbol.toIrSymbol(session, declarationStorage) as IrClassSymbol + ) + } + } + return super.visitResolvedQualifier(resolvedQualifier, data) + } } \ No newline at end of file diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt index e6202836724..86a09977903 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/deserialization/KotlinDeserializedJvmSymbolsProvider.kt @@ -26,6 +26,7 @@ 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.resolve.* +import org.jetbrains.kotlin.fir.resolve.transformers.firSafeNullable import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope @@ -146,7 +147,7 @@ class KotlinDeserializedJvmSymbolsProvider( ): FirScope? { val symbol = this.getClassLikeSymbolByFqName(classId) ?: return null - return symbol.firUnsafe().buildDefaultUseSiteScope(session, scopeSession) + return symbol.firSafeNullable()?.buildDefaultUseSiteScope(session, scopeSession) } override fun getClassLikeSymbolByFqName(classId: ClassId): ConeClassLikeSymbol? { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt index 4bb74bfafce..0cea525113e 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ScopeUtils.kt @@ -29,10 +29,7 @@ fun ConeKotlinType.scope(useSiteSession: FirSession, scopeSession: ScopeSession) // For ConeClassLikeType they might be a type alias instead of a regular class // TODO: support that case and switch back to `firUnsafe` instead of `firSafeNullable` val fir = this.lookupTag.toSymbol(useSiteSession)?.firSafeNullable() ?: return null - val companionScope = fir.companionObject?.buildUseSiteScope(useSiteSession, scopeSession) - val ownScope = wrapSubstitutionScopeIfNeed(useSiteSession, fir.buildUseSiteScope(useSiteSession, scopeSession)!!, scopeSession) - if (companionScope != null) FirCompositeScope(mutableListOf(ownScope, companionScope)) else ownScope - + wrapSubstitutionScopeIfNeed(useSiteSession, fir.buildUseSiteScope(useSiteSession, scopeSession)!!, scopeSession) } is ConeTypeParameterType -> { // TODO: support LibraryTypeParameterSymbol or get rid of it diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt index 1abf7aeddf7..caf3bf8f845 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/CallResolver.kt @@ -8,16 +8,21 @@ 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.* +import org.jetbrains.kotlin.fir.declarations.impl.FirImportImpl +import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedImportImpl import org.jetbrains.kotlin.fir.expressions.FirExpression +import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.scope import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculatorWithJump +import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe import org.jetbrains.kotlin.fir.scopes.FirPosition import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction +import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope import org.jetbrains.kotlin.fir.scopes.processClassifiersByNameWithAction import org.jetbrains.kotlin.fir.service import org.jetbrains.kotlin.fir.symbols.* @@ -25,6 +30,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.types.* +import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage import org.jetbrains.kotlin.resolve.calls.model.PostponedResolvedAtomMarker @@ -253,6 +259,84 @@ class ScopeTowerLevel( } +/** + * Handles only statics and top-levels, DOES NOT handle objects/companions members + */ +class QualifiedReceiverTowerLevel(session: FirSession) : SessionBasedTowerLevel(session) { + override fun processElementsByName( + token: TowerScopeLevel.Token, + name: Name, + explicitReceiver: ExpressionReceiverValue?, + processor: TowerScopeLevel.TowerScopeLevelProcessor + ): ProcessorAction { + val qualifiedReceiver = explicitReceiver?.explicitReceiverExpression as FirResolvedQualifier + val scope = FirExplicitSimpleImportingScope( + listOf( + FirResolvedImportImpl( + session, + FirImportImpl(session, null, FqName.topLevel(name), false, null), + qualifiedReceiver.packageFqName, + qualifiedReceiver.relativeClassFqName + ) + ), session + ) + + return if (token == TowerScopeLevel.Token.Objects) { + scope.processClassifiersByNameWithAction(name, FirPosition.OTHER) { + processor.consumeCandidate(it as T, null) + } + } else { + scope.processCallables(name, token.cast()) { + val fir = it.firUnsafe() + if (fir.isStatic || it.callableId.classId == null) { + processor.consumeCandidate(it as T, null) + } else { + ProcessorAction.NEXT + } + } + } + } + +} + +class QualifiedReceiverTowerDataConsumer( + val session: FirSession, + val name: Name, + val token: TowerScopeLevel.Token, + val explicitReceiver: ExpressionReceiverValue, + val candidateFactory: CandidateFactory +) : TowerDataConsumer() { + override fun consume( + kind: TowerDataKind, + towerScopeLevel: TowerScopeLevel, + resultCollector: CandidateCollector, + group: Int + ): ProcessorAction { + if (checkSkip(group, resultCollector)) return ProcessorAction.NEXT + if (kind != TowerDataKind.EMPTY) return ProcessorAction.NEXT + + return QualifiedReceiverTowerLevel(session).processElementsByName( + token, + name, + explicitReceiver, + processor = object : TowerScopeLevel.TowerScopeLevelProcessor { + override fun consumeCandidate(symbol: T, dispatchReceiverValue: ClassDispatchReceiverValue?): ProcessorAction { + assert(dispatchReceiverValue == null) + resultCollector.consumeCandidate( + group, + candidateFactory.createCandidate( + symbol, + null, + ExplicitReceiverKind.NO_EXPLICIT_RECEIVER + ) + ) + return ProcessorAction.NEXT + } + } + ) + } +} + abstract class TowerDataConsumer { abstract fun consume( @@ -321,14 +405,25 @@ fun createSimpleConsumer( inferenceComponents: InferenceComponents ): TowerDataConsumer { val factory = CandidateFactory(inferenceComponents, callInfo) - return if (callInfo.explicitReceiver != null) { - ExplicitReceiverTowerDataConsumer( - session, - name, - token, - ExpressionReceiverValue(callInfo.explicitReceiver, callInfo.typeProvider), - factory - ) + val explicitReceiver = callInfo.explicitReceiver + return if (explicitReceiver != null) { + val receiverValue = ExpressionReceiverValue(explicitReceiver, callInfo.typeProvider) + if (explicitReceiver is FirResolvedQualifier) { + val qualified = + QualifiedReceiverTowerDataConsumer(session, name, token, receiverValue, factory) + + if (explicitReceiver.classId != null) { + PrioritizedTowerDataConsumer( + qualified, + ExplicitReceiverTowerDataConsumer(session, name, token, receiverValue, factory) + ) + } else { + qualified + } + + } else { + ExplicitReceiverTowerDataConsumer(session, name, token, receiverValue, factory) + } } else { NoExplicitReceiverTowerDataConsumer(session, name, token, factory) } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt index b371990b8e1..98f6ea1420f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt @@ -24,7 +24,7 @@ class ClassDispatchReceiverValue(val klassSymbol: FirClassSymbol) : ReceiverValu } class ExpressionReceiverValue( - private val explicitReceiverExpression: FirExpression, + val explicitReceiverExpression: FirExpression, val typeProvider: (FirExpression) -> FirTypeRef? ) : ReceiverValue { override val type: ConeKotlinType diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt index f5fa7abfc35..8c480936026 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolverParts.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.calls import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration +import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier import org.jetbrains.kotlin.fir.resolve.FirProvider import org.jetbrains.kotlin.fir.resolve.transformers.firSafeNullable import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe @@ -39,7 +40,8 @@ internal object CheckExplicitReceiverConsistency : ResolutionStage() { // TODO: add invoke cases when (receiverKind) { NO_EXPLICIT_RECEIVER -> { - if (explicitReceiver != null) return sink.reportApplicability(CandidateApplicability.WRONG_RECEIVER) + if (explicitReceiver != null && explicitReceiver !is FirResolvedQualifier) + return sink.reportApplicability(CandidateApplicability.WRONG_RECEIVER) } EXTENSION_RECEIVER, DISPATCH_RECEIVER -> { if (explicitReceiver == null) return sink.reportApplicability(CandidateApplicability.WRONG_RECEIVER) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt index 08cb27a6498..06cf05968a1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirBodyResolveTransformer.kt @@ -6,10 +6,12 @@ package org.jetbrains.kotlin.fir.resolve.transformers import com.google.common.collect.LinkedHashMultimap +import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.impl.FirValueParameterImpl import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.references.FirSimpleNamedReference import org.jetbrains.kotlin.fir.resolve.* @@ -123,6 +125,10 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn primaryConstructorParametersScope = null val type = regularClass.defaultType() scopes.addIfNotNull(type.scope(session, scopeSession)) + val companionObject = regularClass.companionObject + if (companionObject != null) { + scopes.addIfNotNull(symbolProvider.getClassUseSiteMemberScope(companionObject.classId, session, scopeSession)) + } val result = withLabelAndReceiverType(regularClass.name, regularClass, type) { super.transformRegularClass(regularClass, data) } @@ -159,10 +165,10 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn } FirOperation.SAFE_AS -> { resolved.resultType = - resolved.conversionTypeRef.withReplacedConeType( - session, - resolved.conversionTypeRef.coneTypeUnsafe().withNullability(ConeNullability.NULLABLE) - ) + resolved.conversionTypeRef.withReplacedConeType( + session, + resolved.conversionTypeRef.coneTypeUnsafe().withNullability(ConeNullability.NULLABLE) + ) } else -> error("Unknown type operator") } @@ -251,10 +257,79 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn } }, session) - private fun transformCallee(qualifiedAccess: T): T { + private var qualifierStack = mutableListOf() + private var qualifierPartsToDrop = 0 + + private fun tryResolveAsQualifier(): FirStatement? { + + val symbolProvider = session.service() + var qualifierParts = qualifierStack.asReversed().map { it.asString() } + var resolved: PackageOrClass? + do { + resolved = resolveToPackageOrClass( + symbolProvider, + FqName.fromSegments(qualifierParts) + ) + if (resolved == null) + qualifierParts = qualifierParts.dropLast(1) + } while (resolved == null && qualifierParts.isNotEmpty()) + + if (resolved != null) { + qualifierPartsToDrop = qualifierParts.size - 1 + return FirResolvedQualifierImpl(session, null /* TODO */, resolved.packageFqName, resolved.relativeClassFqName) + .apply { resultType = typeForQualifier(this) } + } + + return null + } + + private fun typeForQualifier(resolvedQualifier: FirResolvedQualifier): FirTypeRef { + val classId = resolvedQualifier.classId + val resultType = resolvedQualifier.resultType + if (classId != null) { + val classSymbol = symbolProvider.getClassLikeSymbolByFqName(classId)!! + val declaration = classSymbol.firUnsafe() + if (declaration is FirClass) { + if (declaration.classKind == ClassKind.OBJECT) { + return resultType.resolvedTypeFromPrototype( + classSymbol.constructType(emptyArray(), false) + ) + } else if (declaration.classKind == ClassKind.ENUM_ENTRY) { + val enumClassSymbol = symbolProvider.getClassLikeSymbolByFqName(classSymbol.classId.outerClassId!!)!! + return resultType.resolvedTypeFromPrototype( + enumClassSymbol.constructType(emptyArray(), false) + ) + } else { + if (declaration is FirRegularClass) { + val companionObject = declaration.companionObject + if (companionObject != null) { + return resultType.resolvedTypeFromPrototype( + companionObject.symbol.constructType(emptyArray(), false) + ) + } + } + } + } + } + // TODO: Handle no value type here + return resultType.resolvedTypeFromPrototype( + StandardClassIds.Unit(symbolProvider).constructType(emptyArray(), isNullable = false) + ) + } + + private fun transformCallee(qualifiedAccess: T): FirStatement { val callee = qualifiedAccess.calleeReference as? FirSimpleNamedReference ?: return qualifiedAccess + if (qualifiedAccess.safe || callee.name.isSpecial) { + qualifierStack.clear() + } else { + qualifierStack.add(callee.name) + } val qualifiedAccess = qualifiedAccess.transformExplicitReceiver(this, noExpectedType) + if (qualifierPartsToDrop > 0) { + qualifierPartsToDrop-- + return qualifiedAccess.explicitReceiver ?: qualifiedAccess + } val info = CallInfo( CallKind.VariableAccess, @@ -277,12 +352,32 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn ) val result = resolver.runTowerResolver(consumer, implicitReceiverStack.asReversed()) + val candidates = result.bestCandidates() val nameReference = createResolvedNamedReference( callee, - result.bestCandidates(), + candidates, result.currentApplicability ) + if (qualifiedAccess.explicitReceiver == null && + (candidates.size <= 1 && result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED) + ) { + tryResolveAsQualifier()?.let { return it } + } + + if (nameReference is FirResolvedCallableReference) { + val symbol = nameReference.coneSymbol as? ConeClassLikeSymbol + if (symbol != null) { + return FirResolvedQualifierImpl(session, nameReference.psi, symbol.classId).apply { + resultType = typeForQualifier(this) + } + } + } + + if (qualifiedAccess.explicitReceiver == null) { + qualifierStack.clear() + } + val resultExpression = qualifiedAccess.transformCalleeReference(StoreNameReference, nameReference) as T if (resultExpression is FirExpression) storeTypeFromCallee(resultExpression) @@ -304,15 +399,15 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn } is FirSuperReference -> { qualifiedAccessExpression.resultType = - callee.superTypeRef as? FirResolvedTypeRef ?: - implicitReceiverStack.filterIsInstance().lastOrNull() + callee.superTypeRef as? FirResolvedTypeRef + ?: implicitReceiverStack.filterIsInstance().lastOrNull() ?.boundSymbol?.fir?.superTypeRefs?.firstOrNull() - ?: FirErrorTypeRefImpl(session, qualifiedAccessExpression.psi, "No super type") + ?: FirErrorTypeRefImpl(session, qualifiedAccessExpression.psi, "No super type") } is FirResolvedCallableReference -> { if (qualifiedAccessExpression.typeRef !is FirResolvedTypeRef) { qualifiedAccessExpression.resultType = - jump.tryCalculateReturnType(callee.coneSymbol.firUnsafe()) + jump.tryCalculateReturnType(callee.coneSymbol.firUnsafe()) } } } @@ -365,6 +460,8 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn private fun resolveCallAndSelectCandidate(functionCall: FirFunctionCall, expectedTypeRef: FirTypeRef?): FirFunctionCall { + qualifierStack.clear() + val functionCall = (functionCall.transformExplicitReceiver(this, noExpectedType) as FirFunctionCall) .transformArguments(this, null) as FirFunctionCall @@ -795,13 +892,33 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn override fun transformGetClassCall(getClassCall: FirGetClassCall, data: Any?): CompositeTransformResult { val transformedGetClassCall = super.transformGetClassCall(getClassCall, data).single as FirGetClassCall val kClassSymbol = ClassId.fromString("kotlin/reflect/KClass")(session.service()) + + val typeOfExpression = when (val lhs = transformedGetClassCall.argument) { + is FirResolvedQualifier -> { + val classId = lhs.classId + if (classId != null) { + val symbol = symbolProvider.getClassLikeSymbolByFqName(classId)!! + // TODO: Unify logic? + symbol.constructType( + Array(symbol.firUnsafe().typeParameters.size) { + ConeStarProjection + }, + isNullable = false + ) + } else { + lhs.resultType.coneTypeUnsafe() + } + } + else -> lhs.resultType.coneTypeUnsafe() + } + transformedGetClassCall.resultType = - FirResolvedTypeRefImpl( - session, - null, - kClassSymbol.constructType(arrayOf(transformedGetClassCall.argument.resultType.coneTypeUnsafe()), false), - emptyList() - ) + FirResolvedTypeRefImpl( + session, + null, + kClassSymbol.constructType(arrayOf(typeOfExpression), false), + emptyList() + ) return transformedGetClassCall.compose() } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirImportResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirImportResolveTransformer.kt index 776ecd7d072..d27d5d0816f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirImportResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/FirImportResolveTransformer.kt @@ -49,32 +49,34 @@ class FirImportResolveTransformer() : FirAbstractTreeTransformer() { } private fun transformImportForFqName(fqName: FqName, delegate: FirImport): CompositeTransformResult { - val (packageFqName, relativeClassFqName) = resolveToPackageOrClass(fqName) ?: return delegate.compose() + val (packageFqName, relativeClassFqName) = resolveToPackageOrClass(symbolProvider, fqName) ?: return delegate.compose() return FirResolvedImportImpl(session, delegate, packageFqName, relativeClassFqName).compose() } - private fun resolveToPackageOrClass(fqName: FqName): PackageOrClass? { - var currentPackage = fqName - val pathSegments = fqName.pathSegments() - var prefixSize = pathSegments.size - while (!currentPackage.isRoot) { - if (symbolProvider.getPackage(currentPackage) != null) { - break - } - currentPackage = currentPackage.parent() - prefixSize-- +} + +fun resolveToPackageOrClass(symbolProvider: FirSymbolProvider, fqName: FqName): PackageOrClass? { + var currentPackage = fqName + + val pathSegments = fqName.pathSegments() + var prefixSize = pathSegments.size + while (!currentPackage.isRoot && prefixSize > 0) { + if (symbolProvider.getPackage(currentPackage) != null) { + break } - - if (currentPackage == fqName) return PackageOrClass(currentPackage, null) - val relativeClassFqName = - FqName.fromSegments((prefixSize until pathSegments.size).map { pathSegments[it].asString() }) - - val classId = ClassId(currentPackage, relativeClassFqName, false) - if (symbolProvider.getClassLikeSymbolByFqName(classId) == null) return null - - return PackageOrClass(currentPackage, relativeClassFqName) + currentPackage = currentPackage.parent() + prefixSize-- } - private data class PackageOrClass(val packageFqName: FqName, val relativeClassFqName: FqName?) + if (currentPackage == fqName) return PackageOrClass(currentPackage, null) + val relativeClassFqName = + FqName.fromSegments((prefixSize until pathSegments.size).map { pathSegments[it].asString() }) + + val classId = ClassId(currentPackage, relativeClassFqName, false) + if (symbolProvider.getClassLikeSymbolByFqName(classId) == null) return null + + return PackageOrClass(currentPackage, relativeClassFqName) } + +data class PackageOrClass(val packageFqName: FqName, val relativeClassFqName: FqName?) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt index c1a8ea0cc8b..fd3d17e2d39 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirAbstractImportingScope.kt @@ -7,8 +7,13 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirResolvedImport +import org.jetbrains.kotlin.fir.declarations.FirTypeAlias +import org.jetbrains.kotlin.fir.declarations.expandedConeType import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.calls.TowerScopeLevel +import org.jetbrains.kotlin.fir.resolve.toSymbol +import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe +import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.ProcessorAction import org.jetbrains.kotlin.fir.scopes.processConstructors import org.jetbrains.kotlin.fir.symbols.* @@ -21,7 +26,23 @@ abstract class FirAbstractImportingScope(session: FirSession, lookupInFir: Boole protected val scopeCache = ScopeSession() - fun processCallables( + + private fun getStaticsScope(classId: ClassId): FirScope? { + provider.getClassUseSiteMemberScope(classId, session, scopeCache)?.let { return it } + + + val symbol = provider.getClassLikeSymbolByFqName(classId) ?: error("No scope/symbol for $classId") + if (symbol is ConeTypeAliasSymbol) { + val expansionSymbol = symbol.firUnsafe().expandedConeType?.lookupTag?.toSymbol(session) + if (expansionSymbol as? ConeClassLikeSymbol != null) { + return getStaticsScope(expansionSymbol.classId) + } + } + + return null + } + + protected fun processCallables( import: FirResolvedImport, name: Name, token: TowerScopeLevel.Token, @@ -31,9 +52,8 @@ abstract class FirAbstractImportingScope(session: FirSession, lookupInFir: Boole val classId = import.resolvedClassId if (classId != null) { + val scope = getStaticsScope(classId) ?: return ProcessorAction.NEXT - val scope = - provider.getClassUseSiteMemberScope(classId, session, scopeCache) ?: error("No scope for $classId") val action = when (token) { TowerScopeLevel.Token.Functions -> scope.processFunctionsByName( @@ -75,7 +95,7 @@ abstract class FirAbstractImportingScope(session: FirSession, lookupInFir: Boole return ProcessorAction.NEXT } - protected abstract fun processCallables( + abstract fun processCallables( name: Name, token: TowerScopeLevel.Token, processor: (ConeCallableSymbol) -> ProcessorAction diff --git a/compiler/fir/resolve/testData/resolve/enum.txt b/compiler/fir/resolve/testData/resolve/enum.txt index fdc278f21ad..6ff62c73207 100644 --- a/compiler/fir/resolve/testData/resolve/enum.txt +++ b/compiler/fir/resolve/testData/resolve/enum.txt @@ -23,7 +23,7 @@ FILE: enum.kt public final enum entry FIRST : R|SomeEnum| { public constructor(): R|SomeEnum.FIRST| { - super(R|/O1|) + super(Q|O1|) } public final override fun check(y: R|Some|): R|kotlin/Boolean| { @@ -34,11 +34,11 @@ FILE: enum.kt public final enum entry SECOND : R|SomeEnum| { public constructor(): R|SomeEnum.SECOND| { - super(R|/O2|) + super(Q|O2|) } public final override fun check(y: R|Some|): R|kotlin/Boolean| { - ^check ==(R|/y|, R|/O2|) + ^check ==(R|/y|, Q|O2|) } } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/companion.txt b/compiler/fir/resolve/testData/resolve/expresssions/companion.txt index 81020808eb8..d1e9297592d 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/companion.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/companion.txt @@ -42,10 +42,10 @@ FILE: companion.kt } public final fun test(): R|kotlin/Unit| { - R|/A|.R|/A.Companion.foo|() - R|/B|.#() - R|/B|.R|/B.Companion.baz|() - lval x: R|kotlin/String| = R|/A|.R|/A.Companion.D| - lval y: R|kotlin/String| = R|/B|.R|/B.Companion.C| - lval z: = R|/B|.# + Q|A|.R|/A.Companion.foo|() + Q|B|.R|/A.bar|() + Q|B|.R|/B.Companion.baz|() + lval x: R|kotlin/String| = Q|A|.R|/A.Companion.D| + lval y: R|kotlin/String| = Q|B|.R|/B.Companion.C| + lval z: = Q|B|.# } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/objects.txt b/compiler/fir/resolve/testData/resolve/expresssions/objects.txt index cd16d50bbdd..3db15fcf254 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/objects.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/objects.txt @@ -10,8 +10,8 @@ FILE: objects.kt } public final fun use(): R|A| { - ^use R|/A| + ^use Q|A| } public final fun bar(): R|A| { - ^bar R|/A|.R|/A.foo|() + ^bar Q|A|.R|/A.foo|() } diff --git a/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.kt b/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.kt new file mode 100644 index 00000000000..8917d08e900 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.kt @@ -0,0 +1,33 @@ +package a.b + +class C { + object D { + fun foo() {} + } + + + companion object { + fun foo() {} + } + + fun foo() {} +} + +enum class E { + entry +} + +fun foo() {} + +val f = 10 + +fun main() { + a.b.foo() + a.b.C.foo() + a.b.C.D.foo() + val x = a.b.f + C.foo() + C().foo() + val e = a.b.E.entry + val e1 = E.entry +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt b/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt new file mode 100644 index 00000000000..d853eb13249 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt @@ -0,0 +1,57 @@ +FILE: qualifiedExpressions.kt + public final class C : R|kotlin/Any| { + public constructor(): R|a/b/C| { + super() + } + + public final object D : R|kotlin/Any| { + private constructor(): R|a/b/C.D| { + super() + } + + public final fun foo(): R|kotlin/Unit| { + } + + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|a/b/C.Companion| { + super() + } + + public final fun foo(): R|kotlin/Unit| { + } + + } + + public final fun foo(): R|kotlin/Unit| { + } + + } + public final enum class E : R|kotlin/Enum| { + private constructor(): R|a/b/E| { + super() + } + + public final enum entry entry : R|kotlin/Any| { + public constructor(): R|a/b/E.entry| { + super() + } + + } + + } + public final fun foo(): R|kotlin/Unit| { + } + public final val f: R|kotlin/Int| = Int(10) + public get(): R|kotlin/Int| + public final fun main(): R|kotlin/Unit| { + Q|a/b|.R|a/b/foo|() + Q|a/b/C|.R|a/b/C.Companion.foo|() + Q|a/b/C.D|.R|a/b/C.D.foo|() + lval x: R|kotlin/Int| = Q|a/b|.R|a/b/f| + Q|a/b/C|.R|a/b/C.Companion.foo|() + R|a/b/C.C|().R|a/b/C.foo|() + lval e: R|a/b/E| = Q|a/b/E.entry| + lval e1: R|a/b/E| = Q|a/b/E.entry| + } diff --git a/compiler/fir/resolve/testData/resolve/nested/inner.txt b/compiler/fir/resolve/testData/resolve/nested/inner.txt index 1c290990da7..5acaceb8493 100644 --- a/compiler/fir/resolve/testData/resolve/nested/inner.txt +++ b/compiler/fir/resolve/testData/resolve/nested/inner.txt @@ -41,8 +41,8 @@ FILE: inner.kt public final fun test(): R|kotlin/Unit| { lval o: R|Owner| = R|/Owner.Owner|() R|/o|.R|/Owner.foo|() - lval err: R|Owner.Inner| = R|/Owner|.R|/Owner.Inner.Inner|() - R|/err|.R|/Owner.Inner.baz|() + lval err: = Q|Owner|.#() + R|/err|.#() lval i: R|Owner.Inner| = R|/o|.R|/Owner.Inner.Inner|() R|/i|.R|/Owner.Inner.gau|() } diff --git a/compiler/fir/resolve/testData/resolve/nested/simple.txt b/compiler/fir/resolve/testData/resolve/nested/simple.txt index 742efc34ecf..8a045b7ab61 100644 --- a/compiler/fir/resolve/testData/resolve/nested/simple.txt +++ b/compiler/fir/resolve/testData/resolve/nested/simple.txt @@ -40,6 +40,6 @@ FILE: simple.kt public final fun test(): R|kotlin/Unit| { lval o: R|Owner| = R|/Owner.Owner|() R|/o|.R|/Owner.foo|() - lval n: R|Owner.Nested| = R|/Owner|.R|/Owner.Nested.Nested|() - R|/n|.R|/Owner.Nested.baz|() + lval n: = Q|Owner|.#() + R|/n|.#() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/companionLoad.txt b/compiler/fir/resolve/testData/resolve/stdlib/companionLoad.txt index c92d72e386a..db2cd3e4611 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/companionLoad.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/companionLoad.txt @@ -1,4 +1,4 @@ FILE: companionLoad.kt public final fun main(): R|kotlin/Unit| { - lval y: R|kotlin/Int| = R|kotlin/Int|.R|kotlin/Int.Companion.MAX_VALUE| + lval y: R|kotlin/Int| = Q|kotlin/Int|.R|kotlin/Int.Companion.MAX_VALUE| } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.txt b/compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.txt index 8d3ffcd1fb4..5e05b619819 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/reflectionClass.txt @@ -1,5 +1,5 @@ FILE: reflectionClass.kt - public final val javaClass: R|java/lang/Class| = (R|kotlin/String|).R|kotlin/jvm/java| + public final val javaClass: R|java/lang/Class| = (Q|kotlin/String|).R|kotlin/jvm/java| public get(): R|java/lang/Class| - public final val kotlinClass: R|kotlin/reflect/KClass| = (R|kotlin/String|) + public final val kotlinClass: R|kotlin/reflect/KClass| = (Q|kotlin/String|) public get(): R|kotlin/reflect/KClass| diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java index 8a577758062..1abef9bda4e 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirResolveTestCaseGenerated.java @@ -257,6 +257,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase { runTest("compiler/fir/resolve/testData/resolve/expresssions/objects.kt"); } + @TestMetadata("qualifiedExpressions.kt") + public void testQualifiedExpressions() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.kt"); + } + @TestMetadata("receiverConsistency.kt") public void testReceiverConsistency() throws Exception { runTest("compiler/fir/resolve/testData/resolve/expresssions/receiverConsistency.kt"); diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt index 9069e819598..a9518467879 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/FirRenderer.kt @@ -930,4 +930,15 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() { uncheckedNotNullCast.expression.accept(this) print("!") } + + override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { + print("Q|") + val classId = resolvedQualifier.classId + if (classId != null) { + print(classId.asString()) + } else { + print(resolvedQualifier.packageFqName.asString().replace(".", "/")) + } + print("|") + } } diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt new file mode 100644 index 00000000000..2334d5d5ab0 --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/FirResolvedQualifier.kt @@ -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.expressions + +import org.jetbrains.kotlin.fir.visitors.FirVisitor +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName + +interface FirResolvedQualifier : FirExpression { + + override fun accept(visitor: FirVisitor, data: D): R = visitor.visitResolvedQualifier(this, data) + + val packageFqName: FqName + val relativeClassFqName: FqName? + val classId + get() = relativeClassFqName?.let { + ClassId(packageFqName, it, false) + } +} \ No newline at end of file diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt new file mode 100644 index 00000000000..c0cb372aa8d --- /dev/null +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/expressions/impl/FirResolvedQualifierImpl.kt @@ -0,0 +1,26 @@ +/* + * 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.expressions.impl + +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.fir.FirSession +import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName + +class FirResolvedQualifierImpl( + session: FirSession, + psi: PsiElement?, + override val packageFqName: FqName, + override val relativeClassFqName: FqName? +) : FirResolvedQualifier, FirAbstractExpression(session, psi) { + constructor(session: FirSession, psi: PsiElement?, classId: ClassId) : this( + session, + psi, + classId.packageFqName, + classId.relativeClassName + ) +} \ No newline at end of file diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt index ed57fbfee5d..07ad55a1fe6 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirTransformerGenerated.kt @@ -268,6 +268,10 @@ abstract class FirTransformer : FirVisitor { + return transformExpression(resolvedQualifier, data) + } + open fun transformThrowExpression(throwExpression: FirThrowExpression, data: D): CompositeTransformResult { return transformExpression(throwExpression, data) } @@ -664,6 +668,10 @@ abstract class FirTransformer : FirVisitor { + return transformResolvedQualifier(resolvedQualifier, data) + } + final override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: D): CompositeTransformResult { return transformResolvedTypeRef(resolvedTypeRef, data) } diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt index d22323dc2f5..ddbb6ca1113 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorGenerated.kt @@ -268,6 +268,10 @@ abstract class FirVisitor { return visitJump(returnExpression, data) } + open fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: D): R { + return visitExpression(resolvedQualifier, data) + } + open fun visitThrowExpression(throwExpression: FirThrowExpression, data: D): R { return visitExpression(throwExpression, data) } diff --git a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt index d1330c056fc..355451e2926 100644 --- a/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt +++ b/compiler/fir/tree/visitors/org/jetbrains/kotlin/fir/visitors/FirVisitorVoidGenerated.kt @@ -268,6 +268,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitJump(returnExpression, null) } + open fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) { + visitExpression(resolvedQualifier, null) + } + open fun visitThrowExpression(throwExpression: FirThrowExpression) { visitExpression(throwExpression, null) } @@ -664,6 +668,10 @@ abstract class FirVisitorVoid : FirVisitor() { visitResolvedImport(resolvedImport) } + final override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: Nothing?) { + visitResolvedQualifier(resolvedQualifier) + } + final override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: Nothing?) { visitResolvedTypeRef(resolvedTypeRef) } diff --git a/compiler/testData/ir/irText/classes/enum.fir.txt b/compiler/testData/ir/irText/classes/enum.fir.txt index 3e9bff72f7d..37033cd63e7 100644 --- a/compiler/testData/ir/irText/classes/enum.fir.txt +++ b/compiler/testData/ir/irText/classes/enum.fir.txt @@ -279,7 +279,7 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER name: type:.TestEnum4.TEST1 BLOCK_BODY CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null - message: ERROR_CALL 'Unresolved reference: R|/TestEnum4.TEST1|' type=.TestEnum4 + message: GET_OBJECT 'CLASS ENUM_ENTRY name:TEST1 modality:FINAL visibility:public superTypes:[.TestEnum4]' type=.TestEnum4 FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any overridden: protected final fun clone (): kotlin.Any declared in kotlin.Enum @@ -326,7 +326,7 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER name: type:.TestEnum4.TEST2 BLOCK_BODY CALL 'public final fun println (message: kotlin.Any?): kotlin.Unit [inline] declared in kotlin.io' type=kotlin.Unit origin=null - message: ERROR_CALL 'Unresolved reference: R|/TestEnum4.TEST2|' type=.TestEnum4 + message: GET_OBJECT 'CLASS ENUM_ENTRY name:TEST2 modality:FINAL visibility:public superTypes:[.TestEnum4]' type=.TestEnum4 FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any overridden: protected final fun clone (): kotlin.Any declared in kotlin.Enum diff --git a/compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.fir.txt index 51f3d3f42a9..66812bd2b0d 100644 --- a/compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferenceToImportedFromObject.fir.txt @@ -47,7 +47,7 @@ FILE fqName:test fileName:/callableReferenceToImportedFromObject.kt FIELD PROPERTY_BACKING_FIELD name:test1a type:kotlin.String visibility:public [final,static] EXPRESSION_BODY CALL 'public final fun (): kotlin.String declared in test.Foo' type=kotlin.String origin=null - $this: ERROR_CALL 'Unresolved reference: R|test/Foo|' type=test.Foo + $this: GET_OBJECT 'CLASS OBJECT name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' type=test.Foo FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.String correspondingProperty: PROPERTY name:test1a visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/classReference.fir.txt b/compiler/testData/ir/irText/expressions/classReference.fir.txt index 5a0e30cf4bc..b81c6721e7f 100644 --- a/compiler/testData/ir/irText/expressions/classReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/classReference.fir.txt @@ -21,7 +21,7 @@ FILE fqName: fileName:/classReference.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY GET_CLASS type=kotlin.reflect.KClass<.A> - ERROR_CALL 'Unresolved reference: R|/A|' type=.A + GET_OBJECT 'CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit GET_CLASS type=kotlin.reflect.KClass<.A> CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null ERROR_CALL 'No getter found for R|kotlin/jvm/java|' type=java.lang.Class> diff --git a/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.txt b/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.txt index e0d43187ed8..d28577c5c7b 100644 --- a/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.txt +++ b/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.fir.txt @@ -144,21 +144,21 @@ FILE fqName: fileName:/complexAugmentedAssignment.kt BLOCK_BODY VAR name: type:kotlin.Int [val] CALL 'public final fun (): kotlin.Int declared in .X1' type=kotlin.Int origin=null - $this: ERROR_CALL 'Unresolved reference: R|/X1|' type=.X1 + $this: GET_OBJECT 'CLASS OBJECT name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1 SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x1 type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null $this: GET_VAR 'val : kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null GET_VAR 'val : kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null VAR name: type:kotlin.Int [val] CALL 'public final fun (): kotlin.Int declared in .X1.X2' type=kotlin.Int origin=null - $this: ERROR_CALL 'Unresolved reference: R|/X1.X2|' type=.X1.X2 + $this: GET_OBJECT 'CLASS OBJECT name:X2 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1.X2 SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x2 type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null $this: GET_VAR 'val : kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null GET_VAR 'val : kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null VAR name: type:kotlin.Int [val] CALL 'public final fun (): kotlin.Int declared in .X1.X2.X3' type=kotlin.Int origin=null - $this: ERROR_CALL 'Unresolved reference: R|/X1.X2.X3|' type=.X1.X2.X3 + $this: GET_OBJECT 'CLASS OBJECT name:X3 modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.X1.X2.X3 SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x3 type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null $this: GET_VAR 'val : kotlin.Int [val] declared in .test2' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/expressions/destructuring1.fir.txt b/compiler/testData/ir/irText/expressions/destructuring1.fir.txt index a1227ab2742..5c2d3d31619 100644 --- a/compiler/testData/ir/irText/expressions/destructuring1.fir.txt +++ b/compiler/testData/ir/irText/expressions/destructuring1.fir.txt @@ -50,7 +50,7 @@ FILE fqName: fileName:/destructuring1.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name: type:.A [val] - ERROR_CALL 'Unresolved reference: R|/A|' type=.A + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int declared in .B' type=kotlin.Int origin=null $this: GET_VAR 'val : .A [val] declared in .test' type=.A origin=null diff --git a/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt b/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt index bf64edf5086..aa5832c3243 100644 --- a/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt +++ b/compiler/testData/ir/irText/expressions/destructuringWithUnderscore.fir.txt @@ -55,7 +55,7 @@ FILE fqName: fileName:/destructuringWithUnderscore.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name: type:.A [val] - ERROR_CALL 'Unresolved reference: R|/A|' type=.A + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int declared in .B' type=kotlin.Int origin=null $this: GET_VAR 'val : .A [val] declared in .test' type=.A origin=null diff --git a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.txt index 96e93acf8bb..64ddd4e4b6a 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.fir.txt @@ -97,7 +97,7 @@ FILE fqName: fileName:/forWithImplicitReceivers.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name: type:.FiveTimes [val] - ERROR_CALL 'Unresolved reference: R|/FiveTimes|' type=.FiveTimes + GET_OBJECT 'CLASS OBJECT name:FiveTimes modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.FiveTimes VAR name: type:.IntCell [val] CALL 'public open fun iterator (): .IntCell declared in .IReceiver' type=.IntCell origin=null $this: GET_VAR 'val : .FiveTimes [val] declared in .test' type=.FiveTimes origin=null diff --git a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt index e00a8cd1f28..f215b5d96fa 100644 --- a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt @@ -89,7 +89,7 @@ FILE fqName: fileName:/objectAsCallable.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: #' type=IrErrorType + ERROR_CALL 'Unresolved reference: #' type=IrErrorType CONST Int type=kotlin.Int value=42 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] diff --git a/compiler/testData/ir/irText/expressions/objectClassReference.fir.txt b/compiler/testData/ir/irText/expressions/objectClassReference.fir.txt index d8696b3cb7d..554975dd7c7 100644 --- a/compiler/testData/ir/irText/expressions/objectClassReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectClassReference.fir.txt @@ -21,6 +21,6 @@ FILE fqName: fileName:/objectClassReference.kt FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY GET_CLASS type=kotlin.reflect.KClass<.A> - ERROR_CALL 'Unresolved reference: R|/A|' type=.A + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A ERROR_CALL 'No getter found for R|kotlin/jvm/java|' type=java.lang.Class> diff --git a/compiler/testData/ir/irText/expressions/objectReference.fir.txt b/compiler/testData/ir/irText/expressions/objectReference.fir.txt index 6b85d4866f6..edc9012202b 100644 --- a/compiler/testData/ir/irText/expressions/objectReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectReference.fir.txt @@ -36,7 +36,7 @@ FILE fqName: fileName:/objectReference.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null - $this: ERROR_CALL 'Unresolved reference: R|/Z|' type=.Z + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z CLASS CLASS name:Nested modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z.Nested CONSTRUCTOR visibility:public <> () returnType:.Z.Nested [primary] @@ -51,7 +51,7 @@ FILE fqName: fileName:/objectReference.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null - $this: ERROR_CALL 'Unresolved reference: R|/Z|' type=.Z + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z FUN name:test visibility:public modality:FINAL <> ($this:.Z.Nested) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Z.Nested BLOCK_BODY @@ -61,7 +61,7 @@ FILE fqName: fileName:/objectReference.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null - $this: ERROR_CALL 'Unresolved reference: R|/Z|' type=.Z + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any @@ -88,7 +88,7 @@ FILE fqName: fileName:/objectReference.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null - $this: ERROR_CALL 'Unresolved reference: R|/Z|' type=.Z + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z FUNCTION_REFERENCE 'local final fun (): IrErrorType declared in .Z.aLambda' type=IrErrorType origin=LAMBDA FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Z) returnType:IrErrorType correspondingProperty: PROPERTY name:aLambda visibility:public modality:FINAL [val] @@ -115,7 +115,7 @@ FILE fqName: fileName:/objectReference.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null - $this: ERROR_CALL 'Unresolved reference: R|/Z|' type=.Z + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z FUN name:test visibility:public modality:FINAL <> ($this:.Z.anObject.) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Z.anObject. BLOCK_BODY @@ -125,7 +125,7 @@ FILE fqName: fileName:/objectReference.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null - $this: ERROR_CALL 'Unresolved reference: R|/Z|' type=.Z + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Z.anObject.' type=.Z.anObject. origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.Z) returnType:kotlin.Any correspondingProperty: PROPERTY name:anObject visibility:public modality:FINAL [val] @@ -155,4 +155,4 @@ FILE fqName: fileName:/objectReference.kt SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:public ' type=kotlin.Int origin=null value: CONST Int type=kotlin.Int value=1 CALL 'public final fun foo (): kotlin.Unit declared in .Z' type=kotlin.Unit origin=null - $this: ERROR_CALL 'Unresolved reference: R|/Z|' type=.Z + $this: GET_OBJECT 'CLASS OBJECT name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z diff --git a/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt b/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt index 476146a319c..3ff0c4ddd72 100644 --- a/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/propertyReferences.fir.txt @@ -254,23 +254,20 @@ FILE fqName: fileName:/propertyReferences.kt RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_J_nonConst type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=null PROPERTY name:test_varWithPrivateSet visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test_varWithPrivateSet type:kotlin.Int visibility:public [final,static] + FIELD PROPERTY_BACKING_FIELD name:test_varWithPrivateSet type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=null - $this: ERROR_CALL 'Unresolved reference: R|/C|' type=.C - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test_varWithPrivateSet visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_varWithPrivateSet type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=null + RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_varWithPrivateSet type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null PROPERTY name:test_varWithProtectedSet visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test_varWithProtectedSet type:kotlin.Int visibility:public [final,static] + FIELD PROPERTY_BACKING_FIELD name:test_varWithProtectedSet type:IrErrorType visibility:public [final,static] EXPRESSION_BODY - CALL 'public final fun (): kotlin.Int declared in .C' type=kotlin.Int origin=null - $this: ERROR_CALL 'Unresolved reference: R|/C|' type=.C - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Int + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test_varWithProtectedSet visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_varWithProtectedSet type:kotlin.Int visibility:public [final,static] ' type=kotlin.Int origin=null - + RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test_varWithProtectedSet type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null diff --git a/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt b/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt index 406a4f70661..6e0bce645c5 100644 --- a/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt +++ b/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt @@ -36,7 +36,7 @@ FILE fqName: fileName:/reflectionLiterals.kt FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.reflect.KClass<.A> visibility:public [final,static] EXPRESSION_BODY GET_CLASS type=kotlin.reflect.KClass<.A> - ERROR_CALL 'Unresolved reference: R|/A|' type=.A + GET_OBJECT 'CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KClass<.A> correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -62,14 +62,14 @@ FILE fqName: fileName:/reflectionLiterals.kt RETURN type=kotlin.Nothing from='public final fun (): IrErrorType declared in ' GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType visibility:public [final,static] ' type=IrErrorType origin=null PROPERTY name:test4 visibility:public modality:FINAL [val] - FIELD PROPERTY_BACKING_FIELD name:test4 type:.A visibility:public [final,static] + FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Unit visibility:public [final,static] EXPRESSION_BODY - ERROR_CALL 'Unresolved reference: R|/A|' type=.A - FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:.A + GET_OBJECT 'CLASS CLASS name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Unit correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [val] BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun (): .A declared in ' - GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:.A visibility:public [final,static] ' type=.A origin=null + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Unit declared in ' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.Unit visibility:public [final,static] ' type=kotlin.Unit origin=null PROPERTY name:test5 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test5 type:IrErrorType visibility:public [final,static] EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/safeCalls.fir.txt b/compiler/testData/ir/irText/expressions/safeCalls.fir.txt index d102a83160c..07cb86bfe05 100644 --- a/compiler/testData/ir/irText/expressions/safeCalls.fir.txt +++ b/compiler/testData/ir/irText/expressions/safeCalls.fir.txt @@ -63,18 +63,20 @@ FILE fqName: fileName:/safeCalls.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test1 (x: kotlin.String?): kotlin.Int? declared in ' ERROR_CALL 'No getter found for R|kotlin/String.length|' type=kotlin.Int? - FUN name:test2 visibility:public modality:FINAL <> (x:kotlin.String?) returnType:IrErrorType + FUN name:test2 visibility:public modality:FINAL <> (x:kotlin.String?) returnType:kotlin.Int VALUE_PARAMETER name:x index:0 type:kotlin.String? BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test2 (x: kotlin.String?): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUN name:test3 visibility:public modality:FINAL <> (x:kotlin.String?, y:kotlin.Any?) returnType:IrErrorType + RETURN type=kotlin.Nothing from='public final fun test2 (x: kotlin.String?): kotlin.Int declared in ' + CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null + $this: GET_VAR 'x: kotlin.String? declared in .test2' type=kotlin.String? origin=null + FUN name:test3 visibility:public modality:FINAL <> (x:kotlin.String?, y:kotlin.Any?) returnType:kotlin.Boolean VALUE_PARAMETER name:x index:0 type:kotlin.String? VALUE_PARAMETER name:y index:1 type:kotlin.Any? BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test3 (x: kotlin.String?, y: kotlin.Any?): IrErrorType declared in ' - ERROR_CALL 'Unresolved reference: #' type=IrErrorType - GET_VAR 'y: kotlin.Any? declared in .test3' type=kotlin.Any? origin=null + RETURN type=kotlin.Nothing from='public final fun test3 (x: kotlin.String?, y: kotlin.Any?): kotlin.Boolean declared in ' + CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any' type=kotlin.Boolean origin=null + $this: GET_VAR 'x: kotlin.String? declared in .test3' type=kotlin.String? origin=null + other: GET_VAR 'y: kotlin.Any? declared in .test3' type=kotlin.Any? origin=null FUN name:test4 visibility:public modality:FINAL <> (x:.Ref?) returnType:kotlin.Unit VALUE_PARAMETER name:x index:0 type:.Ref? BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt b/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt index af648614de1..ee7ba356234 100644 --- a/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt +++ b/compiler/testData/ir/irText/expressions/thisReferenceBeforeClassDeclared.fir.txt @@ -18,8 +18,7 @@ FILE fqName: fileName:/thisReferenceBeforeClassDeclared.kt CONSTRUCTOR visibility:private <> () returnType:.WithCompanion [primary] BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'public constructor (a: .WithCompanion.Companion) [primary] declared in .WithCompanion' - a: CALL 'public final fun foo (): .WithCompanion.Companion declared in .WithCompanion.Companion' type=.WithCompanion.Companion origin=null - $this: ERROR_CALL 'Unresolved reference: this#' type=.WithCompanion + a: ERROR_CALL 'Unresolved reference: #' type=IrErrorType INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name: modality:FINAL visibility:local superTypes:[.WithCompanion]' CONSTRUCTOR_CALL 'private constructor () [primary] declared in .test.' type=.test. origin=null CLASS CLASS name:WithCompanion modality:OPEN visibility:public superTypes:[kotlin.Any] diff --git a/compiler/testData/ir/irText/expressions/values.fir.txt b/compiler/testData/ir/irText/expressions/values.fir.txt index 5f4492c65f3..e15ce13a291 100644 --- a/compiler/testData/ir/irText/expressions/values.fir.txt +++ b/compiler/testData/ir/irText/expressions/values.fir.txt @@ -113,20 +113,19 @@ FILE fqName: fileName:/values.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Any + FUN name:test1 visibility:public modality:FINAL <> () returnType:.Enum BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test1 (): kotlin.Any declared in ' - ERROR_CALL 'Unresolved reference: R|/Enum.A|' type=kotlin.Any + RETURN type=kotlin.Nothing from='public final fun test1 (): .Enum declared in ' + GET_OBJECT 'CLASS ENUM_ENTRY name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Enum FUN name:test2 visibility:public modality:FINAL <> () returnType:.A BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test2 (): .A declared in ' - ERROR_CALL 'Unresolved reference: R|/A|' type=.A + GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.Int declared in ' CALL 'public final fun (): kotlin.Int declared in ' type=kotlin.Int origin=null - FUN name:test4 visibility:public modality:FINAL <> () returnType:.Z + FUN name:test4 visibility:public modality:FINAL <> () returnType:.Z.Companion BLOCK_BODY - RETURN type=kotlin.Nothing from='public final fun test4 (): .Z declared in ' - ERROR_CALL 'Unresolved reference: R|/Z|' type=.Z - + RETURN type=kotlin.Nothing from='public final fun test4 (): .Z.Companion declared in ' + GET_OBJECT 'CLASS CLASS name:Z modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Z.Companion diff --git a/compiler/testData/ir/irText/expressions/when.fir.txt b/compiler/testData/ir/irText/expressions/when.fir.txt index 3ebe9196e02..2ce086275b1 100644 --- a/compiler/testData/ir/irText/expressions/when.fir.txt +++ b/compiler/testData/ir/irText/expressions/when.fir.txt @@ -33,7 +33,7 @@ FILE fqName: fileName:/when.kt BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp0_subject: kotlin.Any? [val] declared in .testWithSubject' type=kotlin.Any? origin=null - arg1: ERROR_CALL 'Unresolved reference: R|/A|' type=.A + arg1: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A then: CONST String type=kotlin.String value="A" BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String @@ -63,7 +63,7 @@ FILE fqName: fileName:/when.kt BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'x: kotlin.Any? declared in .test' type=kotlin.Any? origin=null - arg1: ERROR_CALL 'Unresolved reference: R|/A|' type=.A + arg1: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A then: CONST String type=kotlin.String value="A" BRANCH if: TYPE_OP type=kotlin.Boolean origin=INSTANCEOF typeOperand=kotlin.String diff --git a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt index dcde57a855b..cf6f947e18d 100644 --- a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt +++ b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.fir.txt @@ -45,7 +45,7 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt $this: VALUE_PARAMETER name: type:.IFoo BLOCK_BODY RETURN type=kotlin.Nothing from='public open fun (): .B declared in .IFoo' - ERROR_CALL 'Unresolved reference: R|/B|' type=.B + GET_OBJECT 'CLASS OBJECT name:B modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.B FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any @@ -84,7 +84,7 @@ FILE fqName: fileName:/multipleImplicitReceivers.kt VALUE_PARAMETER name:invokeImpl index:1 type:.IInvoke BLOCK_BODY CALL 'public final fun with (receiver: T of , block: kotlin.Function1, R of >): R of [inline] declared in kotlin' type=kotlin.Nothing origin=null - receiver: ERROR_CALL 'Unresolved reference: R|/A|' type=.A + receiver: GET_OBJECT 'CLASS OBJECT name:A modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.A block: BLOCK type=IrErrorType origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> (it:.A) returnType:kotlin.Nothing VALUE_PARAMETER name:it index:0 type:.A