Skip to content

[SR-8898] CodeCompletion: Forward references do not show up in top-level module scope  #51404

@AnthonyLatsis

Description

@AnthonyLatsis
Previous ID SR-8898
Radar rdar://problem/44942051
Original Reporter @AnthonyLatsis
Type Bug
Environment

Xcode 12.0 beta (12A6159)

Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug
Assignee @rintaro
Priority Medium

md5: 3b8fc482fb0b9539e17cde7ce92f056a

is duplicated by:

  • SR-14431 Global completions at top level from module only appear after import statement

Issue Description:

@benlangmuir:

The real problem here is that consumeDecl wants to use IsTopLevel to mean TopLevelCode - i.e. a script or main.swift file, where you cannot make forward references at all - but the caller is passing in TopLevelLibrary as well, where forward references are fine. So we actually have the same bug already in e.g. inheritance completion where we only suggest the names earlier in the file.

Test case for inheritance completion:

$ cat t.swift 
class C {}
class E: #^A^# {}
class D {}

$ xcrun swift-ide-test -code-completion -code-completion-token=A -source-filename=t.swift | grep CurrMo
found code completion token A at offset 20
Decl[Class]/CurrModule:             C[#C#]; name=C

This should also find D.

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.code completionArea → source tooling: code completionsource toolingArea: IDE support, SourceKit, and other source tooling

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions