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(
15551555 if (!Sink.addInitsToTopLevel )
15561556 return ;
15571557
1558+ // 'AnyObject' is not initializable.
1559+ // FIXME: Should we do this in 'AnyObjectLookupRequest'?
1560+ if (type->isAnyObject ())
1561+ return ;
1562+
15581563 assert (CurrDeclContext);
15591564
15601565 auto results =
Original file line number Diff line number Diff line change @@ -365,6 +365,10 @@ static void collectPossibleCalleesByQualifiedLookup(
365365 if (!baseInstanceTy->mayHaveMembers ())
366366 return ;
367367
368+ // 'AnyObject' is not initializable.
369+ if (baseInstanceTy->isAnyObject () && name == DeclNameRef::createConstructor ())
370+ return ;
371+
368372 // Make sure we've resolved implicit members.
369373 namelookup::installSemanticMembersIfNeeded (baseInstanceTy, name);
370374
Original file line number Diff line number Diff line change 5656// RUN: %FileCheck %s -check-prefix=DL_CLASS_DOT < %t.dl.txt
5757// RUN: %FileCheck %s -check-prefix=GLOBAL_NEGATIVE < %t.dl.txt
5858
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+
5962// REQUIRES: objc_interop
6063
6164import foo_swift_module
@@ -491,3 +494,16 @@ func testAnyObjectClassMethods1(_ dl: AnyObject) {
491494func testAnyObjectClassMethods2( _ dl: AnyObject ) {
492495 type ( of: dl) . #^DL_CLASS_DOT_1^#
493496}
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