Skip to content

[SR-12903] References to @objc optional funcs do not get indexed #55349

@swift-ci

Description

@swift-ci
Previous ID SR-12903
Radar None
Original Reporter rockbruno (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 673dbd66810d405d1790652da9602332

Issue Description:

import Foundation

@objc protocol Foo {
    @objc optional func bar()
}

class Sample {

    weak var delegate: Foo?

    func doSomething() {
        delegate?.bar()
    }
}

In this snippet, `bar` from `delegate?.bar()` will not get indexed. This only happens if the declaration is `optional`. It works with just `objc`.

Here's how the AST of this looks like:

(optional_evaluation_expr implicit type='<null>'
(call_expr type='<null>' arg_labels=
(unresolved_dot_expr type='<null>' field 'bar' function_ref=single
(bind_optional_expr type='<null>' depth=0
(unresolved_dot_expr type='<null>' field 'delegate' function_ref=unapplied
(declref_expr implicit type='<null>' decl=blabla.(file).Sample.doSomething().self@/Users/rochab/Desktop/blabla.swift:11:10 function_ref=unapplied))))

Looks like it hasn't got resolved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions