File tree Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Expand file tree Collapse file tree 2 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -88,15 +88,23 @@ static bool shouldIgnoreScoreIncreaseForCodeCompletion(
8888 return true ;
8989 }
9090
91- // The sibling argument is the code completion expression, this allows e.g.
92- // non-default literal values in sibling arguments.
93- // E.g. we allow a 1 to be a double in
94- // foo(1, #^COMPLETE^#)
9591 if (auto parent = cs.getParentExpr (expr)) {
92+ // The sibling argument is the code completion expression, this allows e.g.
93+ // non-default literal values in sibling arguments.
94+ // E.g. we allow a 1 to be a double in
95+ // foo(1, #^COMPLETE^#)
9696 if (exprHasCodeCompletionAsArgument (parent, cs)) {
9797 return true ;
9898 }
99+ // If we are completing a member of a literal, consider completion results
100+ // for all possible literal types. E.g. show completion results for `let a:
101+ // Double = 1.#^COMPLETE^#
102+ if (isa_and_nonnull<CodeCompletionExpr>(parent) &&
103+ kind == SK_NonDefaultLiteral) {
104+ return true ;
105+ }
99106 }
107+
100108 return false ;
101109}
102110
Original file line number Diff line number Diff line change 1+ // RUN: %batch-code-completion
2+
3+ extension Double {
4+ var doubleOnlyMember : Double { self }
5+ }
6+
7+ struct CustomInt : ExpressibleByIntegerLiteral {
8+ public init ( ) { }
9+ public init ( integerLiteral value: Int ) { }
10+ var customIntMember : CustomInt { . init( ) }
11+ }
12+
13+ func test( ) {
14+ let double : Double = 2 . #^DOUBLE_CONTEXTUAL_TYPE^#
15+ // DOUBLE_CONTEXTUAL_TYPE: Decl[InstanceVar]/CurrNominal/TypeRelation[Convertible]: doubleOnlyMember[#Double#];
16+
17+ let int : Int = 2 . #^INT_CONTEXTUAL_TYPE^#
18+ // INT_CONTEXTUAL_TYPE: Decl[InstanceVar]/CurrNominal: doubleOnlyMember[#Double#];
19+
20+ let customInt : CustomInt = 2 . #^CUSTOM_INT^#
21+ // CUSTOM_INT-NOT: customIntMember
22+ }
You can’t perform that action at this time.
0 commit comments