jdemeulenaere
12/10/2019, 10:39 AMKotlinType
? It works but it is pretty slow as it fetches all top level extensions that are available (even the ones not imported). I can add restriction on the package and only get imported functions if it can help make things faster. Thanks a lot 🙂
fun getExtensionsOnType(type: KotlinType, scope: LexicalScope): List<DeclarationDescriptor> {
val extensionKindFilter = kindFilter exclude DescriptorKindExclude.NonExtensions
return scope.collectDescriptorsFiltered(extensionKindFilter, nameFilter)
.filter {
val receiverType = (it as? CallableDescriptor)?.extensionReceiverParameter?.value?.type
receiverType != null && this.isSubtypeOf(receiverType)
}
}
raulraja
12/10/2019, 12:48 PMraulraja
12/10/2019, 12:48 PM