Merge branch 'KT-1396' of https://github.com/mcgee/kotlin into mcgee-KT-1396
This commit is contained in:
@@ -1484,7 +1484,8 @@ public class KotlinExpressionParsing extends AbstractKotlinParsing {
|
||||
}
|
||||
thenBranch.done(THEN);
|
||||
|
||||
if (at(ELSE_KEYWORD)) {
|
||||
// lookahead for arrow is needed to prevent capturing of whenEntry like "else -> "
|
||||
if (at(ELSE_KEYWORD) && lookahead(1) != ARROW) {
|
||||
advance(); // ELSE_KEYWORD
|
||||
|
||||
PsiBuilder.Marker elseBranch = mark();
|
||||
|
||||
Vendored
+7
@@ -67,3 +67,10 @@ fun whenWithoutCondition(i : Int) {
|
||||
else -> 2
|
||||
}
|
||||
}
|
||||
|
||||
fun ifDoesntCaptureElse(x : Int) {
|
||||
when (x) {
|
||||
2 -> if(1) 3
|
||||
else -> 6
|
||||
}
|
||||
}
|
||||
Vendored
+61
@@ -755,3 +755,64 @@ JetFile: When.kt
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n\n')
|
||||
FUN
|
||||
PsiElement(fun)('fun')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('ifDoesntCaptureElse')
|
||||
VALUE_PARAMETER_LIST
|
||||
PsiElement(LPAR)('(')
|
||||
VALUE_PARAMETER
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
BLOCK
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
WHEN
|
||||
PsiElement(when)('when')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LPAR)('(')
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n ')
|
||||
WHEN_ENTRY
|
||||
WHEN_CONDITION_WITH_EXPRESSION
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('2')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(ARROW)('->')
|
||||
PsiWhiteSpace(' ')
|
||||
IF
|
||||
PsiElement(if)('if')
|
||||
PsiElement(LPAR)('(')
|
||||
CONDITION
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiElement(RPAR)(')')
|
||||
PsiWhiteSpace(' ')
|
||||
THEN
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('3')
|
||||
PsiWhiteSpace('\n ')
|
||||
WHEN_ENTRY
|
||||
PsiElement(else)('else')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(ARROW)('->')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('6')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
Reference in New Issue
Block a user