FIR: Fix part of problems with smoke tests
This commit is contained in:
committed by
Simon Ogorodnik
parent
3e7e9269ab
commit
9b4fe2f991
@@ -28,6 +28,7 @@ fun ConeKotlinType.scope(useSiteSession: FirSession): FirScope? {
|
||||
val fir = this.lookupTag.toSymbol(useSiteSession)?.firUnsafe<FirTypeParameter>() ?: return null
|
||||
FirCompositeScope(fir.bounds.mapNotNullTo(mutableListOf()) { it.coneTypeUnsafe().scope(useSiteSession) })
|
||||
}
|
||||
is ConeFlexibleType -> lowerBound.scope(useSiteSession)
|
||||
else -> error("Failed type ${this}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.calls
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.renderWithType
|
||||
import org.jetbrains.kotlin.fir.resolve.FirSymbolProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
||||
import org.jetbrains.kotlin.fir.resolve.scope
|
||||
@@ -205,7 +206,8 @@ fun createSimpleConsumer(
|
||||
return if (explicitReceiver != null) {
|
||||
ExplicitReceiverTowerDataConsumer(session, name, token, object : ReceiverValueWithPossibleTypes {
|
||||
override val type: ConeKotlinType
|
||||
get() = explicitReceiverType!!.coneTypeUnsafe()
|
||||
get() = explicitReceiverType?.coneTypeUnsafe()
|
||||
?: throw AssertionError("No type calculated for ${explicitReceiver.renderWithType()}")
|
||||
}, callKind)
|
||||
} else {
|
||||
NoExplicitReceiverTowerDataConsumer(session, name, token, callKind)
|
||||
|
||||
+19
-2
@@ -23,6 +23,8 @@ import org.jetbrains.kotlin.fir.visitors.compose
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.*
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
|
||||
@@ -35,7 +37,10 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
||||
return (element.transformChildren(this, data) as E).compose()
|
||||
}
|
||||
|
||||
private var packageFqName = FqName.ROOT
|
||||
|
||||
override fun transformFile(file: FirFile, data: Any?): CompositeTransformResult<FirFile> {
|
||||
packageFqName = file.packageFqName
|
||||
return withScopeCleanup(scopes) {
|
||||
scopes += FirTopLevelDeclaredMemberScope(file, session)
|
||||
super.transformFile(file, data)
|
||||
@@ -283,7 +288,7 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
||||
}
|
||||
|
||||
override fun <T> transformConstExpression(constExpression: FirConstExpression<T>, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
if (data == null) return constExpression.compose()
|
||||
if (data == null) return super.transformConstExpression(constExpression, data)
|
||||
val expectedType = data as FirTypeRef
|
||||
|
||||
if (expectedType is FirImplicitTypeRef) {
|
||||
@@ -315,7 +320,11 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
||||
@Deprecated("It is temp", level = DeprecationLevel.WARNING, replaceWith = ReplaceWith("TODO(\"что-то нормальное\")"))
|
||||
val bindingContext = mutableMapOf<FirExpression, FirTypeRef>()
|
||||
|
||||
val FirExpression.resultType: FirTypeRef? get() = bindingContext[this]
|
||||
var FirExpression.resultType: FirTypeRef?
|
||||
get() = bindingContext[this]
|
||||
set(type) {
|
||||
if (type != null) bindingContext[this] = type
|
||||
}
|
||||
|
||||
|
||||
override fun transformNamedFunction(namedFunction: FirNamedFunction, data: Any?): CompositeTransformResult<FirDeclaration> {
|
||||
@@ -385,6 +394,14 @@ open class FirBodyResolveTransformer(val session: FirSession, val implicitTypeOn
|
||||
return transformVariable(property, data)
|
||||
}
|
||||
|
||||
override fun transformExpression(expression: FirExpression, data: Any?): CompositeTransformResult<FirStatement> {
|
||||
if (expression.resultType == null) {
|
||||
val type = FirErrorTypeRefImpl(session, expression.psi, "Type calculating for ${expression.render()} is not supported")
|
||||
expression.resultType = type
|
||||
}
|
||||
return super.transformExpression(expression, data)
|
||||
}
|
||||
|
||||
fun <D> FirElement.visitNoTransform(transformer: FirTransformer<D>, data: D) {
|
||||
val result = this.transform(transformer, data)
|
||||
require(result.single === this) { "become ${result.single}: `${result.single.render()}`, was ${this}: `${this.render()}`" }
|
||||
|
||||
Reference in New Issue
Block a user