Code completion not working in Xcode 8 when a `let static` is used in an extension

Originator:charles.parnot
Number:rdar://30013615 Date Originated:01/13/2017
Status:Open Resolved:
Product:Xcode Product Version:8.2.1
Classification:Bug Reproducible:Always
 
Summary:
When adding a `static let` property to an extension of a class, code completion within that extension is broken. It works fine everywhere else, and if the code is correct, it all compiles fine. But code completion remains unusable within the extension scope.

Steps to Reproduce:
1. Open the attached project in Xcode 8.2.1
2. Open the file `THE_BUG_IS_HERE.swift`
3. Try code completion with the implementation of `foobar2`
4. Try code completion with the implementation of `foobar1`

Expected Results:
Code completion should succeed in steps 3 & 4

Actual Results:
Code completion fails in step 3
Code completion succeeds in step 4

Version:
Xcode 8.2.1



----

Here is the code

//
//  AppDelegate.swift
//  CodeCompletionBugInStaticLetInExtension
//
//  Created by Charles Parnot on 1/13/17.
//  Copyright © 2017 Charles Parnot. All rights reserved.
//

import Cocoa

@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {

    @IBOutlet weak var window: NSWindow!


    func applicationDidFinishLaunching(_ aNotification: Notification) {
        // Insert code here to initialize your application
    }

    func applicationWillTerminate(_ aNotification: Notification) {
        // Insert code here to tear down your application
    }

    // Code completion works fine here. But does not work in foobar2.
    static let foobar1 = {
        return NSBezierPath()
    }()
}

extension AppDelegate {
    
    static let foobar2 = {
        return NSBezierPath()
        
        // Try code completion here, e.g. type 'nsbez' and then 'esc'. Xcode finds no completion. But that works in foobar1.
        // return nsbez
        
    }()
}

struct SomeStruct {
    
    static let foobar1 = {
        return NSBezierPath()
    }()

}

extension SomeStruct {
    
    static let foobar2 = {
        return NSBezierPath()
        
        // Try code completion here, e.g. type 'nsbez' and then 'esc'. Xcode finds no completion. But that works in foobar1.
        // return nsbez
        
    }()
    
}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!