[K/N] Remove diagnostics about old Native GC ^KT-58853
This commit is contained in:
committed by
Space Team
parent
d2eb4a0abf
commit
2364ffb299
-5
@@ -28,11 +28,6 @@ private val DIAGNOSTIC_FACTORY_TO_RENDERER by lazy {
|
||||
"@SharedImmutable is applicable only to val with backing field or to property with delegation"
|
||||
)
|
||||
put(ErrorsNative.INAPPLICABLE_SHARED_IMMUTABLE_TOP_LEVEL, "@SharedImmutable is applicable only to top level declarations")
|
||||
put(
|
||||
ErrorsNative.VARIABLE_IN_SINGLETON_WITHOUT_THREAD_LOCAL,
|
||||
"With old Native GC, variable in singleton without @ThreadLocal can't be changed after initialization"
|
||||
)
|
||||
put(ErrorsNative.VARIABLE_IN_ENUM, "With old Native GC, variable in enum class can't be changed after initialization")
|
||||
put(
|
||||
ErrorsNative.INAPPLICABLE_THREAD_LOCAL,
|
||||
"@ThreadLocal is applicable only to property with backing field, to property with delegation or to objects"
|
||||
|
||||
@@ -27,14 +27,10 @@ object ErrorsNative {
|
||||
@JvmField
|
||||
val INAPPLICABLE_SHARED_IMMUTABLE_TOP_LEVEL = DiagnosticFactory0.create<KtElement>(Severity.ERROR)
|
||||
@JvmField
|
||||
val VARIABLE_IN_SINGLETON_WITHOUT_THREAD_LOCAL = DiagnosticFactory0.create<KtElement>(Severity.INFO)
|
||||
@JvmField
|
||||
val INAPPLICABLE_THREAD_LOCAL = DiagnosticFactory0.create<KtElement>(Severity.ERROR)
|
||||
@JvmField
|
||||
val INAPPLICABLE_THREAD_LOCAL_TOP_LEVEL = DiagnosticFactory0.create<KtElement>(Severity.ERROR)
|
||||
@JvmField
|
||||
val VARIABLE_IN_ENUM = DiagnosticFactory0.create<KtElement>(Severity.INFO)
|
||||
@JvmField
|
||||
val INVALID_CHARACTERS_NATIVE = DiagnosticFactoryForDeprecation1.create<PsiElement, String>(LanguageFeature.ProhibitInvalidCharsInNativeIdentifiers)
|
||||
@JvmField
|
||||
val INAPPLICABLE_OBJC_NAME = DiagnosticFactory0.create<KtElement>(Severity.ERROR)
|
||||
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.konan.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
|
||||
import org.jetbrains.kotlin.resolve.hasBackingField
|
||||
|
||||
object NativeTopLevelSingletonChecker : DeclarationChecker {
|
||||
private val threadLocalFqName = FqName("kotlin.native.concurrent.ThreadLocal")
|
||||
|
||||
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
|
||||
// Check variables inside singletons.
|
||||
if (descriptor !is PropertyDescriptor) return
|
||||
(descriptor.containingDeclaration as? ClassDescriptor)?.let { parent ->
|
||||
val hasBackingFieldWithDefaultSetter = descriptor.hasBackingField(context.trace.bindingContext) &&
|
||||
descriptor.setter?.isDefault == true
|
||||
val hasDelegate = if (declaration is KtProperty) declaration.delegate != null else false
|
||||
|
||||
if (descriptor.isVar && (DescriptorUtils.isEnumClass(parent) || DescriptorUtils.isEnumEntry(parent)) &&
|
||||
hasBackingFieldWithDefaultSetter && !hasDelegate) {
|
||||
context.trace.report(ErrorsNative.VARIABLE_IN_ENUM.on(declaration))
|
||||
} else if (parent.kind.isSingleton) {
|
||||
parent.annotations.findAnnotation(threadLocalFqName) ?: run {
|
||||
if (descriptor.isVar && !hasDelegate && hasBackingFieldWithDefaultSetter) {
|
||||
context.trace.report(ErrorsNative.VARIABLE_IN_SINGLETON_WITHOUT_THREAD_LOCAL.on(declaration))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ object NativePlatformConfigurator : PlatformConfiguratorBase(
|
||||
),
|
||||
additionalDeclarationCheckers = listOf(
|
||||
NativeThrowsChecker, NativeSharedImmutableChecker,
|
||||
NativeTopLevelSingletonChecker, NativeThreadLocalChecker,
|
||||
NativeThreadLocalChecker,
|
||||
NativeObjCNameChecker, NativeObjCNameOverridesChecker,
|
||||
NativeObjCRefinementChecker, NativeObjCRefinementAnnotationChecker,
|
||||
NativeObjCRefinementOverridesChecker, NativeHiddenFromObjCInheritanceChecker
|
||||
|
||||
Reference in New Issue
Block a user