swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.28k stars 10.33k forks source link

“cannot resolve location as name” for variable with property wrapper without type annotation in result builder #63610

Open ahoppen opened 1 year ago

ahoppen commented 1 year ago

The following new test case reports results for cursor info but when trying to do local rename it fails with “cannot resolve location as name”

@resultBuilder struct ViewBuilder {
  public static func buildBlock() -> Int { 0 }
  public static func buildBlock(_ content: Int) -> Int { content }
}

@propertyWrapper
struct State {
  var wrappedValue: Int
}

struct ValueModifier {
  @ViewBuilder func body() -> Int {
    // RUN: %sourcekitd-test -req=cursor -pos=%(line + 2):16 %s -- %s | %FileCheck %s --check-prefix CURSOR
    // RUN: %sourcekitd-test -req=refactoring.rename.local -pos=%(line + 1):16 %s -- %s
    @State var position
  }
}

// CURSOR: <Declaration>@<Type usr="s:4test5StateV">State</Type> var position: &lt;&lt;error type&gt;&gt; { get set }</Declaration>

rdar://105382720

ahoppen commented 9 months ago

The local refactoring action has been removed but the underlying issue probably still persists when getting local rename ranges.