[Parser] Fix OOM in parsing of incorrect string literals

^KT-46455 Fixed
KT-34410
KT-46564
This commit is contained in:
Dmitriy Novozhilov
2021-05-10 12:20:26 +03:00
committed by TeamCityServer
parent c284eab2dd
commit 3532ce7fbc
5 changed files with 79 additions and 2 deletions
@@ -105,7 +105,7 @@ import static org.jetbrains.kotlin.lexer.KtTokens.*;
IElementType tt = tt();
if (recoverySet == null ||
recoverySet.contains(tt) ||
tt == LBRACE || tt == RBRACE || tt == LONG_TEMPLATE_ENTRY_END ||
tt == LBRACE || tt == RBRACE ||
(recoverySet.contains(EOL_OR_SEMICOLON) && (eof() || tt == SEMICOLON || myBuilder.newlineBeforeCurrentToken()))) {
error(message);
}
@@ -682,7 +682,7 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
else if (!parseLiteralConstant()) {
ok = false;
// TODO: better recovery if FIRST(element) did not match
errorWithRecovery("Expecting an element", EXPRESSION_FOLLOW);
errorWithRecovery("Expecting an element", TokenSet.orSet(EXPRESSION_FOLLOW, TokenSet.create(LONG_TEMPLATE_ENTRY_END)));
}
return ok;