raulraja
09/03/2019, 6:20 PMKtTypeReference
for kotlin.Unit
and it could be any other fqName for a type and I wish to resolve the type for.
This is happening inside a function declared inside a class where I’m using the class member declaration scope to resolve the types.
Currently I’m using:
val returnType = typeResolver.resolveType(containingDeclaration.scopeForMemberDeclarationResolution, function.typeReference!!, trace, true)
but this returns:
[ERROR : kotlin.Unit]
Is there a better way to go from KtTypeReference -> KotlinType
than using the type resolver? Is there a different type of scope I should be constructing to resolve the type?
Any help is appreciated, thanks.shikasd
09/03/2019, 10:30 PMBindingContext
for TYPE
, but it probably not populated before resolution.
I am usually resolving the whole function using ResolveSession.resolveDescriptor
and using it returnType
. Not sure about efficiency of this, but it works most of the time 🙂raulraja
09/03/2019, 10:33 PMBindingContext.TYPE
is not populated yet so I need to resolve it, but I will try with the resolve session and report backraulraja
09/03/2019, 10:43 PMResolveSession
I get:
org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException: Descriptor wasn't found for declaration CLASS
at org.jetbrains.kotlin.idea.project.IdeaAbsentDescriptorHandler.diagnoseDescriptorNotFound(IdeaLocalDescriptorResolver.kt:44)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.findClassDescriptor(LazyDeclarationResolver.kt:88)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.getClassDescriptor(LazyDeclarationResolver.kt:62)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.getMemberScopeDeclaredIn$frontend(LazyDeclarationResolver.kt:227)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver$resolveToDescriptor$1.visitNamedFunction(LazyDeclarationResolver.kt:124)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver$resolveToDescriptor$1.visitNamedFunction(LazyDeclarationResolver.kt:94)
at org.jetbrains.kotlin.psi.KtNamedFunction.accept(KtNamedFunction.java:50)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.resolveToDescriptor(LazyDeclarationResolver.kt:94)
at org.jetbrains.kotlin.resolve.lazy.LazyDeclarationResolver.resolveToDescriptor(LazyDeclarationResolver.kt:91)
at org.jetbrains.kotlin.resolve.lazy.ResolveSession.resolveToDescriptor(ResolveSession.java:324)
at arrow.meta.qq.QuoteKt$classOrObject$$inlined$quote$2$1.invoke(Quote.kt:221)
at arrow.meta.qq.QuoteKt$classOrObject$$inlined$quote$2$1.invoke(Quote.kt)
at arrow.meta.extensions.MetaComponentRegistrar$syntheticResolver$1.generateSyntheticMethods(MetaComponentRegistrar.kt:407)
at arrow.meta.extensions.MetaComponentRegistrar$registerSyntheticResolver$1.generateSyntheticMethods(MetaComponentRegistrar.kt:596)
at org.jetbrains.kotlin.resolve.extensions.SyntheticResolveExtension$Companion$getInstance$1.generateSyntheticMethods(SyntheticResolveExtension.kt:86)
raulraja
09/03/2019, 10:44 PMSyntheticResolverExtension.generateSyntheticMethods
shikasd
09/04/2019, 1:01 AMkralli
09/04/2019, 6:03 AMthisDescriptor.module.findClassAcrossModuleDependencies(ClassId.topLevel(fqName))
kralli
09/04/2019, 6:03 AMthisDescriptor.module.builtIns.unitType
kralli
09/04/2019, 6:04 AMSyntheticResolveExtension.generateSyntheticMethods
)raulraja
09/04/2019, 7:03 AM