File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1555,6 +1555,11 @@ void CompletionLookup::addConstructorCallsForType(
1555
1555
if (!Sink.addInitsToTopLevel )
1556
1556
return ;
1557
1557
1558
+ // 'AnyObject' is not initializable.
1559
+ // FIXME: Should we do this in 'AnyObjectLookupRequest'?
1560
+ if (type->isAnyObject ())
1561
+ return ;
1562
+
1558
1563
assert (CurrDeclContext);
1559
1564
1560
1565
auto results =
Original file line number Diff line number Diff line change @@ -365,6 +365,10 @@ static void collectPossibleCalleesByQualifiedLookup(
365
365
if (!baseInstanceTy->mayHaveMembers ())
366
366
return ;
367
367
368
+ // 'AnyObject' is not initializable.
369
+ if (baseInstanceTy->isAnyObject () && name == DeclNameRef::createConstructor ())
370
+ return ;
371
+
368
372
// Make sure we've resolved implicit members.
369
373
namelookup::installSemanticMembersIfNeeded (baseInstanceTy, name);
370
374
Original file line number Diff line number Diff line change 56
56
// RUN: %FileCheck %s -check-prefix=DL_CLASS_DOT < %t.dl.txt
57
57
// RUN: %FileCheck %s -check-prefix=GLOBAL_NEGATIVE < %t.dl.txt
58
58
59
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -I %t -disable-objc-attr-requires-foundation-module -code-completion-token=INITIALIZE_PAREN | %FileCheck %s -check-prefix=INITIALIZE_PAREN
60
+ // RUN: %target-swift-ide-test -code-completion -source-filename %s -I %t -disable-objc-attr-requires-foundation-module -code-completion-token=GLOBAL_WITHINIT -code-complete-inits-in-postfix-expr | %FileCheck %s -check-prefix=GLOBAL_WITHINIT
61
+
59
62
// REQUIRES: objc_interop
60
63
61
64
import foo_swift_module
@@ -491,3 +494,16 @@ func testAnyObjectClassMethods1(_ dl: AnyObject) {
491
494
func testAnyObjectClassMethods2( _ dl: AnyObject ) {
492
495
type ( of: dl) . #^DL_CLASS_DOT_1^#
493
496
}
497
+
498
+ func testAnyObjectInitialize( ) {
499
+ AnyObject ( #^INITIALIZE_PAREN^#)
500
+ // INITIALIZE_PAREN-NOT: Flair[ArgLabels]
501
+ // INITIALIZE_PAREN-NOT: name=int:
502
+ }
503
+
504
+ func testGlobalInitializer( ) {
505
+ #^GLOBAL_WITHINIT^#
506
+ // GLOBAL_WITHINIT-NOT: name=AnyObject(
507
+ // GLOBAL_WITHINIT-DAG: Decl[TypeAlias]/OtherModule[Swift]/IsSystem: AnyObject[#Builtin.AnyObject#]; name=AnyObject
508
+ // GLOBAL_WITHINIT-NOT: name=AnyObject(
509
+ }
You can’t perform that action at this time.
0 commit comments