[FIR] Pass container when creating FunctionType

so that it can be resolved when type annotations are demanded.
This commit is contained in:
Ting-Yuan Huang
2023-02-02 22:01:32 -08:00
committed by teamcity
parent 8f34b6599a
commit 42b08d411b
11 changed files with 136 additions and 3 deletions
@@ -71,4 +71,16 @@ public interface KtFunctionalTypeRenderer {
}
}
public object AS_FULLY_EXPANDED_CLASS_TYPE_FOR_REFELCTION_TYPES : KtFunctionalTypeRenderer {
context(KtAnalysisSession, KtTypeRenderer)
override fun renderType(type: KtFunctionalType, printer: PrettyPrinter) {
val fullyExpandedType = type.fullyExpandedType
if (fullyExpandedType is KtFunctionalType) {
val renderer = if (fullyExpandedType.isReflectType) AS_CLASS_TYPE else AS_FUNCTIONAL_TYPE
renderer.renderType(fullyExpandedType, printer)
} else {
renderType(fullyExpandedType, printer)
}
}
}
}
@@ -0,0 +1 @@
fun foo(): @Anno3 @Anno2 @Anno1 (() -> kotlin.Unit)
@@ -0,0 +1,41 @@
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: /foo
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: foo
origin: SOURCE
receiverParameter: null
returnType: KtFunctionalType:
annotationsList: [
Anno3()
psi: KtAnnotationEntry
Anno2()
psi: KtAnnotationEntry
Anno1()
psi: KtAnnotationEntry
]
ownTypeArguments: [
KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
]
type: @R|Anno3|() @R|Anno2|() @R|Anno1|() @R|Anno3|() SecondTypeAlias
symbolKind: TOP_LEVEL
typeParameters: []
valueParameters: []
visibility: Public
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null
@@ -0,0 +1,13 @@
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE_K1
// PRETTY_RENDERER_OPTION: FULLY_EXPANDED_TYPES
@Target(AnnotationTarget.TYPE)
annotation class Anno1
@Target(AnnotationTarget.TYPE)
annotation class Anno2
@Target(AnnotationTarget.TYPE)
annotation class Anno3
typealias FirstTypeAlias = @Anno1 (() -> Unit)
typealias SecondTypeAlias = @Anno2 FirstTypeAlias
fun f<caret>oo(): @Anno3 SecondTypeAlias = {}
@@ -0,0 +1 @@
fun foo(): @Anno1 @Anno2 @Anno3 (() -> kotlin.Unit)
@@ -0,0 +1,41 @@
KtFunctionSymbol:
annotationsList: []
callableIdIfNonLocal: /foo
contextReceivers: []
contractEffects: []
hasStableParameterNames: true
isBuiltinFunctionInvoke: false
isExtension: false
isExternal: false
isInfix: false
isInline: false
isOperator: false
isOverride: false
isStatic: false
isSuspend: false
modality: FINAL
name: foo
origin: SOURCE
receiverParameter: null
returnType: KtFunctionalType:
annotationsList: [
Anno1()
psi: KtAnnotationEntry
Anno2()
psi: KtAnnotationEntry
Anno3()
psi: KtAnnotationEntry
]
ownTypeArguments: [
KtUsualClassType:
annotationsList: []
ownTypeArguments: []
type: kotlin/Unit
]
type: @R|Anno1|() @R|Anno2|() @R|Anno3|() kotlin/Function0<kotlin/Unit>
symbolKind: TOP_LEVEL
typeParameters: []
valueParameters: []
visibility: Public
getContainingModule: KtSourceModule "Sources of main"
deprecationStatus: null