Merge pull request #8829 from gottesmm/ome_mark_uninitialized
diff --git a/lib/Index/Index.cpp b/lib/Index/Index.cpp
index 986a719..e11a006 100644
--- a/lib/Index/Index.cpp
+++ b/lib/Index/Index.cpp
@@ -722,6 +722,17 @@
if (getPseudoAccessorNameAndUSR(D, AccKind, Info.name, Info.USR))
return true;
Info.symInfo.Kind = SymbolKind::Function;
+ if (D->getDeclContext()->isTypeContext()) {
+ if (D->isStatic()) {
+ if (isa<VarDecl>(D) &&
+ cast<VarDecl>(D)->getCorrectStaticSpelling() == StaticSpellingKind::KeywordClass)
+ Info.symInfo.Kind = SymbolKind::ClassMethod;
+ else
+ Info.symInfo.Kind = SymbolKind::StaticMethod;
+ } else {
+ Info.symInfo.Kind = SymbolKind::InstanceMethod;
+ }
+ }
Info.symInfo.SubKind = getSubKindForAccessor(AccKind);
Info.roles |= (SymbolRoleSet)SymbolRole::Implicit;
Info.group = "";
@@ -752,7 +763,8 @@
return true; // continue walking.
if (updateInfo(Info))
return true;
- if (addRelation(Info, (SymbolRoleSet) SymbolRole::RelationAccessorOf, D))
+ if (addRelation(Info, (SymbolRoleSet)SymbolRole::RelationAccessorOf |
+ (SymbolRoleSet)SymbolRole::RelationChildOf , D))
return true;
if (!IdxConsumer.startSourceEntity(Info) || !IdxConsumer.finishSourceEntity(Info.symInfo, Info.roles))
@@ -806,7 +818,11 @@
if (startEntityDecl(D)) {
// Pass accessors.
if (auto VarD = dyn_cast<VarDecl>(D)) {
- if (!VarD->getGetter() && !VarD->getSetter()) {
+ auto isNullOrImplicit = [](const Decl *D) -> bool {
+ return !D || D->isImplicit();
+ };
+ if (isNullOrImplicit(VarD->getGetter()) &&
+ isNullOrImplicit(VarD->getSetter())) {
// No actual getter or setter, pass 'pseudo' accessors.
// We create accessor entities so we can implement the functionality
// of libclang, which reports implicit method property accessor
@@ -827,24 +843,24 @@
SourceEntityWalker::walk(cast<Decl>(FD));
if (Cancelled)
return false;
- if (VarD->hasObservers()) {
- if (auto FD = VarD->getWillSetFunc())
- SourceEntityWalker::walk(cast<Decl>(FD));
- if (Cancelled)
- return false;
- if (auto FD = VarD->getDidSetFunc())
- SourceEntityWalker::walk(cast<Decl>(FD));
- if (Cancelled)
- return false;
- }
- if (VarD->hasAddressors()) {
- if (auto FD = VarD->getAddressor())
- SourceEntityWalker::walk(cast<Decl>(FD));
- if (Cancelled)
- return false;
- if (auto FD = VarD->getMutableAddressor())
- SourceEntityWalker::walk(cast<Decl>(FD));
- }
+ }
+ if (VarD->hasObservers()) {
+ if (auto FD = VarD->getWillSetFunc())
+ SourceEntityWalker::walk(cast<Decl>(FD));
+ if (Cancelled)
+ return false;
+ if (auto FD = VarD->getDidSetFunc())
+ SourceEntityWalker::walk(cast<Decl>(FD));
+ if (Cancelled)
+ return false;
+ }
+ if (VarD->hasAddressors()) {
+ if (auto FD = VarD->getAddressor())
+ SourceEntityWalker::walk(cast<Decl>(FD));
+ if (Cancelled)
+ return false;
+ if (auto FD = VarD->getMutableAddressor())
+ SourceEntityWalker::walk(cast<Decl>(FD));
}
} else if (auto NTD = dyn_cast<NominalTypeDecl>(D)) {
if (!reportInheritedTypeRefs(NTD->getInherited(), NTD))
@@ -1038,18 +1054,10 @@
Expr *ParentE = getParentExpr();
- // FIXME: the below check maintains existing indexing behavior with
- // pseudo/accessor output but seems incorrect. E.g otherGlobal in:
- // let global = otherGlobal
- // will not have a parent expression so no accessor call is reported
- if (isa<AbstractStorageDecl>(D) && !ParentE)
- return true;
-
if (!isa<AbstractStorageDecl>(D) &&
!isBeingCalled(CurrentE, ParentE, getContainingExpr(2)))
return false;
-
Info.roles |= (unsigned)SymbolRole::Call;
if (auto *Caller = dyn_cast_or_null<AbstractFunctionDecl>(getParentDecl())) {
if (addRelation(Info, (SymbolRoleSet) SymbolRole::RelationCalledBy, Caller))
diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp
index b62d5f3..5514c18 100644
--- a/lib/Sema/CSSimplify.cpp
+++ b/lib/Sema/CSSimplify.cpp
@@ -2364,7 +2364,12 @@
NameLookupOptions lookupOptions = defaultConstructorLookupOptions;
if (isa<AbstractFunctionDecl>(useDC))
lookupOptions |= NameLookupFlags::KnownPrivate;
- auto ctors = TC.lookupConstructors(useDC, valueType, lookupOptions);
+
+ auto instanceType = valueType;
+ if (auto *selfType = instanceType->getAs<DynamicSelfType>())
+ instanceType = selfType->getSelfType();
+
+ auto ctors = TC.lookupConstructors(useDC, instanceType, lookupOptions);
if (!ctors)
return SolutionKind::Error;
diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp
index 15b44b8..5c80635 100644
--- a/lib/Sema/TypeCheckDecl.cpp
+++ b/lib/Sema/TypeCheckDecl.cpp
@@ -4093,9 +4093,11 @@
return;
}
- if (SD->hasInterfaceType())
+ if (SD->hasInterfaceType() || SD->isBeingValidated())
return;
+ SD->setIsBeingValidated();
+
auto dc = SD->getDeclContext();
assert(dc->isTypeContext() &&
"Decl parsing must prevent subscripts outside of types!");
@@ -4139,6 +4141,8 @@
TC.configureInterfaceType(SD, SD->getGenericSignature());
}
+ SD->setIsBeingValidated(false);
+
TC.checkDeclAttributesEarly(SD);
TC.computeAccessibility(SD);
diff --git a/test/Index/index_module.swift b/test/Index/index_module.swift
index baf4287..43e3211 100644
--- a/test/Index/index_module.swift
+++ b/test/Index/index_module.swift
@@ -8,10 +8,10 @@
public var someGlobal: Int = 0
// CHECK: [[@LINE-1]]:12 | variable/Swift | someGlobal | [[SOMEGLOBAL_USR:.*]] | Def | rel: 0
-// CHECK: [[@LINE-2]]:12 | function/acc-get/Swift | getter:someGlobal | [[SOMEGLOBAL_GET_USR:.*]] | Def,Impl,RelAcc | rel: 1
-// CHECK-NEXT: RelAcc | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]]
-// CHECK: [[@LINE-4]]:12 | function/acc-set/Swift | setter:someGlobal | [[SOMEGLOBAL_SET_USR:.*]] | Def,Impl,RelAcc | rel: 1
-// CHECK-NEXT: RelAcc | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]]
+// CHECK: [[@LINE-2]]:12 | function/acc-get/Swift | getter:someGlobal | [[SOMEGLOBAL_GET_USR:.*]] | Def,Impl,RelChild,RelAcc | rel: 1
+// CHECK-NEXT: RelChild,RelAcc | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]]
+// CHECK: [[@LINE-4]]:12 | function/acc-set/Swift | setter:someGlobal | [[SOMEGLOBAL_SET_USR:.*]] | Def,Impl,RelChild,RelAcc | rel: 1
+// CHECK-NEXT: RelChild,RelAcc | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]]
public func someFunc() {}
// CHECK: [[@LINE-1]]:13 | function/Swift | someFunc() | [[SOMEFUNC_USR:.*]] | Def | rel: 0
@@ -19,9 +19,9 @@
// --- Check the module ---
// CHECK: 0:0 | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]] | Def | rel: 0
-// CHECK: 0:0 | function/acc-get/Swift | getter:someGlobal | [[SOMEGLOBAL_GET_USR:.*]] | Def,Impl,RelAcc | rel: 1
-// CHECK-NEXT: RelAcc | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]]
-// CHECK: 0:0 | function/acc-set/Swift | setter:someGlobal | [[SOMEGLOBAL_SET_USR:.*]] | Def,Impl,RelAcc | rel: 1
-// CHECK-NEXT: RelAcc | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]]
+// CHECK: 0:0 | function/acc-get/Swift | getter:someGlobal | [[SOMEGLOBAL_GET_USR:.*]] | Def,Impl,RelChild,RelAcc | rel: 1
+// CHECK-NEXT: RelChild,RelAcc | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]]
+// CHECK: 0:0 | function/acc-set/Swift | setter:someGlobal | [[SOMEGLOBAL_SET_USR:.*]] | Def,Impl,RelChild,RelAcc | rel: 1
+// CHECK-NEXT: RelChild,RelAcc | variable/Swift | someGlobal | [[SOMEGLOBAL_USR]]
// CHECK: 0:0 | function/Swift | someFunc() | [[SOMEFUNC_USR]] | Def | rel: 0
diff --git a/test/Index/roles.swift b/test/Index/roles.swift
index 35f51d8..47f3d87 100644
--- a/test/Index/roles.swift
+++ b/test/Index/roles.swift
@@ -104,10 +104,10 @@
x += 1
// CHECK: [[@LINE-1]]:5 | instance-property/Swift | x | s:14swift_ide_test7AStructV1xSiv | Ref,Read,Writ,RelCont | rel: 1
// CHECK-NEXT: RelCont | instance-method/Swift | aMethod() | s:14swift_ide_test7AStructV7aMethodyyF
- // CHECK: [[@LINE-3]]:5 | function/acc-get/Swift | getter:x | s:14swift_ide_test7AStructV1xSifg | Ref,Call,Impl,RelRec,RelCall,RelCont | rel: 2
+ // CHECK: [[@LINE-3]]:5 | instance-method/acc-get/Swift | getter:x | s:14swift_ide_test7AStructV1xSifg | Ref,Call,Impl,RelRec,RelCall,RelCont | rel: 2
// CHECK-NEXT: RelCall,RelCont | instance-method/Swift | aMethod() | s:14swift_ide_test7AStructV7aMethodyyF
// CHECK-NEXT: RelRec | struct/Swift | AStruct | s:14swift_ide_test7AStructV
- // CHECK: [[@LINE-6]]:5 | function/acc-set/Swift | setter:x | s:14swift_ide_test7AStructV1xSifs | Ref,Call,Impl,RelRec,RelCall,RelCont | rel: 2
+ // CHECK: [[@LINE-6]]:5 | instance-method/acc-set/Swift | setter:x | s:14swift_ide_test7AStructV1xSifs | Ref,Call,Impl,RelRec,RelCall,RelCont | rel: 2
// CHECK-NEXT: RelCall,RelCont | instance-method/Swift | aMethod() | s:14swift_ide_test7AStructV7aMethodyyF
// CHECK-NEXT: RelRec | struct/Swift | AStruct | s:14swift_ide_test7AStructV
// CHECK: [[@LINE-9]]:7 | static-method/infix-operator/Swift | +=(_:_:) | s:Si2peoiySiz_SitFZ | Ref,RelCont | rel: 1
@@ -134,30 +134,77 @@
}
}
-class AClass { // used for references only
- var y: AStruct;
+class AClass {
+// CHECK: [[@LINE-1]]:7 | class/Swift | AClass | [[AClass_USR:.*]] | Def | rel: 0
+ var y: AStruct
+ // CHECK: [[@LINE-1]]:7 | instance-property/Swift | y | [[AClass_y_USR:.*]] | Def,RelChild | rel: 1
+ // CHECK: [[@LINE-2]]:7 | instance-method/acc-get/Swift | getter:y | [[AClass_y_get_USR:.*]] | Def,Impl,RelChild,RelAcc | rel: 1
+ // CHECK-NEXT: RelChild,RelAcc | instance-property/Swift | y | [[AClass_y_USR]]
+ // CHECK: [[@LINE-4]]:7 | instance-method/acc-set/Swift | setter:y | [[AClass_y_set_USR:.*]] | Def,Impl,RelChild,RelAcc | rel: 1
+ // CHECK-NEXT: RelChild,RelAcc | instance-property/Swift | y | [[AClass_y_USR]]
var z: [Int]
+ var computed_p: Int { return 0 }
+ // CHECK: [[@LINE-1]]:7 | instance-property/Swift | computed_p | [[AClass_computed_p_USR:.*]] | Def,RelChild | rel: 1
+ // CHECK: [[@LINE-2]]:23 | instance-method/acc-get/Swift | getter:computed_p | [[AClass_computed_p_get_USR:.*]] | Def,RelChild,RelAcc | rel: 1
+ // CHECK-NEXT: RelChild,RelAcc | instance-property/Swift | computed_p | [[AClass_computed_p_USR]]
+ // CHECK-NOT: acc-set/Swift | setter:computed_p |
init(x: Int) {
y = AStruct(x: x)
self.z = [1, 2, 3]
}
subscript(index: Int) -> Int {
+ // CHECK: [[@LINE-1]]:3 | instance-property/subscript/Swift | subscript(_:) | [[AClass_subscript_USR:.*]] | Def,RelChild | rel: 1
get { return z[0] }
+ // CHECK: [[@LINE-1]]:5 | instance-method/acc-get/Swift | getter:subscript(_:) | [[AClass_subscript_get_USR:.*]] | Def,RelChild,RelAcc | rel: 1
set { z[0] = newValue }
+ // CHECK: [[@LINE-1]]:5 | instance-method/acc-set/Swift | setter:subscript(_:) | [[AClass_subscript_set_USR:.*]] | Def,RelChild,RelAcc | rel: 1
}
func foo() -> Int { return z[0] }
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | foo() | [[AClass_foo_USR:.*]] | Def,RelChild | rel: 1
}
let _ = AClass.foo
-// CHECK: [[@LINE-1]]:16 | instance-method/Swift | foo() | s:14swift_ide_test6AClassC3fooSiyF | Ref | rel: 0
+// CHECK: [[@LINE-1]]:16 | instance-method/Swift | foo() | [[AClass_foo_USR]] | Ref | rel: 0
let _ = AClass(x: 1).foo
-// CHECK: [[@LINE-1]]:22 | instance-method/Swift | foo() | s:14swift_ide_test6AClassC3fooSiyF | Ref | rel: 0
+// CHECK: [[@LINE-1]]:22 | instance-method/Swift | foo() | [[AClass_foo_USR]] | Ref | rel: 0
let _ = AClass(x: 1)[1]
-// CHECK: [[@LINE-1]]:21 | instance-property/subscript/Swift | subscript(_:) | s:14swift_ide_test6AClassC9subscriptS2ici | Ref,Read | rel: 0
-// CHECK: [[@LINE-2]]:21 | function/acc-get/Swift | getter:subscript(_:) | s:14swift_ide_test6AClassC9subscriptS2icfg | Ref,Call,Dyn,Impl,RelRec | rel: 1
+// CHECK: [[@LINE-1]]:21 | instance-property/subscript/Swift | subscript(_:) | [[AClass_subscript_USR]] | Ref,Read | rel: 0
+// CHECK: [[@LINE-2]]:21 | instance-method/acc-get/Swift | getter:subscript(_:) | [[AClass_subscript_get_USR]] | Ref,Call,Dyn,Impl,RelRec | rel: 1
let _ = AClass(x: 1)[1] = 2
-// CHECK: [[@LINE-1]]:21 | instance-property/subscript/Swift | subscript(_:) | s:14swift_ide_test6AClassC9subscriptS2ici | Ref,Writ | rel: 0
-// CHECK: [[@LINE-2]]:21 | function/acc-set/Swift | setter:subscript(_:) | s:14swift_ide_test6AClassC9subscriptS2icfs | Ref,Call,Dyn,Impl,RelRec | rel: 1
+// CHECK: [[@LINE-1]]:21 | instance-property/subscript/Swift | subscript(_:) | [[AClass_subscript_USR]] | Ref,Writ | rel: 0
+// CHECK: [[@LINE-2]]:21 | instance-method/acc-set/Swift | setter:subscript(_:) | [[AClass_subscript_set_USR]] | Ref,Call,Dyn,Impl,RelRec | rel: 1
+
+extension AClass {
+ func test_property_refs1() -> AStruct {
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | test_property_refs1() | [[test_property_refs1_USR:.*]] | Def,RelChild | rel: 1
+ _ = y
+ // CHECK: [[@LINE-1]]:9 | instance-property/Swift | y | [[AClass_y_USR]] | Ref,Read,RelCont | rel: 1
+ // CHECK: [[@LINE-2]]:9 | instance-method/acc-get/Swift | getter:y | [[AClass_y_get_USR]] | Ref,Call,Dyn,Impl,RelRec,RelCall,RelCont | rel: 2
+ // CHECK-NEXT: RelCall,RelCont | instance-method/Swift | test_property_refs1() | [[test_property_refs1_USR]]
+ // CHECK-NEXT: RelRec | class/Swift | AClass | [[AClass_USR]]
+
+ return y
+ // CHECK: [[@LINE-1]]:12 | instance-property/Swift | y | [[AClass_y_USR]] | Ref,Read,RelCont | rel: 1
+ // CHECK: [[@LINE-2]]:12 | instance-method/acc-get/Swift | getter:y | [[AClass_y_get_USR]] | Ref,Call,Dyn,Impl,RelRec,RelCall,RelCont | rel: 2
+ // CHECK-NEXT: RelCall,RelCont | instance-method/Swift | test_property_refs1() | [[test_property_refs1_USR]]
+ // CHECK-NEXT: RelRec | class/Swift | AClass | [[AClass_USR]]
+ }
+
+ func test_property_refs2() -> Int {
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | test_property_refs2() | [[test_property_refs2_USR:.*]] | Def,RelChild | rel: 1
+ _ = computed_p
+ // CHECK: [[@LINE-1]]:9 | instance-property/Swift | computed_p | [[AClass_computed_p_USR]] | Ref,Read,RelCont | rel: 1
+ // CHECK: [[@LINE-2]]:9 | instance-method/acc-get/Swift | getter:computed_p | [[AClass_computed_p_get_USR]] | Ref,Call,Dyn,Impl,RelRec,RelCall,RelCont | rel: 2
+ // CHECK-NEXT: RelCall,RelCont | instance-method/Swift | test_property_refs2() | [[test_property_refs2_USR]]
+ // CHECK-NEXT: RelRec | class/Swift | AClass | [[AClass_USR]]
+
+ return computed_p
+ // CHECK: [[@LINE-1]]:12 | instance-property/Swift | computed_p | [[AClass_computed_p_USR]] | Ref,Read,RelCont | rel: 1
+ // CHECK: [[@LINE-2]]:12 | instance-method/acc-get/Swift | getter:computed_p | [[AClass_computed_p_get_USR]] | Ref,Call,Dyn,Impl,RelRec,RelCall,RelCont | rel: 2
+ // CHECK-NEXT: RelCall,RelCont | instance-method/Swift | test_property_refs2() | [[test_property_refs2_USR]]
+ // CHECK-NEXT: RelRec | class/Swift | AClass | [[AClass_USR]]
+ }
+}
// RelationBaseOf, RelationOverrideOf
@@ -208,7 +255,7 @@
override func foo() -> Int {
// CHECK: [[@LINE-1]]:17 | instance-method/Swift | foo() | s:14swift_ide_test9ASubClassC3fooSiyF | Def,RelChild,RelOver | rel: 3
- // CHECK-NEXT: RelOver | instance-method/Swift | foo() | s:14swift_ide_test6AClassC3fooSiyF
+ // CHECK-NEXT: RelOver | instance-method/Swift | foo() | [[AClass_foo_USR]]
// CHECK-NEXT: RelOver | instance-method/Swift | foo() | s:14swift_ide_test9AProtocolP3fooSiyF
// CHECK-NEXT: RelChild | class/Swift | ASubClass | s:14swift_ide_test9ASubClassC
return 1
@@ -250,15 +297,15 @@
anInstance.y.x = anInstance.y.x
// CHECK: [[@LINE-1]]:1 | variable/Swift | anInstance | s:14swift_ide_test10anInstanceAA6AClassCv | Ref,Read | rel: 0
-// CHECK: [[@LINE-2]]:12 | instance-property/Swift | y | s:14swift_ide_test6AClassC1yAA7AStructVv | Ref,Read,Writ | rel: 0
+// CHECK: [[@LINE-2]]:12 | instance-property/Swift | y | [[AClass_y_USR]] | Ref,Read,Writ | rel: 0
// CHECK: [[@LINE-3]]:14 | instance-property/Swift | x | s:14swift_ide_test7AStructV1xSiv | Ref,Writ | rel: 0
// CHECK: [[@LINE-4]]:18 | variable/Swift | anInstance | s:14swift_ide_test10anInstanceAA6AClassCv | Ref,Read | rel: 0
-// CHECK: [[@LINE-5]]:29 | instance-property/Swift | y | s:14swift_ide_test6AClassC1yAA7AStructVv | Ref,Read | rel: 0
+// CHECK: [[@LINE-5]]:29 | instance-property/Swift | y | [[AClass_y_USR]] | Ref,Read | rel: 0
// CHECK: [[@LINE-6]]:31 | instance-property/Swift | x | s:14swift_ide_test7AStructV1xSiv | Ref,Read | rel: 0
anInstance.y.aMethod()
// CHECK: [[@LINE-1]]:1 | variable/Swift | anInstance | s:14swift_ide_test10anInstanceAA6AClassCv | Ref,Read | rel: 0
-// CHECK: [[@LINE-2]]:12 | instance-property/Swift | y | s:14swift_ide_test6AClassC1yAA7AStructVv | Ref,Read,Writ | rel: 0
+// CHECK: [[@LINE-2]]:12 | instance-property/Swift | y | [[AClass_y_USR]] | Ref,Read,Writ | rel: 0
// CHECK: [[@LINE-3]]:14 | instance-method/Swift | aMethod() | s:14swift_ide_test7AStructV7aMethodyyF | Ref,Call | rel: 0
// FIXME Write role of z occurrence on the RHS?
@@ -277,7 +324,7 @@
let _ = anInstance[0]
// CHECK: [[@LINE-1]]:9 | variable/Swift | anInstance | s:14swift_ide_test10anInstanceAA6AClassCv | Ref,Read | rel: 0
-// CHECK: [[@LINE-2]]:19 | instance-property/subscript/Swift | subscript(_:) | s:14swift_ide_test6AClassC9subscriptS2ici | Ref,Read | rel: 0
+// CHECK: [[@LINE-2]]:19 | instance-property/subscript/Swift | subscript(_:) | [[AClass_subscript_USR]] | Ref,Read | rel: 0
let aSubInstance: AClass = ASubClass(x: 1)
// CHECK: [[@LINE-1]]:5 | variable/Swift | aSubInstance | s:14swift_ide_test12aSubInstanceAA6AClassCv | Def | rel: 0
@@ -286,7 +333,7 @@
// Dynamic, RelationReceivedBy
let _ = aSubInstance.foo()
// CHECK: [[@LINE-1]]:9 | variable/Swift | aSubInstance | s:14swift_ide_test12aSubInstanceAA6AClassCv | Ref,Read | rel: 0
-// CHECK: [[@LINE-2]]:22 | instance-method/Swift | foo() | s:14swift_ide_test6AClassC3fooSiyF | Ref,Call,Dyn,RelRec | rel: 1
+// CHECK: [[@LINE-2]]:22 | instance-method/Swift | foo() | [[AClass_foo_USR]] | Ref,Call,Dyn,RelRec | rel: 1
// CHECK-NEXT: RelRec | class/Swift | AClass | s:14swift_ide_test6AClassC
// RelationContainedBy
@@ -352,27 +399,27 @@
extension ProtDerived {
func fooCommon() {}
- // CHECK: 354:8 | instance-method/Swift | fooCommon() | s:14swift_ide_test11ProtDerivedPAAE9fooCommonyyF | Def,RelChild,RelOver | rel: 3
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | fooCommon() | s:14swift_ide_test11ProtDerivedPAAE9fooCommonyyF | Def,RelChild,RelOver | rel: 3
// CHECK-NEXT: RelOver | instance-method/Swift | fooCommon() | s:14swift_ide_test11ProtDerivedP9fooCommonyyF
// CHECK-NEXT: RelOver | instance-method/Swift | fooCommon() | s:14swift_ide_test8ProtRootP9fooCommonyyF
func foo1() {}
- // CHECK: 359:8 | instance-method/Swift | foo1() | s:14swift_ide_test11ProtDerivedPAAE4foo1yyF | Def,RelChild,RelOver | rel: 2
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | foo1() | s:14swift_ide_test11ProtDerivedPAAE4foo1yyF | Def,RelChild,RelOver | rel: 2
// CHECK-NEXT: RelOver | instance-method/Swift | foo1() | s:14swift_ide_test8ProtRootP4foo1yyF
func bar1() {}
- // CHECK: 363:8 | instance-method/Swift | bar1() | s:14swift_ide_test11ProtDerivedPAAE4bar1yyF | Def,RelChild,RelOver | rel: 2
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | bar1() | s:14swift_ide_test11ProtDerivedPAAE4bar1yyF | Def,RelChild,RelOver | rel: 2
// CHECK-NEXT: RelOver | instance-method/Swift | bar1() | s:14swift_ide_test11ProtDerivedP4bar1yyF
func foo3(a : Int) {}
- // CHECK: 367:8 | instance-method/Swift | foo3(a:) | s:14swift_ide_test11ProtDerivedPAAE4foo3ySi1a_tF | Def,RelChild,RelOver | rel: 2
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | foo3(a:) | s:14swift_ide_test11ProtDerivedPAAE4foo3ySi1a_tF | Def,RelChild,RelOver | rel: 2
// CHECK-NEXT: RelOver | instance-method/Swift | foo3(a:) | s:14swift_ide_test8ProtRootP4foo3ySi1a_tF
func foo3(a : String) {}
- // CHECK: 371:8 | instance-method/Swift | foo3(a:) | s:14swift_ide_test11ProtDerivedPAAE4foo3ySS1a_tF | Def,RelChild,RelOver | rel: 2
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | foo3(a:) | s:14swift_ide_test11ProtDerivedPAAE4foo3ySS1a_tF | Def,RelChild,RelOver | rel: 2
// CHECK-NEXT: RelOver | instance-method/Swift | foo3(a:) | s:14swift_ide_test8ProtRootP4foo3ySS1a_tF
func bar3(_ : Int) {}
- // CHECK: 375:8 | instance-method/Swift | bar3(_:) | s:14swift_ide_test11ProtDerivedPAAE4bar3ySiF | Def,RelChild,RelOver | rel: 2
+ // CHECK: [[@LINE-1]]:8 | instance-method/Swift | bar3(_:) | s:14swift_ide_test11ProtDerivedPAAE4bar3ySiF | Def,RelChild,RelOver | rel: 2
// CHECK-NEXT: RelOver | instance-method/Swift | bar3(_:) | s:14swift_ide_test11ProtDerivedP4bar3ySiF
}
diff --git a/test/SourceKit/Indexing/Inputs/cycle-depend/A.response b/test/SourceKit/Indexing/Inputs/cycle-depend/A.response
index 7351d77..2b8281d 100644
--- a/test/SourceKit/Indexing/Inputs/cycle-depend/A.response
+++ b/test/SourceKit/Indexing/Inputs/cycle-depend/A.response
@@ -54,7 +54,17 @@
{
key.kind: source.lang.swift.decl.var.instance,
key.name: "x",
- key.usr: "s:1AAAC1x1BADCv"
+ key.usr: "s:1AAAC1x1BADCv",
+ key.entities: [
+ {
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:1AAAC1x1BADCfg"
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:1AAAC1x1BADCfs"
+ }
+ ]
}
]
}
diff --git a/test/SourceKit/Indexing/Inputs/implicit-vis/a.index.response b/test/SourceKit/Indexing/Inputs/implicit-vis/a.index.response
index 242aad7..d2590f9 100644
--- a/test/SourceKit/Indexing/Inputs/implicit-vis/a.index.response
+++ b/test/SourceKit/Indexing/Inputs/implicit-vis/a.index.response
@@ -22,7 +22,21 @@
key.name: "b",
key.usr: "s:12implicit_vis1AC1bAA1BCv",
key.line: 2,
- key.column: 6
+ key.column: 6,
+ key.entities: [
+ {
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:12implicit_vis1AC1bAA1BCfg",
+ key.line: 2,
+ key.column: 6
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:12implicit_vis1AC1bAA1BCfs",
+ key.line: 2,
+ key.column: 6
+ }
+ ]
},
{
key.kind: source.lang.swift.ref.class,
diff --git a/test/SourceKit/Indexing/Inputs/implicit-vis/b.index.response b/test/SourceKit/Indexing/Inputs/implicit-vis/b.index.response
index 633277f..32d2ee5 100644
--- a/test/SourceKit/Indexing/Inputs/implicit-vis/b.index.response
+++ b/test/SourceKit/Indexing/Inputs/implicit-vis/b.index.response
@@ -22,7 +22,21 @@
key.name: "a",
key.usr: "s:12implicit_vis1BC1aAA1ACv",
key.line: 2,
- key.column: 6
+ key.column: 6,
+ key.entities: [
+ {
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:12implicit_vis1BC1aAA1ACfg",
+ key.line: 2,
+ key.column: 6
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:12implicit_vis1BC1aAA1ACfs",
+ key.line: 2,
+ key.column: 6
+ }
+ ]
},
{
key.kind: source.lang.swift.ref.class,
diff --git a/test/SourceKit/Indexing/Inputs/test_module.index.response b/test/SourceKit/Indexing/Inputs/test_module.index.response
index 53b8911..15a5f2b 100644
--- a/test/SourceKit/Indexing/Inputs/test_module.index.response
+++ b/test/SourceKit/Indexing/Inputs/test_module.index.response
@@ -64,12 +64,32 @@
{
key.kind: source.lang.swift.decl.var.instance,
key.name: "x",
- key.usr: "s:11test_module7TwoIntsC1xSiv"
+ key.usr: "s:11test_module7TwoIntsC1xSiv",
+ key.entities: [
+ {
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:11test_module7TwoIntsC1xSifg"
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:11test_module7TwoIntsC1xSifs"
+ }
+ ]
},
{
key.kind: source.lang.swift.decl.var.instance,
key.name: "y",
- key.usr: "s:11test_module7TwoIntsC1ySiv"
+ key.usr: "s:11test_module7TwoIntsC1ySiv",
+ key.entities: [
+ {
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:11test_module7TwoIntsC1ySifg"
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:11test_module7TwoIntsC1ySifs"
+ }
+ ]
},
{
key.kind: source.lang.swift.decl.function.constructor,
diff --git a/test/SourceKit/Indexing/index.swift.response b/test/SourceKit/Indexing/index.swift.response
index 76ea811..ff7bc1f 100644
--- a/test/SourceKit/Indexing/index.swift.response
+++ b/test/SourceKit/Indexing/index.swift.response
@@ -57,7 +57,21 @@
key.name: "instV",
key.usr: "s:5index2CCC5instVACv",
key.line: 8,
- key.column: 7
+ key.column: 7,
+ key.entities: [
+ {
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:5index2CCC5instVACfg",
+ key.line: 8,
+ key.column: 7
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:5index2CCC5instVACfs",
+ key.line: 8,
+ key.column: 7
+ }
+ ]
},
{
key.kind: source.lang.swift.ref.class,
@@ -1231,6 +1245,18 @@
key.column: 7,
key.entities: [
{
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:5index9ObservingC04globB0Sifg",
+ key.line: 151,
+ key.column: 7
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:5index9ObservingC04globB0Sifs",
+ key.line: 151,
+ key.column: 7
+ },
+ {
key.kind: source.lang.swift.decl.function.accessor.willset,
key.name: "willSet:globObserving",
key.usr: "s:5index9ObservingC04globB0Sifw",
@@ -1298,6 +1324,18 @@
key.column: 7,
key.entities: [
{
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:5index12rdar18640140C2S1Sifg",
+ key.line: 164,
+ key.column: 7
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:5index12rdar18640140C2S1Sifs",
+ key.line: 164,
+ key.column: 7
+ },
+ {
key.kind: source.lang.swift.decl.function.accessor.didset,
key.name: "didSet:S1",
key.usr: "s:5index12rdar18640140C2S1SifW",
diff --git a/test/SourceKit/Indexing/index_constructors.swift.response b/test/SourceKit/Indexing/index_constructors.swift.response
index 14391805..be622fe 100644
--- a/test/SourceKit/Indexing/index_constructors.swift.response
+++ b/test/SourceKit/Indexing/index_constructors.swift.response
@@ -38,7 +38,21 @@
key.name: "name",
key.usr: "s:18index_constructors11HorseObjectC4nameXev",
key.line: 7,
- key.column: 7
+ key.column: 7,
+ key.entities: [
+ {
+ key.kind: source.lang.swift.decl.function.accessor.getter,
+ key.usr: "s:18index_constructors11HorseObjectC4nameXefg",
+ key.line: 7,
+ key.column: 7
+ },
+ {
+ key.kind: source.lang.swift.decl.function.accessor.setter,
+ key.usr: "s:18index_constructors11HorseObjectC4nameXefs",
+ key.line: 7,
+ key.column: 7
+ }
+ ]
},
{
key.kind: source.lang.swift.decl.function.method.instance,
diff --git a/test/SourceKit/Indexing/index_forbid_typecheck.swift.response b/test/SourceKit/Indexing/index_forbid_typecheck.swift.response
index f6b0b58..9572f4a 100644
--- a/test/SourceKit/Indexing/index_forbid_typecheck.swift.response
+++ b/test/SourceKit/Indexing/index_forbid_typecheck.swift.response
@@ -36,7 +36,15 @@
key.name: "globalSec",
key.usr: "s:18forbid_typecheck_29globalSecSiv",
key.line: 1,
- key.column: 18
+ key.column: 18,
+ key.entities: [
+ {
+ key.kind: source.lang.swift.ref.function.accessor.getter,
+ key.usr: "s:18forbid_typecheck_29globalSecSifg",
+ key.line: 1,
+ key.column: 18
+ }
+ ]
},
{
key.kind: source.lang.swift.decl.function.free,
@@ -64,7 +72,17 @@
key.name: "member",
key.usr: "s:18forbid_typecheck_26ClsSecC6memberSiv",
key.line: 5,
- key.column: 20
+ key.column: 20,
+ key.entities: [
+ {
+ key.kind: source.lang.swift.ref.function.accessor.getter,
+ key.usr: "s:18forbid_typecheck_26ClsSecC6memberSifg",
+ key.line: 5,
+ key.column: 20,
+ key.receiver_usr: "s:18forbid_typecheck_26ClsSecC",
+ key.is_dynamic: 1
+ }
+ ]
}
]
}
diff --git a/test/decl/func/dynamic_self.swift b/test/decl/func/dynamic_self.swift
index 34fbc3e..dae86a4 100644
--- a/test/decl/func/dynamic_self.swift
+++ b/test/decl/func/dynamic_self.swift
@@ -91,6 +91,13 @@
return Self() // expected-error{{use of unresolved identifier 'Self'}} expected-note {{did you mean 'self'?}}
}
+
+ // This used to crash because metatype construction went down a
+ // different code path that didn't handle DynamicSelfType.
+ class func badFactory() -> Self {
+ return self(int: 0)
+ // expected-error@-1 {{initializing from a metatype value must reference 'init' explicitly}}
+ }
}
// ----------------------------------------------------------------------------
diff --git a/test/decl/protocol/req/associated_type_inference.swift b/test/decl/protocol/req/associated_type_inference.swift
index 4ed9480..dc50669 100644
--- a/test/decl/protocol/req/associated_type_inference.swift
+++ b/test/decl/protocol/req/associated_type_inference.swift
@@ -129,7 +129,11 @@
// Inference from subscripts
protocol SubscriptP0 {
associatedtype Index
- associatedtype Element : PSimple // expected-note{{unable to infer associated type 'Element' for protocol 'SubscriptP0'}}
+ // expected-note@-1 2 {{protocol requires nested type 'Index'; do you want to add it?}}
+
+ associatedtype Element : PSimple
+ // expected-note@-1 {{unable to infer associated type 'Element' for protocol 'SubscriptP0'}}
+ // expected-note@-2 2 {{protocol requires nested type 'Element'; do you want to add it?}}
subscript (i: Index) -> Element { get }
}
@@ -138,14 +142,27 @@
subscript (i: Int) -> Int { get { return i } }
}
-struct XSubP0b : SubscriptP0 { // expected-error{{type 'XSubP0b' does not conform to protocol 'SubscriptP0'}}
+struct XSubP0b : SubscriptP0 {
+// expected-error@-1{{type 'XSubP0b' does not conform to protocol 'SubscriptP0'}}
subscript (i: Int) -> Float { get { return Float(i) } } // expected-note{{inferred type 'Float' (by matching requirement 'subscript') is invalid: does not conform to 'PSimple'}}
}
+struct XSubP0c : SubscriptP0 {
+// expected-error@-1 {{type 'XSubP0c' does not conform to protocol 'SubscriptP0'}}
+ subscript (i: Index) -> Element { get { } }
+}
+
+struct XSubP0d : SubscriptP0 {
+// expected-error@-1 {{type 'XSubP0d' does not conform to protocol 'SubscriptP0'}}
+ subscript (i: XSubP0d.Index) -> XSubP0d.Element { get { } }
+}
+
// Inference from properties and subscripts
protocol CollectionLikeP0 {
associatedtype Index
+ // expected-note@-1 {{protocol requires nested type 'Index'; do you want to add it?}}
associatedtype Element
+ // expected-note@-1 {{protocol requires nested type 'Element'; do you want to add it?}}
var startIndex: Index { get }
var endIndex: Index { get }
@@ -164,6 +181,13 @@
subscript (r: Range<Int>) -> SomeSlice<T> { get { return SomeSlice() } }
}
+struct XCollectionLikeP0b : CollectionLikeP0 {
+// expected-error@-1 {{type 'XCollectionLikeP0b' does not conform to protocol 'CollectionLikeP0'}}
+ var startIndex: XCollectionLikeP0b.Index
+ // expected-error@-1 {{'startIndex' used within its own type}}
+ var startElement: XCollectionLikeP0b.Element
+}
+
// rdar://problem/21304164
public protocol Thenable {
associatedtype T // expected-note{{protocol requires nested type 'T'}}
diff --git a/utils/vim/syntax/swift.vim b/utils/vim/syntax/swift.vim
index d70542b..68601c4 100644
--- a/utils/vim/syntax/swift.vim
+++ b/utils/vim/syntax/swift.vim
@@ -88,6 +88,8 @@
syn keyword swiftLabel
\ get
\ set
+ \ didSet
+ \ willSet
syn keyword swiftBoolean
\ false