Enable signed to unsigned coercion for modules with special capability
Mainly this is needed for Kotlin/Native part
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun ModuleDescriptor.hasImplicitIntegerCoercionCapability(): Boolean {
|
||||
return getCapability(ImplicitIntegerCoercion.MODULE_CAPABILITY) == true
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user