Generate parse error on label without name '@'

This commit is contained in:
Svetlana Isakova
2014-05-15 15:24:14 +04:00
parent f109cfc303
commit e0f37bbef0
15 changed files with 358 additions and 316 deletions
@@ -697,8 +697,7 @@ public class JetControlFlowProcessor {
JetSimpleNameExpression labelElement = expression.getTargetLabel(); JetSimpleNameExpression labelElement = expression.getTargetLabel();
JetElement subroutine; JetElement subroutine;
String labelName = expression.getLabelName(); String labelName = expression.getLabelName();
if (labelElement != null) { if (labelElement != null && labelName != null) {
assert labelName != null;
PsiElement labeledElement = trace.get(BindingContext.LABEL_TARGET, labelElement); PsiElement labeledElement = trace.get(BindingContext.LABEL_TARGET, labelElement);
if (labeledElement != null) { if (labeledElement != null) {
assert labeledElement instanceof JetElement; assert labeledElement instanceof JetElement;
@@ -1605,6 +1605,13 @@ public class JetExpressionParsing extends AbstractJetParsing {
*/ */
private void parseLabel() { private void parseLabel() {
assert _at(LABEL_IDENTIFIER); assert _at(LABEL_IDENTIFIER);
String labelText = myBuilder.getTokenText();
if ("@".equals(labelText)) {
errorAndAdvance("Label must be named");
return;
}
PsiBuilder.Marker labelWrap = mark(); PsiBuilder.Marker labelWrap = mark();
PsiBuilder.Marker mark = mark(); PsiBuilder.Marker mark = mark();
@@ -377,7 +377,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
String labelName = expression.getLabelName(); String labelName = expression.getLabelName();
if (labelName != null) { if (labelName != null) {
LabelResolver.LabeledReceiverResolutionResult resolutionResult = LabelResolver.LabeledReceiverResolutionResult resolutionResult =
LabelResolver.INSTANCE.resolveThisOrSuperLabel(expression, context, Name.identifierForLabel(labelName)); LabelResolver.INSTANCE.resolveThisOrSuperLabel(expression, context, Name.identifier(labelName));
if (onlyClassReceivers && resolutionResult.success()) { if (onlyClassReceivers && resolutionResult.success()) {
if (!isDeclaredInClass(resolutionResult.getReceiverParameterDescriptor())) { if (!isDeclaredInClass(resolutionResult.getReceiverParameterDescriptor())) {
return LabelResolver.LabeledReceiverResolutionResult.labelResolutionSuccess(NO_RECEIVER_PARAMETER); return LabelResolver.LabeledReceiverResolutionResult.labelResolutionSuccess(NO_RECEIVER_PARAMETER);
@@ -60,7 +60,10 @@ public class LabelResolver {
@Nullable @Nullable
private Name getLabelNameIfAny(@NotNull PsiElement element) { private Name getLabelNameIfAny(@NotNull PsiElement element) {
if (element instanceof JetLabeledExpression) { if (element instanceof JetLabeledExpression) {
return Name.identifierForLabel(((JetLabeledExpression) element).getLabelName()); String labelName = ((JetLabeledExpression) element).getLabelName();
if (labelName != null) {
return Name.identifier(labelName);
}
} }
if (element instanceof JetFunctionLiteralExpression) { if (element instanceof JetFunctionLiteralExpression) {
return getCallerName((JetFunctionLiteralExpression) element); return getCallerName((JetFunctionLiteralExpression) element);
@@ -121,7 +124,7 @@ public class LabelResolver {
String name = expression.getLabelName(); String name = expression.getLabelName();
if (labelElement == null || name == null) return null; if (labelElement == null || name == null) return null;
Name labelName = Name.identifierForLabel(name); Name labelName = Name.identifier(name);
Collection<DeclarationDescriptor> declarationsByLabel = context.scope.getDeclarationsByLabel(labelName); Collection<DeclarationDescriptor> declarationsByLabel = context.scope.getDeclarationsByLabel(labelName);
int size = declarationsByLabel.size(); int size = declarationsByLabel.size();
@@ -85,9 +85,9 @@ sink:
fun t3() { fun t3() {
try { try {
1 1
@{ () -> @l{ () ->
if (2 > 3) { if (2 > 3) {
return@ return@l
} }
} }
} finally { } finally {
@@ -97,70 +97,70 @@ fun t3() {
--------------------- ---------------------
L0: L0:
1 <START> 1 <START>
2 mark({ try { 1 @{ () -> if (2 > 3) { return@ } } } finally { 2 } }) 2 mark({ try { 1 @l{ () -> if (2 > 3) { return@l } } } finally { 2 } })
mark(try { 1 @{ () -> if (2 > 3) { return@ } } } finally { 2 }) mark(try { 1 @l{ () -> if (2 > 3) { return@l } } } finally { 2 })
jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 @{ () -> if (2 > 3) { return@ } } })] jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 @l{ () -> if (2 > 3) { return@l } } })]
3 mark({ 1 @{ () -> if (2 > 3) { return@ } } }) 3 mark({ 1 @l{ () -> if (2 > 3) { return@l } } })
r(1) r(1)
mark(@{ () -> if (2 > 3) { return@ } }) mark(@l{ () -> if (2 > 3) { return@l } })
mark({ () -> if (2 > 3) { return@ } }) mark({ () -> if (2 > 3) { return@l } })
jmp?(L3) NEXT:[r({ () -> if (2 > 3) { return@ } }), d({ () -> if (2 > 3) { return@ } })] jmp?(L3) NEXT:[r({ () -> if (2 > 3) { return@l } }), d({ () -> if (2 > 3) { return@l } })]
d({ () -> if (2 > 3) { return@ } }) NEXT:[<SINK>] d({ () -> if (2 > 3) { return@l } }) NEXT:[<SINK>]
L3: L3:
r({ () -> if (2 > 3) { return@ } }) PREV:[jmp?(L3)] r({ () -> if (2 > 3) { return@l } }) PREV:[jmp?(L3)]
2 jmp(L8 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })] 2 jmp(L8 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]: L2 [onExceptionToFinallyBlock]:
L9 [start finally]: L9 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])] 3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2) r(2)
L10 [finish finally]: L10 [finish finally]:
2 jmp(error) NEXT:[<ERROR>] 2 jmp(error) NEXT:[<ERROR>]
L8 [skipFinallyToErrorBlock]: L8 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L8 [skipFinallyToErrorBlock])] 3 mark({ 2 }) PREV:[jmp(L8 [skipFinallyToErrorBlock])]
r(2) r(2)
L1: L1:
1 <END> NEXT:[<SINK>] 1 <END> NEXT:[<SINK>]
error: error:
<ERROR> PREV:[jmp(error)] <ERROR> PREV:[jmp(error)]
sink: sink:
<SINK> PREV:[<ERROR>, <END>, d({ () -> if (2 > 3) { return@ } })] <SINK> PREV:[<ERROR>, <END>, d({ () -> if (2 > 3) { return@l } })]
===================== =====================
== anonymous_0 == == anonymous_0 ==
{ () -> { () ->
if (2 > 3) { if (2 > 3) {
return@ return@l
} }
} }
--------------------- ---------------------
L4: L4:
4 <START> 4 <START>
5 mark(if (2 > 3) { return@ }) 5 mark(if (2 > 3) { return@l })
mark(if (2 > 3) { return@ }) mark(if (2 > 3) { return@l })
mark(2 > 3) mark(2 > 3)
r(2) r(2)
r(3) r(3)
call(>, compareTo) call(>, compareTo)
jf(L6) NEXT:[read (Unit), mark({ return@ })] jf(L6) NEXT:[read (Unit), mark({ return@l })]
6 mark({ return@ }) 6 mark({ return@l })
ret L5 NEXT:[<END>] ret L5 NEXT:[<END>]
- 5 jmp(L7) NEXT:[<END>] PREV:[] - 5 jmp(L7) NEXT:[<END>] PREV:[]
L6: L6:
read (Unit) PREV:[jf(L6)] read (Unit) PREV:[jf(L6)]
L5: L5:
L7: L7:
4 <END> NEXT:[<SINK>] PREV:[ret L5, read (Unit)] 4 <END> NEXT:[<SINK>] PREV:[ret L5, read (Unit)]
error: error:
<ERROR> PREV:[] <ERROR> PREV:[]
sink: sink:
<SINK> PREV:[<ERROR>, <END>] <SINK> PREV:[<ERROR>, <END>]
===================== =====================
== t4 == == t4 ==
fun t4() { fun t4() {
@{ () -> @l{ () ->
try { try {
1 1
if (2 > 3) { if (2 > 3) {
return@ return@l
} }
} finally { } finally {
2 2
@@ -170,26 +170,26 @@ fun t4() {
--------------------- ---------------------
L0: L0:
1 <START> 1 <START>
2 mark({ @{ () -> try { 1 if (2 > 3) { return@ } } finally { 2 } } }) 2 mark({ @l{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } } })
mark(@{ () -> try { 1 if (2 > 3) { return@ } } finally { 2 } }) mark(@l{ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } })
mark({ () -> try { 1 if (2 > 3) { return@ } } finally { 2 } }) mark({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } })
jmp?(L2) NEXT:[r({ () -> try { 1 if (2 > 3) { return@ } } finally { 2 } }), d({ () -> try { 1 if (2 > 3) { return@ } } finally { 2 } })] jmp?(L2) NEXT:[r({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }), d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } })]
d({ () -> try { 1 if (2 > 3) { return@ } } finally { 2 } }) NEXT:[<SINK>] d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) NEXT:[<SINK>]
L2: L2:
r({ () -> try { 1 if (2 > 3) { return@ } } finally { 2 } }) PREV:[jmp?(L2)] r({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } }) PREV:[jmp?(L2)]
L1: L1:
1 <END> NEXT:[<SINK>] 1 <END> NEXT:[<SINK>]
error: error:
<ERROR> PREV:[] <ERROR> PREV:[]
sink: sink:
<SINK> PREV:[<ERROR>, <END>, d({ () -> try { 1 if (2 > 3) { return@ } } finally { 2 } })] <SINK> PREV:[<ERROR>, <END>, d({ () -> try { 1 if (2 > 3) { return@l } } finally { 2 } })]
===================== =====================
== anonymous_1 == == anonymous_1 ==
{ () -> { () ->
try { try {
1 1
if (2 > 3) { if (2 > 3) {
return@ return@l
} }
} finally { } finally {
2 2
@@ -198,49 +198,49 @@ sink:
--------------------- ---------------------
L3: L3:
3 <START> 3 <START>
4 mark(try { 1 if (2 > 3) { return@ } } finally { 2 }) 4 mark(try { 1 if (2 > 3) { return@l } } finally { 2 })
mark(try { 1 if (2 > 3) { return@ } } finally { 2 }) mark(try { 1 if (2 > 3) { return@l } } finally { 2 })
jmp?(L5 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { return@ } })] jmp?(L5 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { return@l } })]
5 mark({ 1 if (2 > 3) { return@ } }) 5 mark({ 1 if (2 > 3) { return@l } })
r(1) r(1)
mark(if (2 > 3) { return@ }) mark(if (2 > 3) { return@l })
mark(2 > 3) mark(2 > 3)
r(2) r(2)
r(3) r(3)
call(>, compareTo) call(>, compareTo)
jf(L6) NEXT:[read (Unit), mark({ return@ })] jf(L6) NEXT:[read (Unit), mark({ return@l })]
6 mark({ return@ }) 6 mark({ return@l })
L7 [start finally]: L7 [start finally]:
7 mark({ 2 }) 7 mark({ 2 })
r(2) r(2)
L8 [finish finally]: L8 [finish finally]:
6 ret L4 NEXT:[<END>] 6 ret L4 NEXT:[<END>]
- 5 jmp(L9) NEXT:[jmp(L10 [skipFinallyToErrorBlock])] PREV:[] - 5 jmp(L9) NEXT:[jmp(L10 [skipFinallyToErrorBlock])] PREV:[]
L6: L6:
read (Unit) PREV:[jf(L6)] read (Unit) PREV:[jf(L6)]
L9: L9:
4 jmp(L10 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })] 4 jmp(L10 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L5 [onExceptionToFinallyBlock]: L5 [onExceptionToFinallyBlock]:
7 mark({ 2 }) PREV:[jmp?(L5 [onExceptionToFinallyBlock])] 7 mark({ 2 }) PREV:[jmp?(L5 [onExceptionToFinallyBlock])]
r(2) r(2)
4 jmp(error) NEXT:[<ERROR>] 4 jmp(error) NEXT:[<ERROR>]
L10 [skipFinallyToErrorBlock]: L10 [skipFinallyToErrorBlock]:
7 mark({ 2 }) PREV:[jmp(L10 [skipFinallyToErrorBlock])] 7 mark({ 2 }) PREV:[jmp(L10 [skipFinallyToErrorBlock])]
r(2) r(2)
L4: L4:
3 <END> NEXT:[<SINK>] PREV:[ret L4, r(2)] 3 <END> NEXT:[<SINK>] PREV:[ret L4, r(2)]
error: error:
<ERROR> PREV:[jmp(error)] <ERROR> PREV:[jmp(error)]
sink: sink:
<SINK> PREV:[<ERROR>, <END>] <SINK> PREV:[<ERROR>, <END>]
===================== =====================
== t5 == == t5 ==
fun t5() { fun t5() {
@ while(true) { @l while(true) {
try { try {
1 1
if (2 > 3) { if (2 > 3) {
break @ break @l
} }
} finally { } finally {
2 2
@@ -250,59 +250,59 @@ fun t5() {
--------------------- ---------------------
L0: L0:
1 <START> 1 <START>
2 mark({ @ while(true) { try { 1 if (2 > 3) { break @ } } finally { 2 } } }) 2 mark({ @l while(true) { try { 1 if (2 > 3) { break @l } } finally { 2 } } })
mark(@ while(true) { try { 1 if (2 > 3) { break @ } } finally { 2 } }) mark(@l while(true) { try { 1 if (2 > 3) { break @l } } finally { 2 } })
mark(while(true) { try { 1 if (2 > 3) { break @ } } finally { 2 } }) mark(while(true) { try { 1 if (2 > 3) { break @l } } finally { 2 } })
L2 [loop entry point]: L2 [loop entry point]:
L5 [condition entry point]: L5 [condition entry point]:
r(true) PREV:[mark(while(true) { try { 1 if (2 > 3) { break @ } } finally { 2 } }), jmp(L2 [loop entry point])] r(true) PREV:[mark(while(true) { try { 1 if (2 > 3) { break @l } } finally { 2 } }), jmp(L2 [loop entry point])]
L4 [body entry point]: L4 [body entry point]:
3 mark({ try { 1 if (2 > 3) { break @ } } finally { 2 } }) 3 mark({ try { 1 if (2 > 3) { break @l } } finally { 2 } })
mark(try { 1 if (2 > 3) { break @ } } finally { 2 }) mark(try { 1 if (2 > 3) { break @l } } finally { 2 })
jmp?(L6 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { break @ } })] jmp?(L6 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { break @l } })]
4 mark({ 1 if (2 > 3) { break @ } }) 4 mark({ 1 if (2 > 3) { break @l } })
r(1) r(1)
mark(if (2 > 3) { break @ }) mark(if (2 > 3) { break @l })
mark(2 > 3) mark(2 > 3)
r(2) r(2)
r(3) r(3)
call(>, compareTo) call(>, compareTo)
jf(L7) NEXT:[read (Unit), mark({ break @ })] jf(L7) NEXT:[read (Unit), mark({ break @l })]
5 mark({ break @ }) 5 mark({ break @l })
L8 [start finally]: L8 [start finally]:
6 mark({ 2 }) 6 mark({ 2 })
r(2) r(2)
L9 [finish finally]: L9 [finish finally]:
5 jmp(L3 [loop exit point]) NEXT:[read (Unit)] 5 jmp(L3 [loop exit point]) NEXT:[read (Unit)]
- 4 jmp(L10) NEXT:[jmp(L11 [skipFinallyToErrorBlock])] PREV:[] - 4 jmp(L10) NEXT:[jmp(L11 [skipFinallyToErrorBlock])] PREV:[]
L7: L7:
read (Unit) PREV:[jf(L7)] read (Unit) PREV:[jf(L7)]
L10: L10:
3 jmp(L11 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })] 3 jmp(L11 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L6 [onExceptionToFinallyBlock]: L6 [onExceptionToFinallyBlock]:
6 mark({ 2 }) PREV:[jmp?(L6 [onExceptionToFinallyBlock])] 6 mark({ 2 }) PREV:[jmp?(L6 [onExceptionToFinallyBlock])]
r(2) r(2)
3 jmp(error) NEXT:[<ERROR>] 3 jmp(error) NEXT:[<ERROR>]
L11 [skipFinallyToErrorBlock]: L11 [skipFinallyToErrorBlock]:
6 mark({ 2 }) PREV:[jmp(L11 [skipFinallyToErrorBlock])] 6 mark({ 2 }) PREV:[jmp(L11 [skipFinallyToErrorBlock])]
r(2) r(2)
2 jmp(L2 [loop entry point]) NEXT:[r(true)] 2 jmp(L2 [loop entry point]) NEXT:[r(true)]
L3 [loop exit point]: L3 [loop exit point]:
read (Unit) PREV:[jmp(L3 [loop exit point])] read (Unit) PREV:[jmp(L3 [loop exit point])]
L1: L1:
1 <END> NEXT:[<SINK>] 1 <END> NEXT:[<SINK>]
error: error:
<ERROR> PREV:[jmp(error)] <ERROR> PREV:[jmp(error)]
sink: sink:
<SINK> PREV:[<ERROR>, <END>] <SINK> PREV:[<ERROR>, <END>]
===================== =====================
== t6 == == t6 ==
fun t6() { fun t6() {
try { try {
@ while(true) { @l while(true) {
1 1
if (2 > 3) { if (2 > 3) {
break @ break @l
} }
} }
5 5
@@ -313,25 +313,86 @@ fun t6() {
--------------------- ---------------------
L0: L0:
1 <START> 1 <START>
2 mark({ try { @ while(true) { 1 if (2 > 3) { break @ } } 5 } finally { 2 } }) 2 mark({ try { @l while(true) { 1 if (2 > 3) { break @l } } 5 } finally { 2 } })
mark(try { @ while(true) { 1 if (2 > 3) { break @ } } 5 } finally { 2 }) mark(try { @l while(true) { 1 if (2 > 3) { break @l } } 5 } finally { 2 })
jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ @ while(true) { 1 if (2 > 3) { break @ } } 5 })] jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ @l while(true) { 1 if (2 > 3) { break @l } } 5 })]
3 mark({ @ while(true) { 1 if (2 > 3) { break @ } } 5 }) 3 mark({ @l while(true) { 1 if (2 > 3) { break @l } } 5 })
mark(@ while(true) { 1 if (2 > 3) { break @ } }) mark(@l while(true) { 1 if (2 > 3) { break @l } })
mark(while(true) { 1 if (2 > 3) { break @ } }) mark(while(true) { 1 if (2 > 3) { break @l } })
L3 [loop entry point]: L3 [loop entry point]:
L6 [condition entry point]: L6 [condition entry point]:
r(true) PREV:[mark(while(true) { 1 if (2 > 3) { break @ } }), jmp(L3 [loop entry point])] r(true) PREV:[mark(while(true) { 1 if (2 > 3) { break @l } }), jmp(L3 [loop entry point])]
L5 [body entry point]: L5 [body entry point]:
4 mark({ 1 if (2 > 3) { break @ } }) 4 mark({ 1 if (2 > 3) { break @l } })
r(1) r(1)
mark(if (2 > 3) { break @ }) mark(if (2 > 3) { break @l })
mark(2 > 3) mark(2 > 3)
r(2) r(2)
r(3) r(3)
call(>, compareTo) call(>, compareTo)
jf(L7) NEXT:[read (Unit), mark({ break @ })] jf(L7) NEXT:[read (Unit), mark({ break @l })]
5 mark({ break @ }) 5 mark({ break @l })
jmp(L4 [loop exit point]) NEXT:[read (Unit)]
- 4 jmp(L8) NEXT:[jmp(L3 [loop entry point])] PREV:[]
L7:
read (Unit) PREV:[jf(L7)]
L8:
3 jmp(L3 [loop entry point]) NEXT:[r(true)]
L4 [loop exit point]:
read (Unit) PREV:[jmp(L4 [loop exit point])]
r(5)
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]:
L10 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2)
L11 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L9 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L9 [skipFinallyToErrorBlock])]
r(2)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== t7 ==
fun t7() {
try {
@l while(true) {
1
if (2 > 3) {
break @l
}
}
} finally {
2
}
}
---------------------
L0:
1 <START>
2 mark({ try { @l while(true) { 1 if (2 > 3) { break @l } } } finally { 2 } })
mark(try { @l while(true) { 1 if (2 > 3) { break @l } } } finally { 2 })
jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ @l while(true) { 1 if (2 > 3) { break @l } } })]
3 mark({ @l while(true) { 1 if (2 > 3) { break @l } } })
mark(@l while(true) { 1 if (2 > 3) { break @l } })
mark(while(true) { 1 if (2 > 3) { break @l } })
L3 [loop entry point]:
L6 [condition entry point]:
r(true) PREV:[mark(while(true) { 1 if (2 > 3) { break @l } }), jmp(L3 [loop entry point])]
L5 [body entry point]:
4 mark({ 1 if (2 > 3) { break @l } })
r(1)
mark(if (2 > 3) { break @l })
mark(2 > 3)
r(2)
r(3)
call(>, compareTo)
jf(L7) NEXT:[read (Unit), mark({ break @l })]
5 mark({ break @l })
jmp(L4 [loop exit point]) NEXT:[read (Unit)] jmp(L4 [loop exit point]) NEXT:[read (Unit)]
- 4 jmp(L8) NEXT:[jmp(L3 [loop entry point])] PREV:[] - 4 jmp(L8) NEXT:[jmp(L3 [loop entry point])] PREV:[]
L7: L7:
@@ -340,7 +401,6 @@ L8:
3 jmp(L3 [loop entry point]) NEXT:[r(true)] 3 jmp(L3 [loop entry point]) NEXT:[r(true)]
L4 [loop exit point]: L4 [loop exit point]:
read (Unit) PREV:[jmp(L4 [loop exit point])] read (Unit) PREV:[jmp(L4 [loop exit point])]
r(5)
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })] 2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]: L2 [onExceptionToFinallyBlock]:
L10 [start finally]: L10 [start finally]:
@@ -358,73 +418,13 @@ error:
sink: sink:
<SINK> PREV:[<ERROR>, <END>] <SINK> PREV:[<ERROR>, <END>]
===================== =====================
== t7 ==
fun t7() {
try {
@ while(true) {
1
if (2 > 3) {
break @
}
}
} finally {
2
}
}
---------------------
L0:
1 <START>
2 mark({ try { @ while(true) { 1 if (2 > 3) { break @ } } } finally { 2 } })
mark(try { @ while(true) { 1 if (2 > 3) { break @ } } } finally { 2 })
jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ @ while(true) { 1 if (2 > 3) { break @ } } })]
3 mark({ @ while(true) { 1 if (2 > 3) { break @ } } })
mark(@ while(true) { 1 if (2 > 3) { break @ } })
mark(while(true) { 1 if (2 > 3) { break @ } })
L3 [loop entry point]:
L6 [condition entry point]:
r(true) PREV:[mark(while(true) { 1 if (2 > 3) { break @ } }), jmp(L3 [loop entry point])]
L5 [body entry point]:
4 mark({ 1 if (2 > 3) { break @ } })
r(1)
mark(if (2 > 3) { break @ })
mark(2 > 3)
r(2)
r(3)
call(>, compareTo)
jf(L7) NEXT:[read (Unit), mark({ break @ })]
5 mark({ break @ })
jmp(L4 [loop exit point]) NEXT:[read (Unit)]
- 4 jmp(L8) NEXT:[jmp(L3 [loop entry point])] PREV:[]
L7:
read (Unit) PREV:[jf(L7)]
L8:
3 jmp(L3 [loop entry point]) NEXT:[r(true)]
L4 [loop exit point]:
read (Unit) PREV:[jmp(L4 [loop exit point])]
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]:
L10 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2)
L11 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L9 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L9 [skipFinallyToErrorBlock])]
r(2)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== t8 == == t8 ==
fun t8(a : Int) { fun t8(a : Int) {
@ for (i in 1..a) { @l for (i in 1..a) {
try { try {
1 1
if (2 > 3) { if (2 > 3) {
continue @ continue @l
} }
} finally { } finally {
2 2
@@ -436,65 +436,65 @@ L0:
1 <START> 1 <START>
v(a : Int) v(a : Int)
w(a) w(a)
2 mark({ @ for (i in 1..a) { try { 1 if (2 > 3) { continue @ } } finally { 2 } } }) 2 mark({ @l for (i in 1..a) { try { 1 if (2 > 3) { continue @l } } finally { 2 } } })
mark(@ for (i in 1..a) { try { 1 if (2 > 3) { continue @ } } finally { 2 } }) mark(@l for (i in 1..a) { try { 1 if (2 > 3) { continue @l } } finally { 2 } })
3 mark(for (i in 1..a) { try { 1 if (2 > 3) { continue @ } } finally { 2 } }) 3 mark(for (i in 1..a) { try { 1 if (2 > 3) { continue @l } } finally { 2 } })
mark(1..a) mark(1..a)
r(1) r(1)
r(a) r(a)
call(.., rangeTo) call(.., rangeTo)
v(i) v(i)
L3: L3:
jmp?(L2) NEXT:[read (Unit), w(i)] jmp?(L2) NEXT:[read (Unit), w(i)]
L4 [loop entry point]: L4 [loop entry point]:
L5 [body entry point]: L5 [body entry point]:
w(i) PREV:[jmp?(L2), jmp(L4 [loop entry point]), jmp?(L4 [loop entry point])] w(i) PREV:[jmp?(L2), jmp(L4 [loop entry point]), jmp?(L4 [loop entry point])]
4 mark({ try { 1 if (2 > 3) { continue @ } } finally { 2 } }) 4 mark({ try { 1 if (2 > 3) { continue @l } } finally { 2 } })
mark(try { 1 if (2 > 3) { continue @ } } finally { 2 }) mark(try { 1 if (2 > 3) { continue @l } } finally { 2 })
jmp?(L6 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { continue @ } })] jmp?(L6 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ 1 if (2 > 3) { continue @l } })]
5 mark({ 1 if (2 > 3) { continue @ } }) 5 mark({ 1 if (2 > 3) { continue @l } })
r(1) r(1)
mark(if (2 > 3) { continue @ }) mark(if (2 > 3) { continue @l })
mark(2 > 3) mark(2 > 3)
r(2) r(2)
r(3) r(3)
call(>, compareTo) call(>, compareTo)
jf(L7) NEXT:[read (Unit), mark({ continue @ })] jf(L7) NEXT:[read (Unit), mark({ continue @l })]
6 mark({ continue @ }) 6 mark({ continue @l })
L8 [start finally]: L8 [start finally]:
7 mark({ 2 }) 7 mark({ 2 })
r(2) r(2)
L9 [finish finally]: L9 [finish finally]:
6 jmp(L4 [loop entry point]) NEXT:[w(i)] 6 jmp(L4 [loop entry point]) NEXT:[w(i)]
- 5 jmp(L10) NEXT:[jmp(L11 [skipFinallyToErrorBlock])] PREV:[] - 5 jmp(L10) NEXT:[jmp(L11 [skipFinallyToErrorBlock])] PREV:[]
L7: L7:
read (Unit) PREV:[jf(L7)] read (Unit) PREV:[jf(L7)]
L10: L10:
4 jmp(L11 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })] 4 jmp(L11 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L6 [onExceptionToFinallyBlock]: L6 [onExceptionToFinallyBlock]:
7 mark({ 2 }) PREV:[jmp?(L6 [onExceptionToFinallyBlock])] 7 mark({ 2 }) PREV:[jmp?(L6 [onExceptionToFinallyBlock])]
r(2) r(2)
4 jmp(error) NEXT:[<ERROR>] 4 jmp(error) NEXT:[<ERROR>]
L11 [skipFinallyToErrorBlock]: L11 [skipFinallyToErrorBlock]:
7 mark({ 2 }) PREV:[jmp(L11 [skipFinallyToErrorBlock])] 7 mark({ 2 }) PREV:[jmp(L11 [skipFinallyToErrorBlock])]
r(2) r(2)
3 jmp?(L4 [loop entry point]) NEXT:[w(i), read (Unit)] 3 jmp?(L4 [loop entry point]) NEXT:[w(i), read (Unit)]
L2: L2:
read (Unit) PREV:[jmp?(L2), jmp?(L4 [loop entry point])] read (Unit) PREV:[jmp?(L2), jmp?(L4 [loop entry point])]
L1: L1:
1 <END> NEXT:[<SINK>] 1 <END> NEXT:[<SINK>]
error: error:
<ERROR> PREV:[jmp(error)] <ERROR> PREV:[jmp(error)]
sink: sink:
<SINK> PREV:[<ERROR>, <END>] <SINK> PREV:[<ERROR>, <END>]
===================== =====================
== t9 == == t9 ==
fun t9(a : Int) { fun t9(a : Int) {
try { try {
@ for (i in 1..a) { @l for (i in 1..a) {
1 1
if (2 > 3) { if (2 > 3) {
continue @ continue @l
} }
} }
5 5
@@ -507,12 +507,81 @@ L0:
1 <START> 1 <START>
v(a : Int) v(a : Int)
w(a) w(a)
2 mark({ try { @ for (i in 1..a) { 1 if (2 > 3) { continue @ } } 5 } finally { 2 } }) 2 mark({ try { @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } 5 } finally { 2 } })
mark(try { @ for (i in 1..a) { 1 if (2 > 3) { continue @ } } 5 } finally { 2 }) mark(try { @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } 5 } finally { 2 })
jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ @ for (i in 1..a) { 1 if (2 > 3) { continue @ } } 5 })] jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } 5 })]
3 mark({ @ for (i in 1..a) { 1 if (2 > 3) { continue @ } } 5 }) 3 mark({ @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } 5 })
mark(@ for (i in 1..a) { 1 if (2 > 3) { continue @ } }) mark(@l for (i in 1..a) { 1 if (2 > 3) { continue @l } })
4 mark(for (i in 1..a) { 1 if (2 > 3) { continue @ } }) 4 mark(for (i in 1..a) { 1 if (2 > 3) { continue @l } })
mark(1..a)
r(1)
r(a)
call(.., rangeTo)
v(i)
L4:
jmp?(L3) NEXT:[read (Unit), w(i)]
L5 [loop entry point]:
L6 [body entry point]:
w(i) PREV:[jmp?(L3), jmp(L5 [loop entry point]), jmp?(L5 [loop entry point])]
5 mark({ 1 if (2 > 3) { continue @l } })
r(1)
mark(if (2 > 3) { continue @l })
mark(2 > 3)
r(2)
r(3)
call(>, compareTo)
jf(L7) NEXT:[read (Unit), mark({ continue @l })]
6 mark({ continue @l })
jmp(L5 [loop entry point]) NEXT:[w(i)]
- 5 jmp(L8) NEXT:[jmp?(L5 [loop entry point])] PREV:[]
L7:
read (Unit) PREV:[jf(L7)]
L8:
4 jmp?(L5 [loop entry point]) NEXT:[w(i), read (Unit)]
L3:
read (Unit) PREV:[jmp?(L3), jmp?(L5 [loop entry point])]
3 r(5)
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]:
L10 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2)
L11 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L9 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L9 [skipFinallyToErrorBlock])]
r(2)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== t10 ==
fun t10(a : Int) {
try {
@l for (i in 1..a) {
1
if (2 > 3) {
continue @l
}
}
} finally {
2
}
}
---------------------
L0:
1 <START>
v(a : Int)
w(a)
2 mark({ try { @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } } finally { 2 } })
mark(try { @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } } finally { 2 })
jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } })]
3 mark({ @l for (i in 1..a) { 1 if (2 > 3) { continue @l } } })
mark(@l for (i in 1..a) { 1 if (2 > 3) { continue @l } })
4 mark(for (i in 1..a) { 1 if (2 > 3) { continue @l } })
mark(1..a) mark(1..a)
r(1) r(1)
r(a) r(a)
@@ -523,15 +592,15 @@ L4:
L5 [loop entry point]: L5 [loop entry point]:
L6 [body entry point]: L6 [body entry point]:
w(i) PREV:[jmp?(L3), jmp(L5 [loop entry point]), jmp?(L5 [loop entry point])] w(i) PREV:[jmp?(L3), jmp(L5 [loop entry point]), jmp?(L5 [loop entry point])]
5 mark({ 1 if (2 > 3) { continue @ } }) 5 mark({ 1 if (2 > 3) { continue @l } })
r(1) r(1)
mark(if (2 > 3) { continue @ }) mark(if (2 > 3) { continue @l })
mark(2 > 3) mark(2 > 3)
r(2) r(2)
r(3) r(3)
call(>, compareTo) call(>, compareTo)
jf(L7) NEXT:[read (Unit), mark({ continue @ })] jf(L7) NEXT:[read (Unit), mark({ continue @l })]
6 mark({ continue @ }) 6 mark({ continue @l })
jmp(L5 [loop entry point]) NEXT:[w(i)] jmp(L5 [loop entry point]) NEXT:[w(i)]
- 5 jmp(L8) NEXT:[jmp?(L5 [loop entry point])] PREV:[] - 5 jmp(L8) NEXT:[jmp?(L5 [loop entry point])] PREV:[]
L7: L7:
@@ -540,7 +609,6 @@ L8:
4 jmp?(L5 [loop entry point]) NEXT:[w(i), read (Unit)] 4 jmp?(L5 [loop entry point]) NEXT:[w(i), read (Unit)]
L3: L3:
read (Unit) PREV:[jmp?(L3), jmp?(L5 [loop entry point])] read (Unit) PREV:[jmp?(L3), jmp?(L5 [loop entry point])]
3 r(5)
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })] 2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]: L2 [onExceptionToFinallyBlock]:
L10 [start finally]: L10 [start finally]:
@@ -558,74 +626,6 @@ error:
sink: sink:
<SINK> PREV:[<ERROR>, <END>] <SINK> PREV:[<ERROR>, <END>]
===================== =====================
== t10 ==
fun t10(a : Int) {
try {
@ for (i in 1..a) {
1
if (2 > 3) {
continue @
}
}
} finally {
2
}
}
---------------------
L0:
1 <START>
v(a : Int)
w(a)
2 mark({ try { @ for (i in 1..a) { 1 if (2 > 3) { continue @ } } } finally { 2 } })
mark(try { @ for (i in 1..a) { 1 if (2 > 3) { continue @ } } } finally { 2 })
jmp?(L2 [onExceptionToFinallyBlock]) NEXT:[mark({ 2 }), mark({ @ for (i in 1..a) { 1 if (2 > 3) { continue @ } } })]
3 mark({ @ for (i in 1..a) { 1 if (2 > 3) { continue @ } } })
mark(@ for (i in 1..a) { 1 if (2 > 3) { continue @ } })
4 mark(for (i in 1..a) { 1 if (2 > 3) { continue @ } })
mark(1..a)
r(1)
r(a)
call(.., rangeTo)
v(i)
L4:
jmp?(L3) NEXT:[read (Unit), w(i)]
L5 [loop entry point]:
L6 [body entry point]:
w(i) PREV:[jmp?(L3), jmp(L5 [loop entry point]), jmp?(L5 [loop entry point])]
5 mark({ 1 if (2 > 3) { continue @ } })
r(1)
mark(if (2 > 3) { continue @ })
mark(2 > 3)
r(2)
r(3)
call(>, compareTo)
jf(L7) NEXT:[read (Unit), mark({ continue @ })]
6 mark({ continue @ })
jmp(L5 [loop entry point]) NEXT:[w(i)]
- 5 jmp(L8) NEXT:[jmp?(L5 [loop entry point])] PREV:[]
L7:
read (Unit) PREV:[jf(L7)]
L8:
4 jmp?(L5 [loop entry point]) NEXT:[w(i), read (Unit)]
L3:
read (Unit) PREV:[jmp?(L3), jmp?(L5 [loop entry point])]
2 jmp(L9 [skipFinallyToErrorBlock]) NEXT:[mark({ 2 })]
L2 [onExceptionToFinallyBlock]:
L10 [start finally]:
3 mark({ 2 }) PREV:[jmp?(L2 [onExceptionToFinallyBlock])]
r(2)
L11 [finish finally]:
2 jmp(error) NEXT:[<ERROR>]
L9 [skipFinallyToErrorBlock]:
3 mark({ 2 }) PREV:[jmp(L9 [skipFinallyToErrorBlock])]
r(2)
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[jmp(error)]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== t11 == == t11 ==
fun t11() { fun t11() {
try { try {
@@ -20,9 +20,9 @@ fun t2() {
fun t3() { fun t3() {
try { try {
1 1
@{ () -> @l{ () ->
if (2 > 3) { if (2 > 3) {
return@ return@l
} }
} }
} finally { } finally {
@@ -31,11 +31,11 @@ fun t3() {
} }
fun t4() { fun t4() {
@{ () -> @l{ () ->
try { try {
1 1
if (2 > 3) { if (2 > 3) {
return@ return@l
} }
} finally { } finally {
2 2
@@ -44,11 +44,11 @@ fun t4() {
} }
fun t5() { fun t5() {
@ while(true) { @l while(true) {
try { try {
1 1
if (2 > 3) { if (2 > 3) {
break @ break @l
} }
} finally { } finally {
2 2
@@ -58,10 +58,10 @@ fun t5() {
fun t6() { fun t6() {
try { try {
@ while(true) { @l while(true) {
1 1
if (2 > 3) { if (2 > 3) {
break @ break @l
} }
} }
5 5
@@ -72,10 +72,10 @@ fun t6() {
fun t7() { fun t7() {
try { try {
@ while(true) { @l while(true) {
1 1
if (2 > 3) { if (2 > 3) {
break @ break @l
} }
} }
} finally { } finally {
@@ -84,11 +84,11 @@ fun t7() {
} }
fun t8(a : Int) { fun t8(a : Int) {
@ for (i in 1..a) { @l for (i in 1..a) {
try { try {
1 1
if (2 > 3) { if (2 > 3) {
continue @ continue @l
} }
} finally { } finally {
2 2
@@ -98,10 +98,10 @@ fun t8(a : Int) {
fun t9(a : Int) { fun t9(a : Int) {
try { try {
@ for (i in 1..a) { @l for (i in 1..a) {
1 1
if (2 > 3) { if (2 > 3) {
continue @ continue @l
} }
} }
5 5
@@ -112,10 +112,10 @@ fun t9(a : Int) {
fun t10(a : Int) { fun t10(a : Int) {
try { try {
@ for (i in 1..a) { @l for (i in 1..a) {
1 1
if (2 > 3) { if (2 > 3) {
continue @ continue @l
} }
} }
} finally { } finally {
@@ -65,9 +65,9 @@ class C {
} }
fun containsBreakInsideLoopWithLabel(a: String?, array: Array<Int>) { fun containsBreakInsideLoopWithLabel(a: String?, array: Array<Int>) {
@ while(a == null) { @l while(a == null) {
for (el in array) { for (el in array) {
break@ break@l
} }
} }
a<!UNSAFE_CALL!>.<!>compareTo("2") a<!UNSAFE_CALL!>.<!>compareTo("2")
@@ -75,10 +75,10 @@ class C {
fun unresolvedBreak(a: String?, array: Array<Int>) { fun unresolvedBreak(a: String?, array: Array<Int>) {
while(a == null) { while(a == null) {
@ for (el in array) { @l for (el in array) {
break break
} }
if (true) break else <!NOT_A_LOOP_LABEL!>break<!UNRESOLVED_REFERENCE!>@<!><!> if (true) break else <!NOT_A_LOOP_LABEL!>break<!UNRESOLVED_REFERENCE!>@l<!><!>
} }
a<!UNSAFE_CALL!>.<!>compareTo("2") a<!UNSAFE_CALL!>.<!>compareTo("2")
} }
@@ -9,7 +9,7 @@ fun test1() : Any = {<!RETURN_NOT_ALLOWED, RETURN_TYPE_MISMATCH!>return<!>}
fun test2() : Any = @a {<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@a 1<!>} fun test2() : Any = @a {<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@a 1<!>}
fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> } fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> }
fun test4(): ()-> Unit = { <!RETURN_NOT_ALLOWED, RETURN_TYPE_MISMATCH!>return@test4<!> } fun test4(): ()-> Unit = { <!RETURN_NOT_ALLOWED, RETURN_TYPE_MISMATCH!>return@test4<!> }
fun test5(): Any = @{ <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@<!> } fun test5(): Any = @l{ <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@l<!> }
fun test6(): Any = {<!RETURN_NOT_ALLOWED!>return 1<!>} fun test6(): Any = {<!RETURN_NOT_ALLOWED!>return 1<!>}
fun bbb() { fun bbb() {
@@ -60,7 +60,7 @@ fun canBe(i0: Int, j: Int) {
(@label j) = <!UNUSED_VALUE!>34<!> //repeat for j (@label j) = <!UNUSED_VALUE!>34<!> //repeat for j
val a = A() val a = A()
(@ a.a) = 3894 (@l a.a) = 3894
} }
fun canBe2(j: Int) { fun canBe2(j: Int) {
@@ -108,7 +108,7 @@ class Test() {
<!VAL_REASSIGNMENT!>b<!> += 34 <!VAL_REASSIGNMENT!>b<!> += 34
a++ a++
(@ a)++ (@l a)++
(a : Int)++ (a : Int)++
<!UNUSED_CHANGED_VALUE!>(a)++<!> <!UNUSED_CHANGED_VALUE!>(a)++<!>
} }
@@ -5,7 +5,7 @@ fun test() {
fun test1() { fun test1() {
val x = run(@{<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@ 1<!>}) val x = run(@l{<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@l 1<!>})
x: Int x: Int
} }
@@ -0,0 +1,36 @@
fun foo(a: Any?): Int {
<!SYNTAX!>@<!>{ () : Unit ->
return<!SYNTAX!>@<!>
}
<!SYNTAX!>@<!> while(a == null) {
if (true) {
break<!SYNTAX!>@<!>
}
else {
continue<!SYNTAX!>@<!>
}
}
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>b<!> = 1
(<!SYNTAX!>@<!> b) = <!UNUSED_VALUE!>2<!>
return<!SYNTAX!>@<!> 1
}
open class A {
fun foo() {}
}
class B : A() {
fun bar() {
this<!SYNTAX!>@<!>.foo()
super<!SYNTAX!>@<!>.foo()
}
}
fun bar(f: () -> Unit) = f
fun test() {
bar <!SYNTAX!>@<!>{}
}
@@ -9,8 +9,7 @@ fun main(args : Array<String>) {
val <!UNUSED_VARIABLE!>h1<!> : String = <!TYPE_MISMATCH!>--v<!>; val <!UNUSED_VARIABLE!>h1<!> : String = <!TYPE_MISMATCH!>--v<!>;
val <!UNUSED_VARIABLE!>i<!> : String = <!TYPE_MISMATCH!>!true<!>; val <!UNUSED_VARIABLE!>i<!> : String = <!TYPE_MISMATCH!>!true<!>;
val <!UNUSED_VARIABLE!>j<!> : String = @foo <!CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!>; val <!UNUSED_VARIABLE!>j<!> : String = @foo <!CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!>;
val <!UNUSED_VARIABLE!>j1<!> : String = @ <!CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!>; val <!UNUSED_VARIABLE!>k<!> : String = @foo @bar <!CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!>;
val <!UNUSED_VARIABLE!>j2<!> : String = @@ <!CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!>; val <!UNUSED_VARIABLE!>l<!> : String = <!TYPE_MISMATCH!>-1<!>;
val <!UNUSED_VARIABLE!>k<!> : String = <!TYPE_MISMATCH!>-1<!>; val <!UNUSED_VARIABLE!>m<!> : String = <!TYPE_MISMATCH!>+1<!>;
val <!UNUSED_VARIABLE!>l<!> : String = <!TYPE_MISMATCH!>+1<!>;
} }
@@ -4,8 +4,8 @@ package kt411
fun f() { fun f() {
invoker( invoker(
@{ @l{
<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@ 11<!> // expects Function, but should expect Int <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@l 11<!> // expects Function, but should expect Int
} }
) )
} }
@@ -13,15 +13,15 @@ fun invoker(<!UNUSED_PARAMETER!>gen<!> : () -> Int) : Int = 0
//more tests //more tests
fun t1() { fun t1() {
val <!UNUSED_VARIABLE!>v<!> = @{ () : Int -> val <!UNUSED_VARIABLE!>v<!> = @l{ () : Int ->
return@ 111 return@l 111
} }
} }
fun t2() : String { fun t2() : String {
val <!UNUSED_VARIABLE!>g<!> : ()-> Int = @{ val <!UNUSED_VARIABLE!>g<!> : ()-> Int = @l{
if (true) { if (true) {
<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@ 1<!> <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@l 1<!>
} }
<!RETURN_NOT_ALLOWED!>return "s"<!> <!RETURN_NOT_ALLOWED!>return "s"<!>
} }
@@ -30,19 +30,19 @@ fun t2() : String {
fun t3() : String { fun t3() : String {
invoker( invoker(
@{ @l{
if (true) { if (true) {
<!RETURN_NOT_ALLOWED!>return@t3 "1"<!> <!RETURN_NOT_ALLOWED!>return@t3 "1"<!>
} }
else { else {
<!RETURN_NOT_ALLOWED!>return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!><!> <!RETURN_NOT_ALLOWED!>return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!><!>
} }
<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@ 0<!> <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@l 0<!>
} }
) )
invoker( invoker(
@{ (): Int -> @l{ (): Int ->
return@ 1 return@l 1
} }
) )
invoker( invoker(
@@ -57,8 +57,8 @@ fun t4() : Int {
val <!UNUSED_VARIABLE!>h<!> : ()-> String = @l{ val <!UNUSED_VARIABLE!>h<!> : ()-> String = @l{
<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@l "a"<!> <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@l "a"<!>
} }
val <!UNUSED_VARIABLE!>g<!> : ()-> String = @{ () : String -> val <!UNUSED_VARIABLE!>g<!> : ()-> String = @l{ () : String ->
return@ "a" return@l "a"
} }
fun inner(): String { fun inner(): String {
@@ -4656,6 +4656,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest("compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.kt"); doTest("compiler/testData/diagnostics/tests/labels/labelReferencesInsideObjectExpressions.kt");
} }
@TestMetadata("labelsMustBeNamed.kt")
public void testLabelsMustBeNamed() throws Exception {
doTest("compiler/testData/diagnostics/tests/labels/labelsMustBeNamed.kt");
}
} }
@TestMetadata("compiler/testData/diagnostics/tests/library") @TestMetadata("compiler/testData/diagnostics/tests/library")
@@ -68,13 +68,6 @@ public final class Name implements Comparable<Name> {
return new Name(name, false); return new Name(name, false);
} }
@NotNull
public static Name identifierForLabel(@NotNull String name) {
// might be empty ('@' label)
if (name.isEmpty()) return identifierNoValidate(name);
return identifier(name);
}
@NotNull @NotNull
public static Name special(@NotNull String name) { public static Name special(@NotNull String name) {
if (!name.startsWith("<")) { if (!name.startsWith("<")) {