[Injection] Annotate default services with @DefaultImplementation
This commit is contained in:
@@ -46,6 +46,10 @@ fun StorageComponentContainer.useInstance(instance: Any) {
|
||||
registerInstance(instance)
|
||||
}
|
||||
|
||||
fun StorageComponentContainer.useInstanceIfNotNull(instance: Any?) {
|
||||
if (instance != null) registerInstance(instance)
|
||||
}
|
||||
|
||||
inline operator fun <reified T : Any> ComponentProvider.getValue(thisRef: Any?, desc: KProperty<*>): T {
|
||||
return getService(T::class.java)
|
||||
}
|
||||
|
||||
-1
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
import org.jetbrains.kotlin.types.expressions.FunctionWithBigAritySupport
|
||||
|
||||
object JvmPlatformConfigurator : PlatformConfiguratorBase(
|
||||
DynamicTypesSettings(),
|
||||
additionalDeclarationCheckers = listOf(
|
||||
JvmNameAnnotationChecker(),
|
||||
VolatileAnnotationChecker(),
|
||||
|
||||
@@ -6,28 +6,12 @@
|
||||
package org.jetbrains.kotlin.analyzer.common
|
||||
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMap
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.components.SamConversionTransformer
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
|
||||
private object CommonPlatformConfigurator : PlatformConfiguratorBase(
|
||||
DynamicTypesSettings(), listOf(), listOf(), listOf(), listOf(), listOf(),
|
||||
IdentifierChecker.Default, OverloadFilter.Default, PlatformToKotlinClassMap.EMPTY, DelegationFilter.Default,
|
||||
OverridesBackwardCompatibilityHelper.Default,
|
||||
DeclarationReturnTypeSanitizer.Default
|
||||
) {
|
||||
override fun configureModuleComponents(container: StorageComponentContainer) {
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
container.useInstance(SamConversionTransformer.Empty)
|
||||
container.useInstance(TypeSpecificityComparator.NONE)
|
||||
}
|
||||
private object CommonPlatformConfigurator : PlatformConfiguratorBase() {
|
||||
override fun configureModuleComponents(container: StorageComponentContainer) {}
|
||||
}
|
||||
|
||||
object CommonPlatformCompilerServices : PlatformDependentCompilerServices() {
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.WrappedTypeFactory
|
||||
|
||||
@DefaultImplementation(impl = DeclarationReturnTypeSanitizer.Default::class)
|
||||
interface DeclarationReturnTypeSanitizer {
|
||||
fun sanitizeReturnType(
|
||||
inferred: UnwrappedType,
|
||||
|
||||
@@ -16,10 +16,12 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||
|
||||
@DefaultImplementation(impl = IdentifierChecker.Default::class)
|
||||
interface IdentifierChecker {
|
||||
fun checkIdentifier(simpleNameExpression: KtSimpleNameExpression, diagnosticHolder: DiagnosticSink)
|
||||
fun checkDeclaration(declaration: KtDeclaration, diagnosticHolder: DiagnosticSink)
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorNonRoot
|
||||
|
||||
|
||||
@DefaultImplementation(impl = OverloadFilter.Default::class)
|
||||
interface OverloadFilter {
|
||||
fun filterPackageMemberOverloads(overloads: Collection<DeclarationDescriptorNonRoot>): Collection<DeclarationDescriptorNonRoot>
|
||||
|
||||
|
||||
+2
@@ -16,8 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve
|
||||
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
|
||||
@DefaultImplementation(impl = OverridesBackwardCompatibilityHelper.Default::class)
|
||||
interface OverridesBackwardCompatibilityHelper {
|
||||
fun overrideCanBeOmitted(overridingDescriptor: CallableMemberDescriptor): Boolean
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.container.composeContainer
|
||||
import org.jetbrains.kotlin.container.useImpl
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.*
|
||||
import org.jetbrains.kotlin.container.*
|
||||
import org.jetbrains.kotlin.resolve.checkers.*
|
||||
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
||||
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
@@ -56,18 +57,18 @@ private val DEFAULT_ANNOTATION_CHECKERS = listOf<AdditionalAnnotationChecker>()
|
||||
|
||||
|
||||
abstract class PlatformConfiguratorBase(
|
||||
private val dynamicTypesSettings: DynamicTypesSettings,
|
||||
additionalDeclarationCheckers: List<DeclarationChecker>,
|
||||
additionalCallCheckers: List<CallChecker>,
|
||||
additionalTypeCheckers: List<AdditionalTypeChecker>,
|
||||
additionalClassifierUsageCheckers: List<ClassifierUsageChecker>,
|
||||
additionalAnnotationCheckers: List<AdditionalAnnotationChecker>,
|
||||
private val identifierChecker: IdentifierChecker,
|
||||
private val overloadFilter: OverloadFilter,
|
||||
private val platformToKotlinClassMap: PlatformToKotlinClassMap,
|
||||
private val delegationFilter: DelegationFilter,
|
||||
private val overridesBackwardCompatibilityHelper: OverridesBackwardCompatibilityHelper,
|
||||
private val declarationReturnTypeSanitizer: DeclarationReturnTypeSanitizer
|
||||
private val dynamicTypesSettings: DynamicTypesSettings? = null,
|
||||
additionalDeclarationCheckers: List<DeclarationChecker> = emptyList(),
|
||||
additionalCallCheckers: List<CallChecker> = emptyList(),
|
||||
additionalTypeCheckers: List<AdditionalTypeChecker> = emptyList(),
|
||||
additionalClassifierUsageCheckers: List<ClassifierUsageChecker> = emptyList(),
|
||||
additionalAnnotationCheckers: List<AdditionalAnnotationChecker> = emptyList(),
|
||||
private val identifierChecker: IdentifierChecker? = null,
|
||||
private val overloadFilter: OverloadFilter? = null,
|
||||
private val platformToKotlinClassMap: PlatformToKotlinClassMap? = null,
|
||||
private val delegationFilter: DelegationFilter? = null,
|
||||
private val overridesBackwardCompatibilityHelper: OverridesBackwardCompatibilityHelper? = null,
|
||||
private val declarationReturnTypeSanitizer: DeclarationReturnTypeSanitizer? = null
|
||||
) : PlatformConfigurator {
|
||||
private val declarationCheckers: List<DeclarationChecker> = DEFAULT_DECLARATION_CHECKERS + additionalDeclarationCheckers
|
||||
private val callCheckers: List<CallChecker> = DEFAULT_CALL_CHECKERS + additionalCallCheckers
|
||||
@@ -77,18 +78,18 @@ abstract class PlatformConfiguratorBase(
|
||||
private val annotationCheckers: List<AdditionalAnnotationChecker> = DEFAULT_ANNOTATION_CHECKERS + additionalAnnotationCheckers
|
||||
|
||||
override val platformSpecificContainer = composeContainer(this::class.java.simpleName) {
|
||||
useInstance(dynamicTypesSettings)
|
||||
useInstanceIfNotNull(dynamicTypesSettings)
|
||||
declarationCheckers.forEach { useInstance(it) }
|
||||
callCheckers.forEach { useInstance(it) }
|
||||
typeCheckers.forEach { useInstance(it) }
|
||||
classifierUsageCheckers.forEach { useInstance(it) }
|
||||
annotationCheckers.forEach { useInstance(it) }
|
||||
useInstance(identifierChecker)
|
||||
useInstance(overloadFilter)
|
||||
useInstance(platformToKotlinClassMap)
|
||||
useInstance(delegationFilter)
|
||||
useInstance(overridesBackwardCompatibilityHelper)
|
||||
useInstance(declarationReturnTypeSanitizer)
|
||||
useInstanceIfNotNull(identifierChecker)
|
||||
useInstanceIfNotNull(overloadFilter)
|
||||
useInstanceIfNotNull(platformToKotlinClassMap)
|
||||
useInstanceIfNotNull(delegationFilter)
|
||||
useInstanceIfNotNull(overridesBackwardCompatibilityHelper)
|
||||
useInstanceIfNotNull(declarationReturnTypeSanitizer)
|
||||
}
|
||||
|
||||
override fun configureModuleDependentCheckers(container: StorageComponentContainer) {
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
package org.jetbrains.kotlin.resolve.lazy
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
|
||||
@DefaultImplementation(impl = DelegationFilter.Default::class)
|
||||
interface DelegationFilter {
|
||||
|
||||
fun filter(interfaceMember: CallableMemberDescriptor, languageVersionSettings: LanguageVersionSettings): Boolean
|
||||
|
||||
+2
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls.components
|
||||
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
@@ -59,6 +60,7 @@ interface KotlinResolutionCallbacks {
|
||||
fun disableContractsIfNecessary(resolvedAtom: ResolvedCallAtom)
|
||||
}
|
||||
|
||||
@DefaultImplementation(impl = SamConversionTransformer.Empty::class)
|
||||
interface SamConversionTransformer {
|
||||
fun getFunctionTypeForPossibleSamType(possibleSamType: UnwrappedType): UnwrappedType?
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.results
|
||||
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.MemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
@@ -28,6 +29,7 @@ interface SpecificityComparisonCallbacks {
|
||||
fun isNonSubtypeNotLessSpecific(specific: KotlinTypeMarker, general: KotlinTypeMarker): Boolean
|
||||
}
|
||||
|
||||
@DefaultImplementation(impl = TypeSpecificityComparator.NONE::class)
|
||||
interface TypeSpecificityComparator {
|
||||
fun isDefinitelyLessSpecific(specific: KotlinTypeMarker, general: KotlinTypeMarker): Boolean
|
||||
|
||||
|
||||
+2
@@ -16,9 +16,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.components
|
||||
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
|
||||
import org.jetbrains.kotlin.types.SimpleType
|
||||
|
||||
@DefaultImplementation(impl = SamConversionResolver.Empty::class)
|
||||
interface SamConversionResolver {
|
||||
object Empty : SamConversionResolver {
|
||||
override fun resolveFunctionTypeIfSamInterface(classDescriptor: JavaClassDescriptor): SimpleType? = null
|
||||
|
||||
@@ -6,20 +6,22 @@
|
||||
package org.jetbrains.kotlin.builtins;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@DefaultImplementation(impl = PlatformToKotlinClassMap.Default.class)
|
||||
public interface PlatformToKotlinClassMap {
|
||||
PlatformToKotlinClassMap EMPTY = new PlatformToKotlinClassMap() {
|
||||
@NotNull
|
||||
Collection<ClassDescriptor> mapPlatformClass(@NotNull ClassDescriptor classDescriptor);
|
||||
|
||||
class Default implements PlatformToKotlinClassMap {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> mapPlatformClass(@NotNull ClassDescriptor classDescriptor) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
};
|
||||
|
||||
@NotNull
|
||||
Collection<ClassDescriptor> mapPlatformClass(@NotNull ClassDescriptor classDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.scopes
|
||||
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
@@ -95,6 +96,7 @@ interface SyntheticScope {
|
||||
}
|
||||
}
|
||||
|
||||
@DefaultImplementation(impl = SyntheticScopes.Empty::class)
|
||||
interface SyntheticScopes {
|
||||
val scopes: Collection<SyntheticScope>
|
||||
|
||||
|
||||
@@ -17,18 +17,20 @@
|
||||
package org.jetbrains.kotlin.types
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.container.DefaultImplementation
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRendererOptions
|
||||
import org.jetbrains.kotlin.types.model.DynamicTypeMarker
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
|
||||
@DefaultImplementation(impl = DynamicTypesSettings::class)
|
||||
open class DynamicTypesSettings {
|
||||
open val dynamicTypesAllowed: Boolean
|
||||
get() = false
|
||||
}
|
||||
|
||||
class DynamicTypesAllowed: DynamicTypesSettings() {
|
||||
class DynamicTypesAllowed : DynamicTypesSettings() {
|
||||
override val dynamicTypesAllowed: Boolean
|
||||
get() = true
|
||||
}
|
||||
|
||||
@@ -16,22 +16,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.js.resolve
|
||||
|
||||
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMap
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.useImpl
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.js.analyze.JsNativeDiagnosticSuppressor
|
||||
import org.jetbrains.kotlin.js.naming.NameSuggestion
|
||||
import org.jetbrains.kotlin.js.resolve.diagnostics.*
|
||||
import org.jetbrains.kotlin.resolve.DeclarationReturnTypeSanitizer
|
||||
import org.jetbrains.kotlin.resolve.OverloadFilter
|
||||
import org.jetbrains.kotlin.resolve.OverridesBackwardCompatibilityHelper
|
||||
import org.jetbrains.kotlin.resolve.PlatformConfiguratorBase
|
||||
import org.jetbrains.kotlin.resolve.calls.components.SamConversionTransformer
|
||||
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.deprecation.CoroutineCompatibilitySupport
|
||||
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.types.DynamicTypesAllowed
|
||||
|
||||
object JsPlatformConfigurator : PlatformConfiguratorBase(
|
||||
@@ -49,21 +42,11 @@ object JsPlatformConfigurator : PlatformConfiguratorBase(
|
||||
JsDynamicCallChecker,
|
||||
JsDefinedExternallyCallChecker
|
||||
),
|
||||
additionalTypeCheckers = listOf(),
|
||||
additionalClassifierUsageCheckers = listOf(),
|
||||
additionalAnnotationCheckers = listOf(),
|
||||
identifierChecker = JsIdentifierChecker,
|
||||
overloadFilter = OverloadFilter.Default,
|
||||
platformToKotlinClassMap = PlatformToKotlinClassMap.EMPTY,
|
||||
delegationFilter = DelegationFilter.Default,
|
||||
overridesBackwardCompatibilityHelper = OverridesBackwardCompatibilityHelper.Default,
|
||||
declarationReturnTypeSanitizer = DeclarationReturnTypeSanitizer.Default
|
||||
identifierChecker = JsIdentifierChecker
|
||||
) {
|
||||
override fun configureModuleComponents(container: StorageComponentContainer) {
|
||||
container.useInstance(NameSuggestion())
|
||||
container.useImpl<JsCallChecker>()
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
container.useInstance(SamConversionTransformer.Empty)
|
||||
container.useImpl<JsTypeSpecificityComparator>()
|
||||
container.useImpl<JsNameClashChecker>()
|
||||
container.useImpl<JsNameCharsChecker>()
|
||||
|
||||
+1
-21
@@ -5,35 +5,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.konan.platform
|
||||
|
||||
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMap
|
||||
import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.components.SamConversionTransformer
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.jvm.checkers.SuperCallWithDefaultArgumentsChecker
|
||||
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
|
||||
import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
|
||||
object KonanPlatformConfigurator : PlatformConfiguratorBase(
|
||||
DynamicTypesSettings(),
|
||||
additionalDeclarationCheckers = listOf(ExpectedActualDeclarationChecker()),
|
||||
additionalCallCheckers = listOf(SuperCallWithDefaultArgumentsChecker()),
|
||||
additionalTypeCheckers = listOf(),
|
||||
additionalClassifierUsageCheckers = listOf(),
|
||||
additionalAnnotationCheckers = listOf(),
|
||||
identifierChecker = IdentifierChecker.Default,
|
||||
overloadFilter = OverloadFilter.Default,
|
||||
platformToKotlinClassMap = PlatformToKotlinClassMap.EMPTY,
|
||||
delegationFilter = DelegationFilter.Default,
|
||||
overridesBackwardCompatibilityHelper = OverridesBackwardCompatibilityHelper.Default,
|
||||
declarationReturnTypeSanitizer = DeclarationReturnTypeSanitizer.Default
|
||||
additionalCallCheckers = listOf(SuperCallWithDefaultArgumentsChecker())
|
||||
) {
|
||||
override fun configureModuleComponents(container: StorageComponentContainer) {
|
||||
container.useInstance(SyntheticScopes.Empty)
|
||||
container.useInstance(TypeSpecificityComparator.NONE)
|
||||
container.useInstance(SamConversionTransformer.Empty)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user