Skip to content

Commit fe3216a

Browse files
[AST] Consider only rooted keypath as single invalid component
1 parent 7f2c262 commit fe3216a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/swift/AST/Expr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5833,7 +5833,10 @@ class KeyPathExpr : public Expr {
58335833
/// Indicates if the key path expression is composed by a single invalid
58345834
/// component. e.g. missing component `\Root`
58355835
bool hasSingleInvalidComponent() const {
5836-
return Components.size() == 1 && !Components.front().isValid();
5836+
if (ParsedRoot && ParsedRoot->getKind() == ExprKind::Type) {
5837+
return Components.size() == 1 && !Components.front().isValid();
5838+
}
5839+
return false;
58375840
}
58385841

58395842
/// Retrieve the string literal expression, which will be \c NULL prior to

0 commit comments

Comments
 (0)