diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ImplicitIntegerCoercion.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ImplicitIntegerCoercion.kt index 272cbf51bc0..af805ba8d75 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ImplicitIntegerCoercion.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ImplicitIntegerCoercion.kt @@ -21,12 +21,15 @@ object ImplicitIntegerCoercion { private fun isEnabledFor(descriptor: DeclarationDescriptor): Boolean = descriptor.hasImplicitIntegerCoercionAnnotation() || - DescriptorUtils.getContainingModuleOrNull(descriptor) - ?.getCapability(ImplicitIntegerCoercion.MODULE_CAPABILITY) == true + DescriptorUtils.getContainingModuleOrNull(descriptor)?.hasImplicitIntegerCoercionCapability() == true private val IMPLICIT_INTEGER_COERCION_ANNOTATION_FQ_NAME = FqName("kotlin.internal.ImplicitIntegerCoercion") private fun DeclarationDescriptor.hasImplicitIntegerCoercionAnnotation(): Boolean { return annotations.findAnnotation(IMPLICIT_INTEGER_COERCION_ANNOTATION_FQ_NAME) != null } -} \ No newline at end of file +} + +fun ModuleDescriptor.hasImplicitIntegerCoercionCapability(): Boolean { + return getCapability(ImplicitIntegerCoercion.MODULE_CAPABILITY) == true +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index f3ba97846b6..bbb26989ec5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -323,7 +323,7 @@ class CallCompleter( val constant = context.trace[BindingContext.COMPILE_TIME_VALUE, deparenthesized] val convertedConst = constant is IntegerValueTypeConstant && constant.convertedFromSigned - if (convertedConst) { + if (convertedConst && !moduleDescriptor.hasImplicitIntegerCoercionCapability()) { context.trace.report(Errors.SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED.on(deparenthesized)) }