[FE 1.0] Improve error message for disabled "Unit conversions" feature
^KT-49394 Fixed
This commit is contained in:
+7
@@ -12,6 +12,9 @@ class LanguageFeatureMessageRenderer @JvmOverloads constructor(
|
|||||||
private val type: Type,
|
private val type: Type,
|
||||||
private val useHtml: Boolean = false
|
private val useHtml: Boolean = false
|
||||||
) : DiagnosticParameterRenderer<Pair<LanguageFeature, LanguageVersionSettings>> {
|
) : 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 {
|
enum class Type {
|
||||||
UNSUPPORTED,
|
UNSUPPORTED,
|
||||||
@@ -52,6 +55,10 @@ class LanguageFeatureMessageRenderer @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (feature in additionalFeatureMessages) {
|
||||||
|
sb.append(". ${additionalFeatureMessages[feature]}")
|
||||||
|
}
|
||||||
|
|
||||||
return sb.toString()
|
return sb.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,5 @@ val x = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun test() {
|
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<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user