[Commonizer] Enable Optimistic Number Commonization by default
Initially it was restricted to work with type aliases only KT-48455 see test `test property with aliased number return type` This limitation should be lifted now in order to fix KT-48568 ^KT-48568 Verification Pending
This commit is contained in:
@@ -17,7 +17,7 @@ class TypeAliasCommonizer(
|
||||
) : NullableSingleInvocationCommonizer<CirTypeAlias> {
|
||||
|
||||
private val typeCommonizer = typeCommonizer.withOptions {
|
||||
withBackwardsTypeAliasSubstitutionEnabled(false).withOptimisticNumberTypeCommonizationEnabled(true)
|
||||
withBackwardsTypeAliasSubstitutionEnabled(false)
|
||||
}
|
||||
|
||||
override fun invoke(values: List<CirTypeAlias>): CirTypeAlias? {
|
||||
|
||||
@@ -34,7 +34,7 @@ class TypeCommonizer(
|
||||
}
|
||||
|
||||
data class Options(
|
||||
val enableOptimisticNumberTypeCommonization: Boolean = false,
|
||||
val enableOptimisticNumberTypeCommonization: Boolean = true,
|
||||
val enableCovariantNullabilityCommonization: Boolean = false,
|
||||
val enableForwardTypeAliasSubstitution: Boolean = true,
|
||||
val enableBackwardsTypeAliasSubstitution: Boolean = true,
|
||||
|
||||
native/commonizer/testData/callableMemberCommonization/returnTypes/commonized/common/package_root.kt
Vendored
+6
@@ -27,6 +27,12 @@ expect fun function5(): Planet
|
||||
expect fun function6(): Planet
|
||||
expect fun function7(): C
|
||||
|
||||
// Optimistic Number Commonization: KT-48455, KT-48568
|
||||
expect val propertyWithMismatchedType1: Int
|
||||
expect val propertyWithMismatchedType2: Short
|
||||
expect fun functionWithMismatchedType1(): Int
|
||||
expect fun functionWithMismatchedType2(): Short
|
||||
|
||||
expect class Box<T>(value: T) {
|
||||
val value: T
|
||||
}
|
||||
|
||||
Vendored
+7
@@ -19,3 +19,10 @@ const val property17 = "42"
|
||||
expect val property18: String
|
||||
const val property19: Char = 42.toChar()
|
||||
expect val property20: Char
|
||||
|
||||
// Optimistic Number Commonization: KT-48455, KT-48568
|
||||
// Mismatched const types should be commonized as expect val's
|
||||
expect val property22: Byte
|
||||
expect val property23: Short
|
||||
expect val property24: Int
|
||||
expect val property26: Float
|
||||
+1
-6
@@ -678,12 +678,7 @@ class HierarchicalOptimisticNumbersTypeCommonizerTest : AbstractInlineSourcesCom
|
||||
simpleSingleSourceTarget("b", "val x: ULong = null!!")
|
||||
}
|
||||
|
||||
/*
|
||||
Only commonize return types that were specified using a type-alias.
|
||||
As with function value parameters, this is not a hard requirement.
|
||||
It would also be reasonable to support this case.
|
||||
*/
|
||||
result.assertCommonized("(a, b)", "")
|
||||
result.assertCommonized("(a, b)", "expect val x: kotlin.UInt")
|
||||
}
|
||||
|
||||
fun `test property with aliased number return type`() {
|
||||
|
||||
Reference in New Issue
Block a user