Underscore query: tolerate synthetic functions

This commit is contained in:
Chris Smowton
2022-07-18 12:54:07 +01:00
parent 41ca791966
commit 0a351b73cb
6 changed files with 48 additions and 6 deletions

View File

@@ -9,4 +9,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun isUnderscoreParameter(vp: IrValueParameter) =
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)?.safeAs<KtParameter>()?.isSingleUnderscore == true
try {
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)
?.safeAs<KtParameter>()?.isSingleUnderscore == true
} catch(e: NotImplementedError) {
// Some kinds of descriptor throw in `getSourceFromDescriptor` as that method is not normally expected to
// be applied to synthetic functions.
false
}

View File

@@ -9,4 +9,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun isUnderscoreParameter(vp: IrValueParameter) =
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)?.safeAs<KtParameter>()?.isSingleUnderscore == true
try {
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)
?.safeAs<KtParameter>()?.isSingleUnderscore == true
} catch(e: NotImplementedError) {
// Some kinds of descriptor throw in `getSourceFromDescriptor` as that method is not normally expected to
// be applied to synthetic functions.
false
}

View File

@@ -9,4 +9,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun isUnderscoreParameter(vp: IrValueParameter) =
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)?.safeAs<KtParameter>()?.isSingleUnderscore == true
try {
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)
?.safeAs<KtParameter>()?.isSingleUnderscore == true
} catch(e: NotImplementedError) {
// Some kinds of descriptor throw in `getSourceFromDescriptor` as that method is not normally expected to
// be applied to synthetic functions.
false
}

View File

@@ -9,4 +9,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun isUnderscoreParameter(vp: IrValueParameter) =
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)?.safeAs<KtParameter>()?.isSingleUnderscore == true
try {
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)
?.safeAs<KtParameter>()?.isSingleUnderscore == true
} catch(e: NotImplementedError) {
// Some kinds of descriptor throw in `getSourceFromDescriptor` as that method is not normally expected to
// be applied to synthetic functions.
false
}

View File

@@ -9,4 +9,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun isUnderscoreParameter(vp: IrValueParameter) =
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)?.safeAs<KtParameter>()?.isSingleUnderscore == true
try {
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)
?.safeAs<KtParameter>()?.isSingleUnderscore == true
} catch(e: NotImplementedError) {
// Some kinds of descriptor throw in `getSourceFromDescriptor` as that method is not normally expected to
// be applied to synthetic functions.
false
}

View File

@@ -9,4 +9,11 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@OptIn(ObsoleteDescriptorBasedAPI::class)
fun isUnderscoreParameter(vp: IrValueParameter) =
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)?.safeAs<KtParameter>()?.isSingleUnderscore == true
try {
DescriptorToSourceUtils.getSourceFromDescriptor(vp.descriptor)
?.safeAs<KtParameter>()?.isSingleUnderscore == true
} catch(e: NotImplementedError) {
// Some kinds of descriptor throw in `getSourceFromDescriptor` as that method is not normally expected to
// be applied to synthetic functions.
false
}