Files
swift-mirror/test/SourceKit/DocumentStructure/Inputs/main.swift
Nathan Hawes 11d20b8c92 [IDE] Avoid name binding in sourcekitd's syntactic requests
It looks like we recently started binding extensions to their nominals in order
to continue to compute access levels via ValueDecl::getFormalAccess() after an
assertion was added to enforce that bindExtensions had been called before
anything tried to call ExtensionDecl::getBoundNominal() - which
getFormalAccess() depends on. Sourcekitd's syntactic requests are made on every
keypress in the editor though, so we shouldn't do any name binding (which may
require module loading) to keep them as fast as possible.

This patch restores the old inferAccessLevel() functions we used prior to the
switch to ValueDecl::getFormalAccess() (plus a few fixes) that does as much as
it can syntactically, without any name binding, and simply doesn't report the
access level in cases where it couldn't be computed without name-binding.

This also fixes an assertion hit we were getting trying to bind extensions in
inactive ifconfig clauses, which ASTScope doesn't support.

Resolves rdar://problem/57202584
2019-11-16 13:41:20 -08:00

156 lines
2.4 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class Foo : Bar {
var test : Int
@IBOutlet var testOutlet : Int
func testMethod() {
if test {
}
}
@IBAction func testAction() {
}
}
@IBDesignable
class Foo2 {}
class Foo3 {
@IBInspectable var testIBInspectable : Int
@GKInspectable var testGKInspectable : Int
}
protocol MyProt {}
class OuterCls {
class InnerCls1 {}
}
extension OuterCls {
class InnerCls2 {}
}
class GenCls<T1, T2> {}
class TestParamAndCall {
func testParams(arg1: Int, name: String) {
if (arg1) {
testParams(0, name:"testing")
}
}
func testParamAndArg(arg1: Int, param par: Int) {
}
}
// FIXME: Whatever.
class TestMarkers {
// TODO: Something.
func test(arg1: Bool) -> Int {
// FIXME: Blah.
if (arg1) {
// FIXME: Blah.
return 0
}
return 1
}
}
func test2(arg1: Bool) {
if (arg1) {
// http://whatever FIXME: http://whatever/fixme.
}
}
extension Foo {
func anExtendedFooFunction() {
}
}
// rdar://19539259
var (sd2: Qtys)
{
417(d: nil)
}
for i in 0...5 {}
for var i = 0, i2 = 1; i == 0; ++i {}
while var v = o, var z = o, v > z {}
repeat {} while v == 0
if var v = o, var z = o, v > z {}
switch v {
case 1: break;
case 2, 3: break;
default: break;
}
let myArray = [1, 2, 3]
let myDict = [1:1, 2:2, 3:3]
// rdar://21203366
@objc
class ClassObjcAttr : NSObject {
@objc
func m() {}
}
@objc(Blah)
class ClassObjcAttr2 : NSObject {
@objc(Foo)
func m() {}
}
protocol FooProtocol {
associatedtype Bar
associatedtype Baz: Equatable
}
// SR-5717
a.b(c: d?.e?.f, h: i)
// SR-6926
/* 👨👩👧👦👨👩👧👦👨👩👧👦 */
`init`(x: Int, y: Int) {}
class C {
/* 👨👩👧👦👨👩👧👦👨👩👧👦 */
`init`(x: Int, y: Int) {}
}
var // comment
`$` = 1
func /* comment */`foo`(x: Int) {}
// rdar://40085232
enum MyEnum {
case Bar(arg: Int)
}
enum MySecondEnum {
case One = 1
}
func someFunc(input :Int?, completion: () throws -> Void) rethrows {}
class OneMore {
@IBSegueAction func testAction(coder: AnyObject, _ ident: String) -> AnyObject {
fatalError()
}
}
class Chain<A> {
func + (lhs: Chain<A>, rhs: Chain<A>) -> Chain<A> { fatalError() }
}
public init() {
fatalError()
}
deinit {
fatalError()
}
#if false
extension Result {
func foo() {}
}
#endif