@@ -170,7 +170,7 @@ function complete_symbol(@nospecialize(ex), name::String, @nospecialize(ffunc),
170
170
# as excluding Main.Main.Main, etc., because that's most likely not what
171
171
# the user wants
172
172
p = let mod= mod, modname= nameof (mod)
173
- s -> ( ! Base. isdeprecated (mod, s) && s != modname && ffunc (mod, s):: Bool )
173
+ (s :: Symbol ) -> ! Base. isdeprecated (mod, s) && s != modname && ffunc (mod, s):: Bool
174
174
end
175
175
# Looking for a binding in a module
176
176
if mod == context_module
@@ -192,25 +192,32 @@ function complete_symbol(@nospecialize(ex), name::String, @nospecialize(ffunc),
192
192
end
193
193
else
194
194
# Looking for a member of a type
195
- if t isa DataType && t != Any
196
- # Check for cases like Type{typeof(+)}
197
- if Base. isType (t)
198
- t = typeof (t. parameters[1 ])
199
- end
200
- # Only look for fields if this is a concrete type
201
- if isconcretetype (t)
202
- fields = fieldnames (t)
203
- for field in fields
204
- isa (field, Symbol) || continue # Tuple type has ::Int field name
205
- s = string (field)
206
- if startswith (s, name)
207
- push! (suggestions, FieldCompletion (t, field))
208
- end
195
+ add_field_completions! (suggestions, name, t)
196
+ end
197
+ return suggestions
198
+ end
199
+
200
+ function add_field_completions! (suggestions:: Vector{Completion} , name:: String , @nospecialize (t))
201
+ if isa (t, Union)
202
+ add_field_completions! (suggestions, name, t. a)
203
+ add_field_completions! (suggestions, name, t. b)
204
+ elseif t isa DataType && t != Any
205
+ # Check for cases like Type{typeof(+)}
206
+ if Base. isType (t)
207
+ t = typeof (t. parameters[1 ])
208
+ end
209
+ # Only look for fields if this is a concrete type
210
+ if isconcretetype (t)
211
+ fields = fieldnames (t)
212
+ for field in fields
213
+ isa (field, Symbol) || continue # Tuple type has ::Int field name
214
+ s = string (field)
215
+ if startswith (s, name)
216
+ push! (suggestions, FieldCompletion (t, field))
209
217
end
210
218
end
211
219
end
212
220
end
213
- suggestions
214
221
end
215
222
216
223
const sorted_keywords = [
@@ -580,11 +587,6 @@ function repl_eval_ex(@nospecialize(ex), context_module::Module)
580
587
581
588
result = frame. result. result
582
589
result === Union{} && return nothing # for whatever reason, callers expect this as the Bottom and/or Top type instead
583
- if isa (result, Union)
584
- # unswitch `Union` of same `UnionAll` instances to `UnionAll` of `Union`s
585
- # so that we can use the field information of the `UnionAll`
586
- return CC. unswitchtypeunion (result)
587
- end
588
590
return result
589
591
end
590
592
0 commit comments