[FIR] Resolve delegating constructor calls
This commit is contained in:
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.expressions.*
|
|||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub
|
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl
|
import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedQualifierImpl
|
||||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||||
|
import org.jetbrains.kotlin.fir.references.FirReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.impl.FirBackingFieldReferenceImpl
|
import org.jetbrains.kotlin.fir.references.impl.FirBackingFieldReferenceImpl
|
||||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||||
@@ -29,16 +30,20 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirExpressions
|
|||||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
|
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.phasedFir
|
import org.jetbrains.kotlin.fir.resolve.transformers.phasedFir
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||||
|
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope
|
import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope
|
||||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
import org.jetbrains.kotlin.fir.symbols.invoke
|
import org.jetbrains.kotlin.fir.symbols.invoke
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
|
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||||
|
import org.jetbrains.kotlin.fir.visitors.compose
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST
|
import org.jetbrains.kotlin.resolve.descriptorUtil.HIDES_MEMBERS_NAME_LIST
|
||||||
|
|
||||||
class FirCallResolver(
|
class FirCallResolver(
|
||||||
@@ -107,6 +112,7 @@ class FirCallResolver(
|
|||||||
|
|
||||||
val nameReference = createResolvedNamedReference(
|
val nameReference = createResolvedNamedReference(
|
||||||
functionCall.calleeReference,
|
functionCall.calleeReference,
|
||||||
|
name,
|
||||||
reducedCandidates,
|
reducedCandidates,
|
||||||
result.currentApplicability
|
result.currentApplicability
|
||||||
)
|
)
|
||||||
@@ -171,6 +177,7 @@ class FirCallResolver(
|
|||||||
}
|
}
|
||||||
val nameReference = createResolvedNamedReference(
|
val nameReference = createResolvedNamedReference(
|
||||||
callee,
|
callee,
|
||||||
|
callee.name,
|
||||||
reducedCandidates,
|
reducedCandidates,
|
||||||
result.currentApplicability
|
result.currentApplicability
|
||||||
)
|
)
|
||||||
@@ -264,6 +271,61 @@ class FirCallResolver(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun resolveDelegatingConstructorCall(
|
||||||
|
delegatedConstructorCall: FirDelegatedConstructorCall,
|
||||||
|
symbol: FirClassSymbol<*>,
|
||||||
|
typeArguments: List<FirTypeProjection>
|
||||||
|
): FirDelegatedConstructorCall? {
|
||||||
|
val scope = symbol.fir.buildUseSiteMemberScope(session, scopeSession) ?: return null
|
||||||
|
val callInfo = CallInfo(
|
||||||
|
CallKind.Function,
|
||||||
|
explicitReceiver = null,
|
||||||
|
delegatedConstructorCall.arguments,
|
||||||
|
isSafeCall = false,
|
||||||
|
typeArguments = typeArguments,
|
||||||
|
session,
|
||||||
|
file,
|
||||||
|
implicitReceiverStack,
|
||||||
|
container
|
||||||
|
) { it.resultType }
|
||||||
|
val candidateFactory = CandidateFactory(this, callInfo)
|
||||||
|
val candidates = mutableListOf<Candidate>()
|
||||||
|
|
||||||
|
val className = symbol.classId.shortClassName
|
||||||
|
scope.processFunctionsByName(className) {
|
||||||
|
if (it is FirConstructorSymbol) {
|
||||||
|
candidates += candidateFactory.createCandidate(
|
||||||
|
it,
|
||||||
|
dispatchReceiverValue = null,
|
||||||
|
implicitExtensionReceiverValue = null,
|
||||||
|
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER
|
||||||
|
)
|
||||||
|
}
|
||||||
|
ProcessorAction.NEXT
|
||||||
|
}
|
||||||
|
return callResolver.selectCandidateFromGivenCandidates(delegatedConstructorCall, className, candidates)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun <T> selectCandidateFromGivenCandidates(call: T, name: Name, candidates: Collection<Candidate>): T where T : FirResolvable, T : FirCall {
|
||||||
|
val result = CandidateCollector(this, resolutionStageRunner)
|
||||||
|
candidates.forEach { result.consumeCandidate(0, it) }
|
||||||
|
val bestCandidates = result.bestCandidates()
|
||||||
|
val reducedCandidates = if (result.currentApplicability < CandidateApplicability.SYNTHETIC_RESOLVED) {
|
||||||
|
bestCandidates.toSet()
|
||||||
|
} else {
|
||||||
|
conflictResolver.chooseMaximallySpecificCandidates(bestCandidates, discriminateGenerics = true)
|
||||||
|
}
|
||||||
|
|
||||||
|
val nameReference = createResolvedNamedReference(
|
||||||
|
call.calleeReference,
|
||||||
|
name,
|
||||||
|
reducedCandidates,
|
||||||
|
result.currentApplicability
|
||||||
|
)
|
||||||
|
|
||||||
|
return call.transformCalleeReference(StoreNameReference, nameReference) as T
|
||||||
|
}
|
||||||
|
|
||||||
private fun createCallableReferencesConsumerForLHS(
|
private fun createCallableReferencesConsumerForLHS(
|
||||||
callableReferenceAccess: FirCallableReferenceAccess,
|
callableReferenceAccess: FirCallableReferenceAccess,
|
||||||
lhs: DoubleColonLHS?,
|
lhs: DoubleColonLHS?,
|
||||||
@@ -341,12 +403,12 @@ class FirCallResolver(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createResolvedNamedReference(
|
private fun createResolvedNamedReference(
|
||||||
namedReference: FirNamedReference,
|
reference: FirReference,
|
||||||
|
name: Name,
|
||||||
candidates: Collection<Candidate>,
|
candidates: Collection<Candidate>,
|
||||||
applicability: CandidateApplicability
|
applicability: CandidateApplicability
|
||||||
): FirNamedReference {
|
): FirNamedReference {
|
||||||
val name = namedReference.name
|
val source = reference.source
|
||||||
val source = namedReference.source
|
|
||||||
return when {
|
return when {
|
||||||
candidates.isEmpty() -> FirErrorNamedReferenceImpl(
|
candidates.isEmpty() -> FirErrorNamedReferenceImpl(
|
||||||
source, FirUnresolvedNameError(name)
|
source, FirUnresolvedNameError(name)
|
||||||
|
|||||||
@@ -19,10 +19,12 @@ import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
|||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionWithSmartcastImpl
|
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionWithSmartcastImpl
|
||||||
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||||
|
import org.jetbrains.kotlin.fir.references.FirSuperReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirThisReference
|
import org.jetbrains.kotlin.fir.references.FirThisReference
|
||||||
import org.jetbrains.kotlin.fir.render
|
import org.jetbrains.kotlin.fir.render
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
|
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.FirUnresolvedNameError
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
|
import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
|
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.resultType
|
||||||
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
||||||
@@ -35,6 +37,7 @@ import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
|||||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||||
|
|
||||||
@@ -345,6 +348,9 @@ fun <T : FirResolvable> BodyResolveComponents.typeFromCallee(access: T): FirReso
|
|||||||
val implicitReceiver = implicitReceiverStack[labelName]
|
val implicitReceiver = implicitReceiverStack[labelName]
|
||||||
FirResolvedTypeRefImpl(null, implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName"))
|
FirResolvedTypeRefImpl(null, implicitReceiver?.type ?: ConeKotlinErrorType("Unresolved this@$labelName"))
|
||||||
}
|
}
|
||||||
|
is FirSuperReference -> {
|
||||||
|
newCallee.superTypeRef as? FirResolvedTypeRef ?: FirErrorTypeRefImpl(newCallee.source, FirUnresolvedNameError(Name.identifier("super")))
|
||||||
|
}
|
||||||
else -> error("Failed to extract type from: $newCallee")
|
else -> error("Failed to extract type from: $newCallee")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,6 +259,11 @@ class ConstraintSystemCompleter(val components: InferenceComponents) {
|
|||||||
this.returnExpressions().forEach { it.processAllContainingCallCandidates(processBlocks, processor) }
|
this.returnExpressions().forEach { it.processAllContainingCallCandidates(processBlocks, processor) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
is FirDelegatedConstructorCall -> {
|
||||||
|
processCandidateIfApplicable(processor)
|
||||||
|
this.arguments.forEach { it.processAllContainingCallCandidates(processBlocks, processor) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
@@ -186,6 +186,21 @@ class FirCallCompletionResultsWriterTransformer(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun transformDelegatedConstructorCall(
|
||||||
|
delegatedConstructorCall: FirDelegatedConstructorCall,
|
||||||
|
data: Nothing?
|
||||||
|
): CompositeTransformResult<FirStatement> {
|
||||||
|
val calleeReference = delegatedConstructorCall.calleeReference as? FirNamedReferenceWithCandidate ?: return delegatedConstructorCall.compose()
|
||||||
|
|
||||||
|
val subCandidate = calleeReference.candidate
|
||||||
|
val result = delegatedConstructorCall.transformArguments(this, data)
|
||||||
|
return result.transformCalleeReference(StoreCalleeReference, FirResolvedNamedReferenceImpl(
|
||||||
|
calleeReference.source,
|
||||||
|
calleeReference.name,
|
||||||
|
calleeReference.candidateSymbol
|
||||||
|
)).compose()
|
||||||
|
}
|
||||||
|
|
||||||
private fun computeTypeArguments(
|
private fun computeTypeArguments(
|
||||||
candidate: Candidate
|
candidate: Candidate
|
||||||
): List<ConeKotlinType> {
|
): List<ConeKotlinType> {
|
||||||
|
|||||||
+12
-2
@@ -11,8 +11,7 @@ import org.jetbrains.kotlin.fir.expressions.FirExpression
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWrappedArgumentExpression
|
import org.jetbrains.kotlin.fir.expressions.FirWrappedArgumentExpression
|
||||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
import org.jetbrains.kotlin.fir.references.*
|
||||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType
|
import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||||
@@ -75,6 +74,17 @@ internal object StoreNameReference : FirDefaultTransformer<FirNamedReference>()
|
|||||||
): CompositeTransformResult<FirNamedReference> {
|
): CompositeTransformResult<FirNamedReference> {
|
||||||
return data.compose()
|
return data.compose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun transformThisReference(thisReference: FirThisReference, data: FirNamedReference): CompositeTransformResult<FirReference> {
|
||||||
|
return data.compose()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun transformSuperReference(
|
||||||
|
superReference: FirSuperReference,
|
||||||
|
data: FirNamedReference
|
||||||
|
): CompositeTransformResult<FirReference> {
|
||||||
|
return data.compose()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object StoreCalleeReference : FirTransformer<FirResolvedNamedReference>() {
|
internal object StoreCalleeReference : FirTransformer<FirResolvedNamedReference>() {
|
||||||
|
|||||||
+7
@@ -147,6 +147,13 @@ open class FirBodyResolveTransformer(
|
|||||||
return expressionsTransformer.transformAnnotationCall(annotationCall, data)
|
return expressionsTransformer.transformAnnotationCall(annotationCall, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun transformDelegatedConstructorCall(
|
||||||
|
delegatedConstructorCall: FirDelegatedConstructorCall,
|
||||||
|
data: ResolutionMode
|
||||||
|
): CompositeTransformResult<FirStatement> {
|
||||||
|
return expressionsTransformer.transformDelegatedConstructorCall(delegatedConstructorCall, data)
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------- Declarations -------------------------------------
|
// ------------------------------------- Declarations -------------------------------------
|
||||||
|
|
||||||
override fun transformDeclaration(declaration: FirDeclaration, data: ResolutionMode): CompositeTransformResult<FirDeclaration> {
|
override fun transformDeclaration(declaration: FirDeclaration, data: ResolutionMode): CompositeTransformResult<FirDeclaration> {
|
||||||
|
|||||||
+57
-3
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.expressions.impl.FirVariableAssignmentImpl
|
|||||||
import org.jetbrains.kotlin.fir.references.FirDelegateFieldReference
|
import org.jetbrains.kotlin.fir.references.FirDelegateFieldReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirSuperReference
|
import org.jetbrains.kotlin.fir.references.FirSuperReference
|
||||||
|
import org.jetbrains.kotlin.fir.references.FirThisReference
|
||||||
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
import org.jetbrains.kotlin.fir.references.impl.FirErrorNamedReferenceImpl
|
||||||
import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference
|
import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference
|
||||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||||
@@ -30,18 +31,19 @@ import org.jetbrains.kotlin.fir.resolve.transformers.StoreReceiver
|
|||||||
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType
|
import org.jetbrains.kotlin.fir.scopes.impl.withReplacedConeType
|
||||||
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLookupTagWithFixedSymbol
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.invoke
|
import org.jetbrains.kotlin.fir.symbols.invoke
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
import org.jetbrains.kotlin.fir.types.impl.*
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
|
||||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||||
import org.jetbrains.kotlin.fir.visitors.compose
|
import org.jetbrains.kotlin.fir.visitors.compose
|
||||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
import org.jetbrains.kotlin.types.Variance
|
||||||
|
|
||||||
class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) {
|
class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) : FirPartialBodyResolveTransformer(transformer) {
|
||||||
private val callResolver: FirCallResolver get() = components.callResolver
|
private val callResolver: FirCallResolver get() = components.callResolver
|
||||||
@@ -426,6 +428,58 @@ class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransformer) :
|
|||||||
}.compose()
|
}.compose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun ConeKotlinTypeProjection.toFirTypeProjection(): FirTypeProjection = when (this) {
|
||||||
|
is ConeStarProjection -> FirStarProjectionImpl(null)
|
||||||
|
else -> {
|
||||||
|
val variance = when (kind) {
|
||||||
|
ProjectionKind.IN -> Variance.IN_VARIANCE
|
||||||
|
ProjectionKind.OUT -> Variance.OUT_VARIANCE
|
||||||
|
ProjectionKind.INVARIANT -> Variance.INVARIANT
|
||||||
|
ProjectionKind.STAR -> throw IllegalStateException()
|
||||||
|
}
|
||||||
|
val type = when (this) {
|
||||||
|
is ConeKotlinTypeProjectionIn -> type
|
||||||
|
is ConeKotlinTypeProjectionOut -> type
|
||||||
|
is ConeStarProjection -> throw IllegalStateException()
|
||||||
|
else -> this as ConeKotlinType
|
||||||
|
}
|
||||||
|
FirTypeProjectionWithVarianceImpl(
|
||||||
|
null, FirResolvedTypeRefImpl(null, type), variance
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun transformDelegatedConstructorCall(
|
||||||
|
delegatedConstructorCall: FirDelegatedConstructorCall,
|
||||||
|
data: ResolutionMode
|
||||||
|
): CompositeTransformResult<FirStatement> {
|
||||||
|
if (transformer.implicitTypeOnly) return delegatedConstructorCall.compose()
|
||||||
|
delegatedConstructorCall.transformChildren(transformer, ResolutionMode.ContextDependent)
|
||||||
|
val typeArguments: List<FirTypeProjection>
|
||||||
|
val symbol: FirClassSymbol<*> = when (val reference = delegatedConstructorCall.calleeReference) {
|
||||||
|
is FirThisReference -> {
|
||||||
|
typeArguments = emptyList()
|
||||||
|
reference.boundSymbol as? FirClassSymbol<*> ?: return delegatedConstructorCall.compose()
|
||||||
|
}
|
||||||
|
is FirSuperReference -> {
|
||||||
|
// TODO: unresolved supertype
|
||||||
|
val supertype = reference.superTypeRef.coneTypeSafe<ConeClassLikeType>() ?: return delegatedConstructorCall.compose()
|
||||||
|
typeArguments = supertype.typeArguments.takeIf { it.isNotEmpty() }?.map { it.toFirTypeProjection() } ?: emptyList()
|
||||||
|
val expandedSupertype = supertype.fullyExpandedType(session)
|
||||||
|
val lookupTag = expandedSupertype.lookupTag
|
||||||
|
if (lookupTag is ConeClassLookupTagWithFixedSymbol) {
|
||||||
|
lookupTag.symbol
|
||||||
|
} else {
|
||||||
|
// TODO: support locals
|
||||||
|
symbolProvider.getSymbolByLookupTag(lookupTag) ?: return delegatedConstructorCall.compose()
|
||||||
|
} as FirClassSymbol<*>
|
||||||
|
}
|
||||||
|
else -> return delegatedConstructorCall.compose()
|
||||||
|
}
|
||||||
|
val result = callResolver.resolveDelegatingConstructorCall(delegatedConstructorCall, symbol, typeArguments) ?: return delegatedConstructorCall.compose()
|
||||||
|
return callCompleter.completeCall(result, noExpectedType).compose()
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
internal fun <T> storeTypeFromCallee(access: T) where T : FirQualifiedAccess, T : FirExpression {
|
internal fun <T> storeTypeFromCallee(access: T) where T : FirQualifiedAccess, T : FirExpression {
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
fun <K> materialize(): K = <!UNRESOLVED_REFERENCE!>null!!<!>
|
||||||
|
|
||||||
|
open class A1(val x: String)
|
||||||
|
class B1 : A1(materialize())
|
||||||
|
|
||||||
|
open class A2(val x: Int)
|
||||||
|
class B2 : A2(1 + 1)
|
||||||
|
|
||||||
|
open class A3(x: String, y: String = "") {
|
||||||
|
constructor(x: String, b: Boolean = true) : this(x, x)
|
||||||
|
}
|
||||||
|
|
||||||
|
class B3_1 : <!AMBIGUITY!>A3<!>("")
|
||||||
|
class B3_2 : A3("", "asas")
|
||||||
|
class B3_3 : A3("", true)
|
||||||
|
class B3_4 : <!INAPPLICABLE_CANDIDATE!>A3<!>("", Unit)
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
FILE: delegatingConstructorCall.kt
|
||||||
|
public final fun <K> materialize(): R|K| {
|
||||||
|
^materialize when (lval <bangbang>: R|kotlin/Nothing?| = Null(null)) {
|
||||||
|
==($subj$, Null(null)) -> {
|
||||||
|
throw <Unresolved name: KotlinNullPointerException>#()
|
||||||
|
}
|
||||||
|
else -> {
|
||||||
|
R|<local>/<bangbang>|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public open class A1 : R|kotlin/Any| {
|
||||||
|
public constructor(x: R|kotlin/String|): R|A1| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final val x: R|kotlin/String| = R|<local>/x|
|
||||||
|
public get(): R|kotlin/String|
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class B1 : R|A1| {
|
||||||
|
public constructor(): R|B1| {
|
||||||
|
super<R|A1|>(R|/materialize|<R|kotlin/String|>())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public open class A2 : R|kotlin/Any| {
|
||||||
|
public constructor(x: R|kotlin/Int|): R|A2| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public final val x: R|kotlin/Int| = R|<local>/x|
|
||||||
|
public get(): R|kotlin/Int|
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class B2 : R|A2| {
|
||||||
|
public constructor(): R|B2| {
|
||||||
|
super<R|A2|>(Int(1).R|kotlin/Int.plus|(Int(1)))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public open class A3 : R|kotlin/Any| {
|
||||||
|
public constructor(x: R|kotlin/String|, y: R|kotlin/String| = String()): R|A3| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
public constructor(x: R|kotlin/String|, b: R|kotlin/Boolean| = Boolean(true)): R|A3| {
|
||||||
|
this<R|A3|>(R|<local>/x|, R|<local>/x|)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class B3_1 : R|A3| {
|
||||||
|
public constructor(): R|B3_1| {
|
||||||
|
super<R|A3|>(String())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class B3_2 : R|A3| {
|
||||||
|
public constructor(): R|B3_2| {
|
||||||
|
super<R|A3|>(String(), String(asas))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class B3_3 : R|A3| {
|
||||||
|
public constructor(): R|B3_3| {
|
||||||
|
super<R|A3|>(String(), Boolean(true))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final class B3_4 : R|A3| {
|
||||||
|
public constructor(): R|B3_4| {
|
||||||
|
super<R|A3|>(String(), Q|kotlin/Unit|)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
open class Inv<T, R>(x: T, r: R)
|
||||||
|
|
||||||
|
typealias Alias<X> = Inv<X, Inv<X, X>>
|
||||||
|
|
||||||
|
class InvImpl : Alias<String>("", Inv("", ""))
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
FILE: delegatingConstructorsAndTypeAliases.kt
|
||||||
|
public open class Inv<T, R> : R|kotlin/Any| {
|
||||||
|
public constructor<T, R>(x: R|T|, r: R|R|): R|Inv<T, R>| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public final typealias Alias<X> = R|Inv<X, Inv<X, X>>|
|
||||||
|
public final class InvImpl : R|Alias<kotlin/String>| {
|
||||||
|
public constructor(): R|InvImpl| {
|
||||||
|
super<R|Alias<kotlin/String>|>(String(), R|/Inv.Inv|<R|kotlin/String|, R|kotlin/String|>(String(), String()))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -56,7 +56,7 @@ open class Generic<T>(val x: T) {
|
|||||||
protected open fun foo(): T = x
|
protected open fun foo(): T = x
|
||||||
}
|
}
|
||||||
|
|
||||||
class DerivedGeneric : Generic<Int>() {
|
class DerivedGeneric : Generic<Int>(1) {
|
||||||
override fun foo(): Int {
|
override fun foo(): Int {
|
||||||
return super.foo()
|
return super.foo()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ FILE: protectedVisibility.kt
|
|||||||
}
|
}
|
||||||
public final class DerivedGeneric : R|Generic<kotlin/Int>| {
|
public final class DerivedGeneric : R|Generic<kotlin/Int>| {
|
||||||
public constructor(): R|DerivedGeneric| {
|
public constructor(): R|DerivedGeneric| {
|
||||||
super<R|Generic<kotlin/Int>|>()
|
super<R|Generic<kotlin/Int>|>(Int(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
public final override fun foo(): R|kotlin/Int| {
|
public final override fun foo(): R|kotlin/Int| {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// FILE: K1.kt
|
// FILE: K1.kt
|
||||||
class K2: J1() {
|
class K2: <!AMBIGUITY!>J1<!>() {
|
||||||
class Q : Nested()
|
class Q : Nested()
|
||||||
fun bar() {
|
fun bar() {
|
||||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||||
|
|||||||
+10
@@ -53,6 +53,16 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
|||||||
runTest("compiler/fir/resolve/testData/resolve/delegatedSuperType.kt");
|
runTest("compiler/fir/resolve/testData/resolve/delegatedSuperType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("delegatingConstructorCall.kt")
|
||||||
|
public void testDelegatingConstructorCall() throws Exception {
|
||||||
|
runTest("compiler/fir/resolve/testData/resolve/delegatingConstructorCall.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("delegatingConstructorsAndTypeAliases.kt")
|
||||||
|
public void testDelegatingConstructorsAndTypeAliases() throws Exception {
|
||||||
|
runTest("compiler/fir/resolve/testData/resolve/delegatingConstructorsAndTypeAliases.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("derivedClass.kt")
|
@TestMetadata("derivedClass.kt")
|
||||||
public void testDerivedClass() throws Exception {
|
public void testDerivedClass() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/derivedClass.kt");
|
runTest("compiler/fir/resolve/testData/resolve/derivedClass.kt");
|
||||||
|
|||||||
@@ -238,11 +238,7 @@ class FirResolveBench(val withProgress: Boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef) {
|
override fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef) {
|
||||||
if (implicitTypeRef is FirResolvedTypeRef) {
|
visitTypeRef(implicitTypeRef)
|
||||||
visitResolvedTypeRef(implicitTypeRef)
|
|
||||||
} else {
|
|
||||||
visitTypeRef(implicitTypeRef)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) {
|
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) {
|
||||||
|
|||||||
+4
-4
@@ -16,18 +16,18 @@ import org.jetbrains.kotlin.fir.visitors.*
|
|||||||
* DO NOT MODIFY IT MANUALLY
|
* DO NOT MODIFY IT MANUALLY
|
||||||
*/
|
*/
|
||||||
|
|
||||||
abstract class FirDelegatedConstructorCall : FirPureAbstractElement(), FirCall {
|
abstract class FirDelegatedConstructorCall : FirPureAbstractElement(), FirResolvable, FirCall {
|
||||||
abstract override val source: FirSourceElement?
|
abstract override val source: FirSourceElement?
|
||||||
|
abstract override val calleeReference: FirReference
|
||||||
abstract override val annotations: List<FirAnnotationCall>
|
abstract override val annotations: List<FirAnnotationCall>
|
||||||
abstract override val arguments: List<FirExpression>
|
abstract override val arguments: List<FirExpression>
|
||||||
abstract val constructedTypeRef: FirTypeRef
|
abstract val constructedTypeRef: FirTypeRef
|
||||||
abstract val isThis: Boolean
|
abstract val isThis: Boolean
|
||||||
abstract val isSuper: Boolean
|
abstract val isSuper: Boolean
|
||||||
abstract val calleeReference: FirReference
|
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitDelegatedConstructorCall(this, data)
|
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitDelegatedConstructorCall(this, data)
|
||||||
|
|
||||||
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCall
|
abstract override fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCall
|
||||||
|
|
||||||
abstract fun <D> transformCalleeReference(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCall
|
abstract override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCall
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-8
@@ -26,28 +26,23 @@ class FirDelegatedConstructorCallImpl(
|
|||||||
override var constructedTypeRef: FirTypeRef,
|
override var constructedTypeRef: FirTypeRef,
|
||||||
override val isThis: Boolean
|
override val isThis: Boolean
|
||||||
) : FirDelegatedConstructorCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement {
|
) : FirDelegatedConstructorCall(), FirCallWithArgumentList, FirAbstractAnnotatedElement {
|
||||||
|
override var calleeReference: FirReference = if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, constructedTypeRef)
|
||||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||||
override val arguments: MutableList<FirExpression> = mutableListOf()
|
override val arguments: MutableList<FirExpression> = mutableListOf()
|
||||||
override val isSuper: Boolean get() = !isThis
|
override val isSuper: Boolean get() = !isThis
|
||||||
override var calleeReference: FirReference = if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, constructedTypeRef)
|
|
||||||
|
|
||||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||||
|
calleeReference.accept(visitor, data)
|
||||||
annotations.forEach { it.accept(visitor, data) }
|
annotations.forEach { it.accept(visitor, data) }
|
||||||
arguments.forEach { it.accept(visitor, data) }
|
arguments.forEach { it.accept(visitor, data) }
|
||||||
constructedTypeRef.accept(visitor, data)
|
constructedTypeRef.accept(visitor, data)
|
||||||
calleeReference.accept(visitor, data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCallImpl {
|
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCallImpl {
|
||||||
|
transformCalleeReference(transformer, data)
|
||||||
annotations.transformInplace(transformer, data)
|
annotations.transformInplace(transformer, data)
|
||||||
transformArguments(transformer, data)
|
transformArguments(transformer, data)
|
||||||
constructedTypeRef = constructedTypeRef.transformSingle(transformer, data)
|
constructedTypeRef = constructedTypeRef.transformSingle(transformer, data)
|
||||||
transformCalleeReference(transformer, data)
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCallImpl {
|
|
||||||
arguments.transformInplace(transformer, data)
|
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,4 +50,9 @@ class FirDelegatedConstructorCallImpl(
|
|||||||
calleeReference = calleeReference.transformSingle(transformer, data)
|
calleeReference = calleeReference.transformSingle(transformer, data)
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun <D> transformArguments(transformer: FirTransformer<D>, data: D): FirDelegatedConstructorCallImpl {
|
||||||
|
arguments.transformInplace(transformer, data)
|
||||||
|
return this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ import org.jetbrains.kotlin.fir.expressions.FirOperatorCall
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall
|
import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWhenBranch
|
import org.jetbrains.kotlin.fir.expressions.FirWhenBranch
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessWithoutCallee
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessWithoutCallee
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
|
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
|
||||||
@@ -81,6 +80,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorExpression
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirComponentCall
|
import org.jetbrains.kotlin.fir.expressions.FirComponentCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression
|
import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression
|
||||||
@@ -388,10 +388,6 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
|||||||
return transformElement(whenBranch, data)
|
return transformElement(whenBranch, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun transformDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: D): CompositeTransformResult<FirStatement> {
|
|
||||||
return transformElement(delegatedConstructorCall, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun transformQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee, data: D): CompositeTransformResult<FirStatement> {
|
open fun transformQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee, data: D): CompositeTransformResult<FirStatement> {
|
||||||
return transformElement(qualifiedAccessWithoutCallee, data)
|
return transformElement(qualifiedAccessWithoutCallee, data)
|
||||||
}
|
}
|
||||||
@@ -428,6 +424,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
|||||||
return transformElement(functionCall, data)
|
return transformElement(functionCall, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun transformDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: D): CompositeTransformResult<FirStatement> {
|
||||||
|
return transformElement(delegatedConstructorCall, data)
|
||||||
|
}
|
||||||
|
|
||||||
open fun transformComponentCall(componentCall: FirComponentCall, data: D): CompositeTransformResult<FirStatement> {
|
open fun transformComponentCall(componentCall: FirComponentCall, data: D): CompositeTransformResult<FirStatement> {
|
||||||
return transformElement(componentCall, data)
|
return transformElement(componentCall, data)
|
||||||
}
|
}
|
||||||
@@ -836,10 +836,6 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
|||||||
return transformWhenBranch(whenBranch, data)
|
return transformWhenBranch(whenBranch, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: D): CompositeTransformResult<FirStatement> {
|
|
||||||
return transformDelegatedConstructorCall(delegatedConstructorCall, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
final override fun visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee, data: D): CompositeTransformResult<FirStatement> {
|
final override fun visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee, data: D): CompositeTransformResult<FirStatement> {
|
||||||
return transformQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee, data)
|
return transformQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee, data)
|
||||||
}
|
}
|
||||||
@@ -876,6 +872,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
|||||||
return transformFunctionCall(functionCall, data)
|
return transformFunctionCall(functionCall, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: D): CompositeTransformResult<FirStatement> {
|
||||||
|
return transformDelegatedConstructorCall(delegatedConstructorCall, data)
|
||||||
|
}
|
||||||
|
|
||||||
final override fun visitComponentCall(componentCall: FirComponentCall, data: D): CompositeTransformResult<FirStatement> {
|
final override fun visitComponentCall(componentCall: FirComponentCall, data: D): CompositeTransformResult<FirStatement> {
|
||||||
return transformComponentCall(componentCall, data)
|
return transformComponentCall(componentCall, data)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ import org.jetbrains.kotlin.fir.expressions.FirOperatorCall
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall
|
import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWhenBranch
|
import org.jetbrains.kotlin.fir.expressions.FirWhenBranch
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessWithoutCallee
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessWithoutCallee
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
|
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
|
||||||
@@ -81,6 +80,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorExpression
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirComponentCall
|
import org.jetbrains.kotlin.fir.expressions.FirComponentCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression
|
import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression
|
||||||
@@ -256,8 +256,6 @@ abstract class FirVisitor<out R, in D> {
|
|||||||
|
|
||||||
open fun visitWhenBranch(whenBranch: FirWhenBranch, data: D): R = visitElement(whenBranch, data)
|
open fun visitWhenBranch(whenBranch: FirWhenBranch, data: D): R = visitElement(whenBranch, data)
|
||||||
|
|
||||||
open fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: D): R = visitElement(delegatedConstructorCall, data)
|
|
||||||
|
|
||||||
open fun visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee, data: D): R = visitElement(qualifiedAccessWithoutCallee, data)
|
open fun visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee, data: D): R = visitElement(qualifiedAccessWithoutCallee, data)
|
||||||
|
|
||||||
open fun visitQualifiedAccess(qualifiedAccess: FirQualifiedAccess, data: D): R = visitElement(qualifiedAccess, data)
|
open fun visitQualifiedAccess(qualifiedAccess: FirQualifiedAccess, data: D): R = visitElement(qualifiedAccess, data)
|
||||||
@@ -276,6 +274,8 @@ abstract class FirVisitor<out R, in D> {
|
|||||||
|
|
||||||
open fun visitFunctionCall(functionCall: FirFunctionCall, data: D): R = visitElement(functionCall, data)
|
open fun visitFunctionCall(functionCall: FirFunctionCall, data: D): R = visitElement(functionCall, data)
|
||||||
|
|
||||||
|
open fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: D): R = visitElement(delegatedConstructorCall, data)
|
||||||
|
|
||||||
open fun visitComponentCall(componentCall: FirComponentCall, data: D): R = visitElement(componentCall, data)
|
open fun visitComponentCall(componentCall: FirComponentCall, data: D): R = visitElement(componentCall, data)
|
||||||
|
|
||||||
open fun visitCallableReferenceAccess(callableReferenceAccess: FirCallableReferenceAccess, data: D): R = visitElement(callableReferenceAccess, data)
|
open fun visitCallableReferenceAccess(callableReferenceAccess: FirCallableReferenceAccess, data: D): R = visitElement(callableReferenceAccess, data)
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ import org.jetbrains.kotlin.fir.expressions.FirOperatorCall
|
|||||||
import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall
|
import org.jetbrains.kotlin.fir.expressions.FirTypeOperatorCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
import org.jetbrains.kotlin.fir.expressions.FirWhenExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWhenBranch
|
import org.jetbrains.kotlin.fir.expressions.FirWhenBranch
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessWithoutCallee
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessWithoutCallee
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
|
import org.jetbrains.kotlin.fir.expressions.FirArrayOfCall
|
||||||
@@ -81,6 +80,7 @@ import org.jetbrains.kotlin.fir.expressions.FirErrorExpression
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
import org.jetbrains.kotlin.fir.declarations.FirErrorFunction
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||||
|
import org.jetbrains.kotlin.fir.expressions.FirDelegatedConstructorCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirComponentCall
|
import org.jetbrains.kotlin.fir.expressions.FirComponentCall
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression
|
import org.jetbrains.kotlin.fir.expressions.FirThisReceiverExpression
|
||||||
@@ -386,10 +386,6 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
|||||||
visitElement(whenBranch)
|
visitElement(whenBranch)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall) {
|
|
||||||
visitElement(delegatedConstructorCall)
|
|
||||||
}
|
|
||||||
|
|
||||||
open fun visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee) {
|
open fun visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee) {
|
||||||
visitElement(qualifiedAccessWithoutCallee)
|
visitElement(qualifiedAccessWithoutCallee)
|
||||||
}
|
}
|
||||||
@@ -426,6 +422,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
|||||||
visitElement(functionCall)
|
visitElement(functionCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall) {
|
||||||
|
visitElement(delegatedConstructorCall)
|
||||||
|
}
|
||||||
|
|
||||||
open fun visitComponentCall(componentCall: FirComponentCall) {
|
open fun visitComponentCall(componentCall: FirComponentCall) {
|
||||||
visitElement(componentCall)
|
visitElement(componentCall)
|
||||||
}
|
}
|
||||||
@@ -834,10 +834,6 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
|||||||
visitWhenBranch(whenBranch)
|
visitWhenBranch(whenBranch)
|
||||||
}
|
}
|
||||||
|
|
||||||
final override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: Nothing?) {
|
|
||||||
visitDelegatedConstructorCall(delegatedConstructorCall)
|
|
||||||
}
|
|
||||||
|
|
||||||
final override fun visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee, data: Nothing?) {
|
final override fun visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee: FirQualifiedAccessWithoutCallee, data: Nothing?) {
|
||||||
visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee)
|
visitQualifiedAccessWithoutCallee(qualifiedAccessWithoutCallee)
|
||||||
}
|
}
|
||||||
@@ -874,6 +870,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
|||||||
visitFunctionCall(functionCall)
|
visitFunctionCall(functionCall)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: Nothing?) {
|
||||||
|
visitDelegatedConstructorCall(delegatedConstructorCall)
|
||||||
|
}
|
||||||
|
|
||||||
final override fun visitComponentCall(componentCall: FirComponentCall, data: Nothing?) {
|
final override fun visitComponentCall(componentCall: FirComponentCall, data: Nothing?) {
|
||||||
visitComponentCall(componentCall)
|
visitComponentCall(componentCall)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -84,7 +84,6 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
|||||||
val typeOperatorCall = element("TypeOperatorCall", Expression, expression, call)
|
val typeOperatorCall = element("TypeOperatorCall", Expression, expression, call)
|
||||||
val whenExpression = element("WhenExpression", Expression, expression, resolvable)
|
val whenExpression = element("WhenExpression", Expression, expression, resolvable)
|
||||||
val whenBranch = element("WhenBranch", Expression)
|
val whenBranch = element("WhenBranch", Expression)
|
||||||
val delegatedConstructorCall = element("DelegatedConstructorCall", Expression, call)
|
|
||||||
val qualifiedAccessWithoutCallee = element("QualifiedAccessWithoutCallee", Expression, statement)
|
val qualifiedAccessWithoutCallee = element("QualifiedAccessWithoutCallee", Expression, statement)
|
||||||
val qualifiedAccess = element("QualifiedAccess", Expression, qualifiedAccessWithoutCallee, resolvable)
|
val qualifiedAccess = element("QualifiedAccess", Expression, qualifiedAccessWithoutCallee, resolvable)
|
||||||
|
|
||||||
@@ -95,6 +94,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
|||||||
val errorFunction = element("ErrorFunction", Declaration, function, diagnosticHolder)
|
val errorFunction = element("ErrorFunction", Declaration, function, diagnosticHolder)
|
||||||
val qualifiedAccessExpression = element("QualifiedAccessExpression", Expression, expression, qualifiedAccess)
|
val qualifiedAccessExpression = element("QualifiedAccessExpression", Expression, expression, qualifiedAccess)
|
||||||
val functionCall = element("FunctionCall", Expression, qualifiedAccessExpression, call)
|
val functionCall = element("FunctionCall", Expression, qualifiedAccessExpression, call)
|
||||||
|
val delegatedConstructorCall = element("DelegatedConstructorCall", Expression, resolvable, call)
|
||||||
val componentCall = element("ComponentCall", Expression, functionCall)
|
val componentCall = element("ComponentCall", Expression, functionCall)
|
||||||
val callableReferenceAccess = element("CallableReferenceAccess", Expression, qualifiedAccessExpression)
|
val callableReferenceAccess = element("CallableReferenceAccess", Expression, qualifiedAccessExpression)
|
||||||
val thisReceiverExpression = element("ThisReceiverExpression", Expression, qualifiedAccessExpression)
|
val thisReceiverExpression = element("ThisReceiverExpression", Expression, qualifiedAccessExpression)
|
||||||
|
|||||||
+10
@@ -575,6 +575,16 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
|||||||
}
|
}
|
||||||
|
|
||||||
noImpl(userTypeRef)
|
noImpl(userTypeRef)
|
||||||
|
|
||||||
|
// impl(delegatedConstructorCall) {
|
||||||
|
// defaultTrue("safe", withGetter = true)
|
||||||
|
// listOf("dispatchReceiver", "extensionReceiver", "explicitReceiver").forEach {
|
||||||
|
// default(it) {
|
||||||
|
// value = "FirNoReceiverExpression"
|
||||||
|
// withGetter = true
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findImplementationsWithAnnotations(implementationPredicate: (Implementation) -> Boolean): Collection<Implementation> {
|
private fun findImplementationsWithAnnotations(implementationPredicate: (Implementation) -> Boolean): Collection<Implementation> {
|
||||||
|
|||||||
-1
@@ -324,7 +324,6 @@ object NodeConfigurator : AbstractFieldConfigurator() {
|
|||||||
delegatedConstructorCall.configure {
|
delegatedConstructorCall.configure {
|
||||||
+field("constructedTypeRef", typeRef)
|
+field("constructedTypeRef", typeRef)
|
||||||
generateBooleanFields("this", "super")
|
generateBooleanFields("this", "super")
|
||||||
+calleeReference.withTransform()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
valueParameter.configure {
|
valueParameter.configure {
|
||||||
|
|||||||
Vendored
+3
-3
@@ -35,10 +35,10 @@ FILE fqName:<root> fileName:/objectReferenceInClosureInSuperConstructorCall.kt
|
|||||||
CONSTRUCTOR visibility:private <> () returnType:<root>.Test [primary]
|
CONSTRUCTOR visibility:private <> () returnType:<root>.Test [primary]
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (lambda: kotlin.Function0<kotlin.Any>) [primary] declared in <root>.Base'
|
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> (lambda: kotlin.Function0<kotlin.Any>) [primary] declared in <root>.Base'
|
||||||
lambda: FUN_EXPR type=IrErrorType origin=LAMBDA
|
lambda: FUN_EXPR type=kotlin.Function0<kotlin.Any> origin=LAMBDA
|
||||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:IrErrorType
|
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Any
|
||||||
BLOCK_BODY
|
BLOCK_BODY
|
||||||
ERROR_CALL 'Unresolved reference: Test#' type=IrErrorType
|
GET_OBJECT 'CLASS OBJECT name:Test modality:FINAL visibility:public superTypes:[<root>.Base]' type=<root>.Test
|
||||||
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Test modality:FINAL visibility:public superTypes:[<root>.Base]'
|
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS OBJECT name:Test modality:FINAL visibility:public superTypes:[<root>.Base]'
|
||||||
PROPERTY FAKE_OVERRIDE name:lambda visibility:public modality:FINAL [fake_override,val]
|
PROPERTY FAKE_OVERRIDE name:lambda visibility:public modality:FINAL [fake_override,val]
|
||||||
FUN FAKE_OVERRIDE name:<get-lambda> visibility:public modality:FINAL <> ($this:<root>.Test) returnType:kotlin.Function0<kotlin.Any> [fake_override]
|
FUN FAKE_OVERRIDE name:<get-lambda> visibility:public modality:FINAL <> ($this:<root>.Test) returnType:kotlin.Function0<kotlin.Any> [fake_override]
|
||||||
|
|||||||
Reference in New Issue
Block a user