Hi. I trying to get parameter's default value of ...
# compiler
Hi. I trying to get parameter's default value of a function through a
, but when the function comes from a class file, it doesn't work.
Copy code
fun parseKtCallExpr(callExpr: KtCallExpression, bindingContext:BindingContext){
    val resolvedCall = callExpr.getResolvedCall(bindingContext)
    val defaultParam : ValueParameterDescriptor = resolvedCall.valueArguments[0].key // Suppose it has defaultvalue
    defaultParam.findPsi() as? KtParameter)?.defaultValue  // it works only when function come from code.
Is there any way to get it? Thanks.
maybe try
The default value is an expression which can have arbitrarily complex code with side effects etc. It’s generated into the bytecode directly, and there’s no way to get it other than to load and parse that bytecode, which is likely very complicated for your use case
ok, thank you for the feedback