Skip to content

Constructor reference missing from Index data with S?() #65723

Open
@keith

Description

@keith

With this code:

struct S {}

func foo(_ x: S) {
  _ = S?(x)
}

You get these index references:

/*
       constructor=init()=s:3foo1SVACycfc=definition, implicit, childOf
       struct=S=s:3foo1SV=definition
       v  */
struct S {}

/*
     function=foo(_:)=s:3fooAAyyAA1SVF=definition
     |     parameter=x=s:3fooAAyyAA1SVF1xL_ACvp=definition, childOf
     |     |  struct=S=s:3foo1SV=reference, containedBy
     v     v  v  */
func foo(_ x: S) {
  /*
      struct=S=s:3foo1SV=reference, containedBy
      v  */
  _ = S?(x)
}

Where there should be a reference to the Optional constructor being called, which you do get with an explicit .init:

/*
       constructor=init()=s:3foo1SVACycfc=definition, implicit, childOf
       struct=S=s:3foo1SV=definition
       v  */
struct S {}

/*
     function=foo(_:)=s:3fooAAyyAA1SVF=definition
     |     parameter=x=s:3fooAAyyAA1SVF1xL_ACvp=definition, childOf
     |     |  struct=S=s:3foo1SV=reference, containedBy
     v     v  v  */
func foo(_ x: S) {
  /*
      struct=S=s:3foo1SV=reference, containedBy
      v  */
  _ = S?(x)
  /*
      struct=S=s:3foo1SV=reference, containedBy
      |  constructor=init(_:)=s:SqyxSgxcfc=reference, call, calledBy, containedBy
      v  v  */
  _ = S?.init(x)

}

f5fbee2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.call expressionsFeature → expressions: Call expressionsexpressionsFeature: expressionsindexingArea → source tooling: AST indexinginitFeature → declarations: Initializerssource toolingArea: IDE support, SourceKit, and other source toolingswift 5.9

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions