[FE 1.0] Improve error message for disabled "Unit conversions" feature

^KT-49394 Fixed
This commit is contained in:
Victor Petukhov
2022-05-16 11:16:58 +02:00
parent bbf52e8b90
commit 7c38f99cbf
2 changed files with 8 additions and 1 deletions
@@ -12,6 +12,9 @@ class LanguageFeatureMessageRenderer @JvmOverloads constructor(
private val type: Type,
private val useHtml: Boolean = false
) : DiagnosticParameterRenderer<Pair<LanguageFeature, LanguageVersionSettings>> {
private val additionalFeatureMessages = mapOf(
LanguageFeature.UnitConversionsOnArbitraryExpressions to "You can also change the original type of this expression to (...) -> Unit"
)
enum class Type {
UNSUPPORTED,
@@ -52,6 +55,10 @@ class LanguageFeatureMessageRenderer @JvmOverloads constructor(
}
}
if (feature in additionalFeatureMessages) {
sb.append(". ${additionalFeatureMessages[feature]}")
}
return sb.toString()
}
}
@@ -11,5 +11,5 @@ val x = {
}
fun test() {
handle(<!UNSUPPORTED_FEATURE("The feature "unit conversions on arbitrary expressions" is experimental and should be enabled explicitly")!>x<!>)
handle(<!UNSUPPORTED_FEATURE("The feature "unit conversions on arbitrary expressions" is experimental and should be enabled explicitly. You can also change the original type of this expression to (...) -> Unit")!>x<!>)
}