FIR LC: use optimal type mapping mode for value parameter
This commit is contained in:
committed by
Ilya Kirillov
parent
6d150fb7a5
commit
d3c34fa200
+11
-5
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.light.classes.symbol
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtValueParameterSymbol
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeMappingMode
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
|
||||
internal abstract class FirLightParameterBaseForSymbol(
|
||||
@@ -39,17 +40,22 @@ internal abstract class FirLightParameterBaseForSymbol(
|
||||
parameterSymbol.annotatedType.type
|
||||
)
|
||||
}
|
||||
}
|
||||
else NullabilityType.Unknown
|
||||
} else NullabilityType.Unknown
|
||||
}
|
||||
|
||||
override fun getNameIdentifier(): PsiIdentifier = _identifier
|
||||
|
||||
private val _type by lazyPub {
|
||||
val convertedType = analyzeWithSymbolAsContext(parameterSymbol) {
|
||||
parameterSymbol.annotatedType.type.asPsiType(this@FirLightParameterBaseForSymbol)
|
||||
?: this@FirLightParameterBaseForSymbol.nonExistentType()
|
||||
}
|
||||
val ktType = parameterSymbol.annotatedType.type
|
||||
val typeMappingMode = when {
|
||||
ktType.isSuspendFunctionType -> TypeMappingMode.DEFAULT
|
||||
// TODO: extract type mapping mode from annotation?
|
||||
// TODO: methods with declaration site wildcards?
|
||||
else -> ktType.getOptimalModeForValueParameter()
|
||||
}
|
||||
ktType.asPsiType(this@FirLightParameterBaseForSymbol, typeMappingMode)
|
||||
} ?: nonExistentType()
|
||||
if (parameterSymbol.isVararg) {
|
||||
PsiEllipsisType(convertedType, convertedType.annotationProvider)
|
||||
} else convertedType
|
||||
|
||||
+1
-2
@@ -72,8 +72,7 @@ internal class FirLightParameterForReceiver private constructor(
|
||||
private val _type: PsiType by lazyPub {
|
||||
analyzeWithSymbolAsContext(context) {
|
||||
receiverTypeAndAnnotations.type.asPsiType(this@FirLightParameterForReceiver)
|
||||
?: this@FirLightParameterForReceiver.nonExistentType()
|
||||
}
|
||||
} ?: nonExistentType()
|
||||
}
|
||||
|
||||
override fun getType(): PsiType = _type
|
||||
|
||||
Reference in New Issue
Block a user