AllOpen: Do not make private members open (KT-16627)

This commit is contained in:
Yan Zhulanow
2017-03-13 19:31:42 +03:00
parent bb0a46ac17
commit 5d4cefcc30
4 changed files with 47 additions and 1 deletions
@@ -16,13 +16,13 @@
package org.jetbrains.kotlin.allopen
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.extensions.AnnotationBasedExtension
import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.psi.KtModifierListOwner
import org.jetbrains.kotlin.resolve.BindingContext
@@ -48,6 +48,10 @@ abstract class AbstractAllOpenDeclarationAttributeAltererExtension : Declaration
return null
}
if (modifierListOwner.hasModifier(KtTokens.PRIVATE_KEYWORD) && modifierListOwner is KtCallableDeclaration) {
return null
}
val descriptor = declaration as? ClassDescriptor ?: containingDeclaration ?: return null
if (descriptor.hasSpecialAnnotation(modifierListOwner)) {
return if (modifierListOwner.hasModifier(KtTokens.FINAL_KEYWORD))