KT-22274 report warning on labels that can't be referenced

Labels are meaningful only if they can be referenced by 'break',
'continue', or 'return' expressions.
This commit is contained in:
Dmitry Petrov
2018-07-24 15:58:10 +03:00
parent 6fb913a463
commit df6d4f358a
28 changed files with 127 additions and 42 deletions
+4 -4
View File
@@ -24,17 +24,17 @@ inline fun foo(bar1: (String.() -> Int) -> Int, bar2: (()->Int) -> Int) {
}
inline fun foo2(bar1: (String.() -> Int) -> Int) {
l1@ <!USAGE_IS_NOT_INLINABLE!>bar1<!>
<!REDUNDANT_LABEL_WARNING!>l1@<!> <!USAGE_IS_NOT_INLINABLE!>bar1<!>
l2@ bar1 {
<!REDUNDANT_LABEL_WARNING!>l2@<!> bar1 {
11
}
(l3@ bar1) {
(<!REDUNDANT_LABEL_WARNING!>l3@<!> bar1) {
11
}
(l5@ (l4@ bar1)) {
(<!REDUNDANT_LABEL_WARNING!>l5@<!> (<!REDUNDANT_LABEL_WARNING!>l4@<!> bar1)) {
11
}
}
@@ -22,6 +22,6 @@ inline fun inlineFunWithInvoke2(s: (p: Int) -> Unit) {
}
inline fun propagation(s: (p: Int) -> Unit) {
inlineFunWithInvoke((label@ s))
inlineFunWithInvoke((label2@ label@ s))
inlineFunWithInvoke((<!REDUNDANT_LABEL_WARNING!>label@<!> s))
inlineFunWithInvoke((<!REDUNDANT_LABEL_WARNING!>label2@<!> <!REDUNDANT_LABEL_WARNING!>label@<!> s))
}