@@ -20,10 +20,13 @@ package com.google.devtools.ksp.symbol.impl.kotlin
20
20
21
21
import com.google.devtools.ksp.symbol.*
22
22
import com.google.devtools.ksp.symbol.impl.KSObjectCache
23
+ import com.google.devtools.ksp.symbol.impl.findParentDeclaration
24
+ import com.google.devtools.ksp.symbol.impl.synthetic.KSTypeReferenceSyntheticImpl
23
25
import com.google.devtools.ksp.symbol.impl.toLocation
24
26
import org.jetbrains.kotlin.lexer.KtTokens.CROSSINLINE_KEYWORD
25
27
import org.jetbrains.kotlin.lexer.KtTokens.NOINLINE_KEYWORD
26
28
import org.jetbrains.kotlin.psi.KtParameter
29
+ import org.jetbrains.kotlin.psi.KtProperty
27
30
28
31
class KSValueParameterImpl private constructor(val ktParameter : KtParameter ) : KSValueParameter {
29
32
companion object : KSObjectCache <KtParameter , KSValueParameterImpl >() {
@@ -58,8 +61,8 @@ class KSValueParameterImpl private constructor(val ktParameter: KtParameter) : K
58
61
}
59
62
}
60
63
61
- override val type: KSTypeReference ? by lazy {
62
- ktParameter.typeReference?.let { KSTypeReferenceImpl .getCached(it) }
64
+ override val type: KSTypeReference by lazy {
65
+ ktParameter.typeReference?.let { KSTypeReferenceImpl .getCached(it) } ? : findPropertyForAccessor()?.type ? : KSTypeReferenceSyntheticImpl .getCached( KSErrorType )
63
66
}
64
67
65
68
override val hasDefault: Boolean = ktParameter.hasDefaultValue()
@@ -71,4 +74,8 @@ class KSValueParameterImpl private constructor(val ktParameter: KtParameter) : K
71
74
override fun toString (): String {
72
75
return name?.asString() ? : " _"
73
76
}
77
+
78
+ private fun findPropertyForAccessor (): KSPropertyDeclaration ? {
79
+ return (ktParameter.parent?.parent?.parent as ? KtProperty )?.let { KSPropertyDeclarationImpl .getCached(it) }
80
+ }
74
81
}
0 commit comments