Don't run ExpectedActualDeclarationChecker on property accessors
One might think that it shouldn't be run because of 'if (declaration !is KtNamedDeclaration) return' check in the 'check'-overload. However, for default accessors we pass PSI for property, i.e. KtProperty (see 'DeclarationCheckers.checkAccessors'), which obviously passes this check Note that we can't use `DescriptorToSourceUtils` here, because it's returns `KtProperty` for default accessor too. This commits adds specific check for that case, to avoid exception in KT-28385. Ideal solution would be to either don't launch checkers on such parameters, or explicitly declare semantic of the 'declaration'-parameter, e.g. to rename it to 'reportOn' (see KT-28403 for discussion) ^KT-28385 Fixed
This commit is contained in:
+3
@@ -49,6 +49,9 @@ class ExpectedActualDeclarationChecker(val argumentExtractors: List<ActualAnnota
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)) return
|
||||
|
||||
// Note that this check is necessary, because for default accessors KtProperty is passed for KtDeclaration, so this
|
||||
// case won't be covered by the next check (also, it accidentally fixes KT-28385)
|
||||
if (descriptor is PropertyAccessorDescriptor) return
|
||||
if (declaration !is KtNamedDeclaration) return
|
||||
if (descriptor !is MemberDescriptor || DescriptorUtils.isEnumEntry(descriptor)) return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user