Merge pull request #22572 from dcci/rdar47982630-50
[5.0][DebuggerSupport] Unbreak closures in the expression parser.
diff --git a/lib/Parse/Lexer.cpp b/lib/Parse/Lexer.cpp
index a5acee6..076358c 100644
--- a/lib/Parse/Lexer.cpp
+++ b/lib/Parse/Lexer.cpp
@@ -953,8 +953,6 @@
// independent of language mode.
return formToken(tok::identifier, tokStart);
} else {
- if (LangOpts.EnableDollarIdentifiers && !LangOpts.Playground)
- return formToken(tok::identifier, tokStart);
return formToken(tok::dollarident, tokStart);
}
}
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index ef443cf..5a82953 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -2915,6 +2915,12 @@
auto closure = dyn_cast_or_null<ClosureExpr>(
dyn_cast<AbstractClosureExpr>(CurDeclContext));
if (!closure) {
+ if (Context.LangOpts.DebuggerSupport) {
+ auto refKind = DeclRefKind::Ordinary;
+ auto identifier = Context.getIdentifier(Name);
+ return new (Context) UnresolvedDeclRefExpr(DeclName(identifier), refKind,
+ DeclNameLoc(Loc));
+ }
diagnose(Loc, diag::anon_closure_arg_not_in_closure);
return new (Context) ErrorExpr(Loc);
}
diff --git a/test/Parse/closure-debugger.swift b/test/Parse/closure-debugger.swift
new file mode 100644
index 0000000..4f74e62
--- /dev/null
+++ b/test/Parse/closure-debugger.swift
@@ -0,0 +1,6 @@
+// RUN: not %target-swift-frontend %s -typecheck -debugger-support 2>&1 | %FileCheck %s --check-prefix=DEBUG
+// RUN: not %target-swift-frontend %s -typecheck 2>&1 | %FileCheck %s --check-prefix=NODEBUG
+
+// DEBUG: error: use of unresolved identifier '$0'
+// NODEBUG: error: anonymous closure argument not contained in a closure
+$0