File tree Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Expand file tree Collapse file tree 2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -771,16 +771,18 @@ static void addKeyPathDynamicMemberOverloads(
771
771
// / shouldn't be compared.
772
772
static Optional<std::pair<Type, Type>>
773
773
getConstructorParamsAsTuples (ASTContext &ctx, Type boundTy1, Type boundTy2) {
774
- // If the bound types are placeholders, they haven't been resolved, so let's
775
- // not try and rank them.
776
- if (boundTy1->isPlaceholder () || boundTy2->isPlaceholder ())
774
+ auto choiceTy1 =
775
+ boundTy1->lookThroughAllOptionalTypes ()->getAs <FunctionType>();
776
+ auto choiceTy2 =
777
+ boundTy2->lookThroughAllOptionalTypes ()->getAs <FunctionType>();
778
+
779
+ // If the type variables haven't been bound to functions yet, let's not try
780
+ // and rank them.
781
+ if (!choiceTy1 || !choiceTy2)
777
782
return None;
778
783
779
- auto choiceTy1 = boundTy1->lookThroughAllOptionalTypes ();
780
- auto choiceTy2 = boundTy2->lookThroughAllOptionalTypes ();
781
-
782
- auto initParams1 = choiceTy1->castTo <FunctionType>()->getParams ();
783
- auto initParams2 = choiceTy2->castTo <FunctionType>()->getParams ();
784
+ auto initParams1 = choiceTy1->getParams ();
785
+ auto initParams2 = choiceTy2->getParams ();
784
786
if (initParams1.size () != initParams2.size ())
785
787
return None;
786
788
Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=CC
2
+
3
+ // PR #39543: Make sure we can complete in this position without crashing.
4
+ extension String {
5
+ init ( format: String , _: Any ) { fatalError ( ) }
6
+ }
7
+ extension RandomAccessCollection {
8
+ func foo( ) {
9
+ print ( String ( format: " " , Int ( distance ( from: #^CC^# startIndex, to: startIndex) ) ) )
10
+ }
11
+ }
You can’t perform that action at this time.
0 commit comments