File tree Expand file tree Collapse file tree 1 file changed +8
-37
lines changed Expand file tree Collapse file tree 1 file changed +8
-37
lines changed Original file line number Diff line number Diff line change @@ -95,43 +95,14 @@ class ScopeCreator final {
95
95
// Implicit nodes don't have source information for name lookup.
96
96
if (d->isImplicit ())
97
97
return false ;
98
- // Have also seen the following in an AST:
99
- // Source::
100
- //
101
- // func testInvalidKeyPathComponents() {
102
- // let _ = \.{return 0} // expected-error* {{}}
103
- // }
104
- // class X {
105
- // class var a: Int { return 1 }
106
- // }
107
- //
108
- // AST:
109
- // clang-format off
110
- // (source_file "test.swift"
111
- // (func_decl range=[test.swift:1:3 - line:3:3] "testInvalidKeyPathComponents()" interface type='() -> ()' access=internal
112
- // (parameter_list range=[test.swift:1:36 - line:1:37])
113
- // (brace_stmt range=[test.swift:1:39 - line:3:3]
114
- // (pattern_binding_decl range=[test.swift:2:5 - line:2:11]
115
- // (pattern_any)
116
- // (error_expr implicit type='<null>'))
117
- //
118
- // (pattern_binding_decl range=[test.swift:2:5 - line:2:5] <=== SOURCE RANGE WILL CONFUSE SCOPE CODE
119
- // (pattern_typed implicit type='<<error type>>'
120
- // (pattern_named '_')))
121
- // ...
122
- // clang-format on
123
- //
124
- // So test the SourceRange
125
- //
126
- // But wait!
127
- // var z = $x0 + $x1
128
- // z
129
- //
130
- // z has start == end, but must be pushed to expand source range
131
- //
132
- // So, only check source ranges for PatternBindingDecls
133
- if (isa<PatternBindingDecl>(d) && (d->getStartLoc () == d->getEndLoc ()))
134
- return false ;
98
+ // / In \c Parser::parseDeclVarGetSet fake PBDs are created. Ignore them.
99
+ // / Example:
100
+ // / \code
101
+ // / class SR10903 { static var _: Int { 0 } }
102
+ // / \endcode
103
+ if (const auto *PBD = dyn_cast<PatternBindingDecl>(d))
104
+ if (PBD->isInvalid ())
105
+ return false ;
135
106
// / In
136
107
// / \code
137
108
// / @propertyWrapper
You can’t perform that action at this time.
0 commit comments