File tree 2 files changed +27
-1
lines changed
validation-test/Sema/type_checker_perf/fast 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 15
15
// ===----------------------------------------------------------------------===//
16
16
17
17
#include " TypeChecker.h"
18
+ #include " swift/AST/ConformanceLookup.h"
18
19
#include " swift/AST/ExistentialLayout.h"
19
20
#include " swift/AST/GenericSignature.h"
20
21
#include " swift/Basic/OptionSet.h"
@@ -554,6 +555,30 @@ static void determineBestChoicesInContext(
554
555
}
555
556
}
556
557
558
+ // Match `[...]` to Array<...> and/or `ExpressibleByArrayLiteral`
559
+ // conforming types.
560
+ if (options.contains (MatchFlag::OnParam) &&
561
+ options.contains (MatchFlag::Literal) &&
562
+ isUnboundArrayType (candidateType)) {
563
+ // If an exact match is requested favor only `[...]` to `Array<...>`
564
+ // since everything else is going to increase to score.
565
+ if (options.contains (MatchFlag::ExactOnly))
566
+ return paramType->isArrayType () ? 1 : 0 ;
567
+
568
+ // Otherwise, check if the other side conforms to
569
+ // `ExpressibleByArrayLiteral` protocol (in some way).
570
+ // We want an overly optimistic result here to avoid
571
+ // under-favoring.
572
+ auto &ctx = cs.getASTContext ();
573
+ return checkConformanceWithoutContext (
574
+ paramType,
575
+ ctx.getProtocol (
576
+ KnownProtocolKind::ExpressibleByArrayLiteral),
577
+ /* allowMissing=*/ true )
578
+ ? 0.3
579
+ : 0 ;
580
+ }
581
+
557
582
if (options.contains (MatchFlag::ExactOnly))
558
583
return areEqual (candidateType, paramType) ? 1 : 0 ;
559
584
Original file line number Diff line number Diff line change 1
- // RUN: %target-typecheck-verify-swift -solver-expression-time- threshold=5
1
+ // RUN: %target-typecheck-verify-swift -solver-scope- threshold=11000
2
2
// REQUIRES: tools-release,no_asan
3
+ // REQUIRES: OS=macosx
3
4
4
5
func f( n: Int , a: [ Int ] ) {
5
6
let _ = [ ( 0 ..< n + a. count) . map { Int8 ( $0) } ] +
You can’t perform that action at this time.
0 commit comments