Skip to content

Commit a41d863

Browse files
committed
fix incorrect missing return annotations on switch case with capture variables
1 parent 0574aef commit a41d863

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/main/java/com/intellij/plugins/haxe/ide/annotator/semantics/HaxeReturnStatementAnnotator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,16 @@ private static boolean hasReturnPathsCovered(@Nullable PsiElement child) {
214214
for (HaxeSwitchCase haxeSwitchCase : switchCaseList) {
215215
if(haxeSwitchCase instanceof HaxeDefaultCase) {
216216
hasDefault = true;
217+
}else {
218+
// check if we got cases with capture variables that cover remaining cases.
219+
List<HaxeSwitchCaseExpr> switchCaseExprList = haxeSwitchCase.getSwitchCaseExprList();
220+
HaxeSwitchCaseExpr first = switchCaseExprList.getFirst();
221+
PsiElement firstChild = first.getFirstChild();
222+
if (firstChild instanceof HaxeEnumExtractedValue) {
223+
hasDefault = true;
224+
}else if (firstChild instanceof HaxeSwitchCaseCaptureVar) {
225+
hasDefault = true;
226+
}
217227
}
218228
HaxeSwitchCaseBlock switchCaseBlock = haxeSwitchCase.getSwitchCaseBlock();
219229
if(switchCaseBlock != null) {

0 commit comments

Comments
 (0)