Enable signed to unsigned coercion for modules with special capability
Mainly this is needed for Kotlin/Native part
This commit is contained in:
@@ -21,8 +21,7 @@ object ImplicitIntegerCoercion {
|
|||||||
|
|
||||||
private fun isEnabledFor(descriptor: DeclarationDescriptor): Boolean =
|
private fun isEnabledFor(descriptor: DeclarationDescriptor): Boolean =
|
||||||
descriptor.hasImplicitIntegerCoercionAnnotation() ||
|
descriptor.hasImplicitIntegerCoercionAnnotation() ||
|
||||||
DescriptorUtils.getContainingModuleOrNull(descriptor)
|
DescriptorUtils.getContainingModuleOrNull(descriptor)?.hasImplicitIntegerCoercionCapability() == true
|
||||||
?.getCapability(ImplicitIntegerCoercion.MODULE_CAPABILITY) == true
|
|
||||||
|
|
||||||
private val IMPLICIT_INTEGER_COERCION_ANNOTATION_FQ_NAME = FqName("kotlin.internal.ImplicitIntegerCoercion")
|
private val IMPLICIT_INTEGER_COERCION_ANNOTATION_FQ_NAME = FqName("kotlin.internal.ImplicitIntegerCoercion")
|
||||||
|
|
||||||
@@ -30,3 +29,7 @@ object ImplicitIntegerCoercion {
|
|||||||
return annotations.findAnnotation(IMPLICIT_INTEGER_COERCION_ANNOTATION_FQ_NAME) != null
|
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 constant = context.trace[BindingContext.COMPILE_TIME_VALUE, deparenthesized]
|
||||||
val convertedConst = constant is IntegerValueTypeConstant && constant.convertedFromSigned
|
val convertedConst = constant is IntegerValueTypeConstant && constant.convertedFromSigned
|
||||||
if (convertedConst) {
|
if (convertedConst && !moduleDescriptor.hasImplicitIntegerCoercionCapability()) {
|
||||||
context.trace.report(Errors.SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED.on(deparenthesized))
|
context.trace.report(Errors.SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED.on(deparenthesized))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user