[FIR] Fix disappeared ILLEGAL_ESCAPE
^KT-59950 Fixed
This commit is contained in:
committed by
Space Team
parent
e4fc375900
commit
42af684ab7
+12
-4
@@ -514,8 +514,15 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
}
|
||||
ESCAPE_STRING_TEMPLATE_ENTRY -> {
|
||||
sb.append(entry.unescapedValue)
|
||||
buildConstExpression(
|
||||
entry.toFirSourceElement(), ConstantValueKind.String, entry.unescapedValue, setType = false
|
||||
val characterWithDiagnostic = escapedStringToCharacter(entry.asText)
|
||||
buildConstOrErrorExpression(
|
||||
entry.toFirSourceElement(),
|
||||
ConstantValueKind.Char,
|
||||
characterWithDiagnostic.value,
|
||||
ConeSimpleDiagnostic(
|
||||
"Incorrect character: ${entry.asText}",
|
||||
characterWithDiagnostic.getDiagnostic() ?: DiagnosticKind.IllegalConstExpression
|
||||
)
|
||||
)
|
||||
}
|
||||
SHORT_STRING_TEMPLATE_ENTRY, LONG_STRING_TEMPLATE_ENTRY -> {
|
||||
@@ -533,8 +540,9 @@ abstract class AbstractRawFirBuilder<T>(val baseSession: FirSession, val context
|
||||
}
|
||||
}
|
||||
source = base?.toFirSourceElement()
|
||||
// Fast-pass if there is no non-const string expressions
|
||||
if (!hasExpressions) return buildConstExpression(source, ConstantValueKind.String, sb.toString(), setType = false)
|
||||
// Fast-pass if there is no errors and non-const string expressions
|
||||
if (!hasExpressions && !argumentList.arguments.any { it is FirErrorExpression })
|
||||
return buildConstExpression(source, ConstantValueKind.String, sb.toString(), setType = false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
fun demo() {
|
||||
val abc = 1
|
||||
val a = ""
|
||||
val asd = 1
|
||||
val bar = 5
|
||||
fun map(f : () -> Any?) : Int = 1
|
||||
fun buzz(f : () -> Any?) : Int = 1
|
||||
val sdf = 1
|
||||
val foo = 3;
|
||||
"$abc"
|
||||
"$"
|
||||
"$.$.asdf$\t"
|
||||
"asd\$"
|
||||
"asd$a\x"
|
||||
"asd$a$asd$ $<!UNRESOLVED_REFERENCE!>xxx<!>"
|
||||
"fosdfasdo${1 + bar + 100}}sdsdfgdsfsdf"
|
||||
"foo${bar + map {foo}}sdfsdf"
|
||||
"foo${bar + map { "foo" }}sdfsdf"
|
||||
"foo${bar + map {
|
||||
"foo$sdf${ buzz{}}" }}sdfsdf"
|
||||
"a\u \u0 \u00 \u000 \u0000 \u0AaA \u0AAz.length( ) + \u0022b"
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
fun demo() {
|
||||
val abc = 1
|
||||
val a = ""
|
||||
|
||||
Reference in New Issue
Block a user