EA-34240 - SIOOBE: CompileTimeConstantResolver.getCharValue

This commit is contained in:
Andrey Breslav
2012-03-12 16:57:43 +04:00
parent b4e2a5fb30
commit c315734665
2 changed files with 15 additions and 2 deletions
@@ -182,11 +182,11 @@ public class CompileTimeConstantResolver {
}
// Strip the quotes
if (text.charAt(0) != '\'' || text.charAt(text.length() - 1) != '\'') {
if (text.length() < 2 || text.charAt(0) != '\'' || text.charAt(text.length() - 1) != '\'') {
return new ErrorValue("Incorrect character literal");
}
text = text.substring(1, text.length() - 1); // now there're no quotes
if (text.length() == 0) {
return new ErrorValue("Empty character literal");
}
@@ -0,0 +1,13 @@
fun test(<!UNUSED_PARAMETER!>c<!> : Char) {
test(<!ERROR_COMPILE_TIME_VALUE!>''<!>)
test('a')
test(<!ERROR_COMPILE_TIME_VALUE!>'aa'<!>)
test(<!ERROR_COMPILE_TIME_VALUE!>'a)<!>
<!UNRESOLVED_REFERENCE!>test<!>(<!ERROR_COMPILE_TIME_VALUE!>'<!>
<!UNRESOLVED_REFERENCE!>test<!>(0<!SYNTAX!><!SYNTAX!><!>'<!>
test('\n')
test('\\')
test(<!ERROR_COMPILE_TIME_VALUE!>''<!><!SYNTAX!>''<!><!SYNTAX!>)<!>
test('\'')
test('\"')
}