Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AnthonyLatsis opened this issue Oct 2, 2018 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@AnthonyLatsis
Copy link
Collaborator

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.

@benlangmuir
Copy link
Member

@swift-ci create

@ahoppen
Copy link
Contributor

ahoppen commented Dec 8, 2022

Another similar case once #62362 is merged

// RUN: %sourcekitd-test -req=cursor -pos=4:9 %s -- %s

let formatter: DateFormatter = {
    let formatter = DateFormatter()
    return formatter
}()

struct DateFormatter {}

@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

3 participants