[ConstraintSystem] Disable performance hacks by default

This also changes the flag to `-enable-constraint-solver-performance-hacks`.
This commit is contained in:
Pavel Yaskevich
2025-06-25 10:38:27 -07:00
parent c04068db1c
commit 2957da3591
39 changed files with 640 additions and 44 deletions

View File

@@ -986,8 +986,8 @@ namespace swift {
/// Enable experimental operator designated types feature.
bool EnableOperatorDesignatedTypes = false;
/// Disable constraint system performance hacks.
bool DisableConstraintSolverPerformanceHacks = false;
/// Enable old constraint system performance hacks.
bool EnableConstraintSolverPerformanceHacks = false;
/// See \ref FrontendOptions.PrintFullConvention
bool PrintFullConvention = false;

View File

@@ -862,8 +862,8 @@ def solver_trail_threshold_EQ : Joined<["-"], "solver-trail-threshold=">,
def solver_disable_splitter : Flag<["-"], "solver-disable-splitter">,
HelpText<"Disable the component splitter phase of expression type checking">;
def disable_constraint_solver_performance_hacks : Flag<["-"], "disable-constraint-solver-performance-hacks">,
HelpText<"Disable all the hacks in the constraint solver">;
def enable_constraint_solver_performance_hacks : Flag<["-"], "enable-constraint-solver-performance-hacks">,
HelpText<"Enable all the old hacks in the constraint solver">;
def enable_operator_designated_types :
Flag<["-"], "enable-operator-designated-types">,

View File

@@ -3595,11 +3595,11 @@ public:
return Options.contains(ConstraintSystemFlags::ForCodeCompletion);
}
/// Check whether type-checker performance hacks has been explicitly
/// disabled by a flag.
/// Check whether old type-checker performance hacks has been explicitly
/// enabled by a flag.
bool performanceHacksEnabled() const {
return !getASTContext()
.TypeCheckerOpts.DisableConstraintSolverPerformanceHacks;
return getASTContext()
.TypeCheckerOpts.EnableConstraintSolverPerformanceHacks;
}
/// Log and record the application of the fix. Return true iff any

View File

@@ -2009,8 +2009,8 @@ static bool ParseTypeCheckerArgs(TypeCheckerOptions &Opts, ArgList &Args,
SWIFT_ONONE_SUPPORT);
}
Opts.DisableConstraintSolverPerformanceHacks |=
Args.hasArg(OPT_disable_constraint_solver_performance_hacks);
Opts.EnableConstraintSolverPerformanceHacks |=
Args.hasArg(OPT_enable_constraint_solver_performance_hacks);
Opts.EnableOperatorDesignatedTypes |=
Args.hasArg(OPT_enable_operator_designated_types);

View File

@@ -212,10 +212,9 @@ func test_async_calls_in_async_context(v: Int) async {
}
// Only implicit `.init` should be accepted with a warning due type-checker previously picking an incorrect overload.
// FIXME: This should produce a warning once type-checker performance hacks are removed.
_ = Test(v) // Temporary okay
_ = Test(v) // expected-warning {{expression is 'async' but is not marked with 'await'; this is an error in the Swift 6 language mode}} expected-note {{call is 'async'}}
_ = Test.init(v) // expected-error {{expression is 'async' but is not marked with 'await'}} expected-note {{call is 'async'}}
Test.test(v) // expected-error {{expression is 'async' but is not marked with 'await'}} expected-note {{call is 'async'}}
Test(v).test(v) // expected-error {{expression is 'async' but is not marked with 'await'}} expected-note {{call is 'async'}}
Test(v).test(v) // expected-error {{expression is 'async' but is not marked with 'await'}} expected-note 2 {{call is 'async'}}
}

View File

@@ -25,9 +25,9 @@ func test_compatibility_coercions(_ arr: [Int], _ optArr: [Int]?, _ dict: [Strin
// Make sure we error on the following in Swift 6 mode.
_ = id(arr) as [String] // expected-error {{conflicting arguments to generic parameter 'T' ('[Int]' vs. '[String]')}}
_ = (arr ?? []) as [String] // expected-error {{conflicting arguments to generic parameter 'T' ('[String]' vs. '[Int]')}}
_ = (arr ?? [] ?? []) as [String] // expected-error {{conflicting arguments to generic parameter 'T' ('[String]' vs. '[Int]')}}
// expected-error@-1{{conflicting arguments to generic parameter 'T' ('[String]' vs. '[Int]')}}
_ = (arr ?? []) as [String] // expected-error {{conflicting arguments to generic parameter 'T' ('[Int]' vs. '[String]')}}
_ = (arr ?? [] ?? []) as [String] // expected-error {{conflicting arguments to generic parameter 'T' ('[Int]' vs. '[String]')}}
// expected-error@-1{{conflicting arguments to generic parameter 'T' ('[Int]' vs. '[String]')}}
_ = (optArr ?? []) as [String] // expected-error {{conflicting arguments to generic parameter 'T' ('[Int]' vs. '[String]'}}
_ = (arr ?? []) as [String]? // expected-error {{'[Int]' is not convertible to '[String]?'}}

View File

@@ -1,6 +1,8 @@
// RUN: %target-typecheck-verify-swift -debug-constraints 2>%t.err
// RUN: %FileCheck %s < %t.err
// REQUIRES: needs_adjustment_for_new_favoring
struct X {
func g(_: Int) -> Int { return 0 }
func g(_: Double) -> Int { return 0 }

View File

@@ -361,3 +361,27 @@ func test_ternary_and_nil_coalescing() {
test(v ?? 0.0) // Ok
}
}
do {
struct G<T> {
init(_: T) {}
}
func round(_: Double) -> Double {}
func round<T: FloatingPoint>(_: T) -> T {}
func test_cgfloat_over_double(withColors colors: Int, size: CGSize) -> G<CGFloat> {
let g = G(1.0 / CGFloat(colors))
return g // Ok
}
func test_no_ambiguity(width: Int, height: Int) -> CGFloat {
let v = round(CGFloat(width / height) * 10) / 10.0
return v // Ok
}
}
func test_cgfloat_operator_is_attempted_with_literal_arguments(v: CGFloat?) {
let ratio = v ?? (2.0 / 16.0)
let _: CGFloat = ratio // Ok
}

View File

@@ -0,0 +1,249 @@
// RUN: %target-typecheck-verify-swift
func entity(_: Int) -> Int {
0
}
struct Test {
func test(_ v: Int) -> Int { v }
func test(_ v: Int?) -> Int? { v }
}
func test_ternary_literal(v: Test) -> Int? {
true ? v.test(0) : nil // Ok
}
func test_ternary(v: Test) -> Int? {
true ? v.test(entity(0)) : nil // Ok
}
do {
struct TestFloat {
func test(_ v: Float) -> Float { v } // expected-note {{found this candidate}}
func test(_ v: Float?) -> Float? { v } // expected-note {{found this candidate}}
}
func test_ternary_non_default_literal(v: TestFloat) -> Float? {
true ? v.test(1.0) : nil // expected-error {{ambiguous use of 'test'}}
}
}
do {
struct Test {
init(a: Int, b: Int = 0) throws {}
init?(a: Int?) {}
}
func test(v: Int) -> Test? {
return Test(a: v) // Ok
}
}
// error: initializer for conditional binding must have Optional type, not 'S'
do {
struct S {
let n: Int
func test(v: String) -> Int { }
func test(v: String, flag: Bool = false) -> Int? { }
func verify(v: String) -> Int? {
guard let _ = test(v: v) else { // Ok
return nil
}
return 0
}
}
func f(_: String, _ p: Bool = false) -> S? {
nil
}
func f(_ x: String) -> S {
fatalError()
}
func g(_ x: String) -> Int? {
guard let y = f(x) else {
return nil
}
return y.n
}
}
// ambiguities related to ~=
protocol _Error: Error {}
extension _Error {
public static func ~=(lhs: Self, rhs: Self) -> Bool {
false
}
public static func ~=(lhs: Error, rhs: Self) -> Bool {
false
}
public static func ~=(lhs: Self, rhs: Error) -> Bool {
false
}
}
enum CustomError {
case A
}
extension CustomError: _Error {}
func f(e: CustomError) {
if e ~= CustomError.A {}
}
// Generic overload should be preferred over concrete one because the latter is non-default literal
struct Pattern {}
func ~= (pattern: Pattern, value: String) -> Bool {
return false
}
extension Pattern: ExpressibleByStringLiteral {
init(stringLiteral value: String) {}
}
func test_default_tilda(v: String) {
_ = "hi" ~= v // Ok
}
struct UUID {}
struct LogKey {
init(base: some CustomStringConvertible, foo: Int = 0) {
}
init(base: UUID, foo: Int = 0) {
}
}
@available(swift 99)
extension LogKey {
init(base: String?) {
}
init(base: UUID?) {
}
}
func test_that_unavailable_init_is_not_used(x: String?) {
_ = LogKey(base: x ?? "??")
}
// error: value of optional type 'UID?' must be unwrapped to a value of type 'UID'
struct S: Comparable {
static func <(lhs: Self, rhs: Self) -> Bool {
false
}
}
func max(_ a: S?, _ b: S?) -> S? {
nil
}
func test_stdlib_max_selection(s: S) -> S {
let new = max(s, s)
return new // Ok
}
// error: initializer for conditional binding must have Optional type, not 'UnsafeMutablePointer<Double>'
do {
struct TestPointerConversions {
var p: UnsafeMutableRawPointer { get { fatalError() } }
func f(_ p: UnsafeMutableRawPointer) {
guard let x = UnsafeMutablePointer<Double>(OpaquePointer(self.p)) else {
return
}
_ = x
guard let x = UnsafeMutablePointer<Double>(OpaquePointer(p)) else {
return
}
_ = x
}
}
}
// error: initializer 'init(_:)' requires that 'T' conform to 'BinaryInteger'
do {
struct Config {
subscript<T>(_ key: String) -> T? { nil }
subscript(_ key: String) -> Any? { nil }
}
struct S {
init(maxQueueDepth: UInt) {}
}
func f(config: Config) {
let maxQueueDepth = config["hi"] ?? 256
_ = S(maxQueueDepth: UInt(maxQueueDepth))
}
}
// swift-distributed-tracing snippet that relies on old hack behavior.
protocol TracerInstant {
}
extension Int: TracerInstant {}
do {
enum SpanKind {
case `internal`
}
func withSpan<Instant: TracerInstant>(
_ operationName: String,
at instant: @autoclosure () -> Instant,
context: @autoclosure () -> Int = 0,
ofKind kind: SpanKind = .internal
) {}
func withSpan(
_ operationName: String,
context: @autoclosure () -> Int = 0,
ofKind kind: SpanKind = .internal,
at instant: @autoclosure () -> some TracerInstant = 42
) {}
withSpan("", at: 0) // Ok
}
protocol ForAssert {
var isEmpty: Bool { get }
}
extension ForAssert {
var isEmpty: Bool { false }
}
do {
func assert(_ condition: @autoclosure () -> Bool, _ message: @autoclosure () -> String = String(), file: StaticString = #file, line: UInt = #line) {}
func assert(_ condition: Bool, _ message: @autoclosure () -> String, file: StaticString = #file, line: UInt = #line) {}
func assert(_ condition: Bool, file: StaticString = #fileID, line: UInt = #line) {}
struct S : ForAssert {
var isEmpty: Bool { false }
}
func test(s: S) {
assert(s.isEmpty, "") // Ok
}
}
extension Double {
public static func * (left: Float, right: Double) -> Double { 0 }
}
func test_non_default_literal_use(arg: Float) {
let v = arg * 2.0 // shouldn't use `(Float, Double) -> Double` overload
let _: Float = v // Ok
}

View File

@@ -330,3 +330,66 @@ enum I60954 {
}
init?<S>(_ string: S) where S: StringProtocol {} // expected-note{{where 'S' = 'I60954'}}
}
infix operator <<<>>> : DefaultPrecedence
protocol P5 {
}
struct Expr : P6 {}
protocol P6: P5 {
}
extension P6 {
public static func <<<>>> (lhs: Self, rhs: (any P5)?) -> Expr { Expr() }
public static func <<<>>> (lhs: (any P5)?, rhs: Self) -> Expr { Expr() }
public static func <<<>>> (lhs: Self, rhs: some P6) -> Expr { Expr() }
public static prefix func ! (value: Self) -> Expr {
Expr()
}
}
extension P6 {
public static func != (lhs: Self, rhs: some P6) -> Expr {
!(lhs <<<>>> rhs) // Ok
}
}
do {
struct Value : P6 {
}
struct Column: P6 {
}
func test(col: Column, val: Value) -> Expr {
col <<<>>> val // Ok
}
func test(col: Column, val: some P6) -> Expr {
col <<<>>> val // Ok
}
func test(col: some P6, val: Value) -> Expr {
col <<<>>> val // Ok
}
}
// Make sure that ?? selects an overload that doesn't produce an optional.
do {
class Obj {
var x: String!
}
class Child : Obj {
func x() -> String? { nil }
static func x(_: Int) -> String { "" }
}
func test(arr: [Child], v: String, defaultV: Child) -> Child {
let result = arr.first { $0.x == v } ?? defaultV
return result // Ok
}
}

View File

@@ -52,7 +52,7 @@ func testPostfix6() {
func testPostfix7() {
1 + 2 * 3.0#^POSTFIX_7^#
}
// POSTFIX_7: Decl[PostfixOperatorFunction]/CurrModule: ***[#Double#]
// POSTFIX_7: Decl[PostfixOperatorFunction]/CurrModule/TypeRelation[Convertible]: ***[#Double#]
func testPostfix8(x: S) {
x#^POSTFIX_8^#

View File

@@ -758,10 +758,10 @@ func invalidDictionaryLiteral() {
//===----------------------------------------------------------------------===//
// nil/metatype comparisons
//===----------------------------------------------------------------------===//
_ = Int.self == nil // expected-warning {{comparing non-optional value of type 'any (~Copyable & ~Escapable).Type' to 'nil' always returns false}}
_ = nil == Int.self // expected-warning {{comparing non-optional value of type 'any (~Copyable & ~Escapable).Type' to 'nil' always returns false}}
_ = Int.self != nil // expected-warning {{comparing non-optional value of type 'any (~Copyable & ~Escapable).Type' to 'nil' always returns true}}
_ = nil != Int.self // expected-warning {{comparing non-optional value of type 'any (~Copyable & ~Escapable).Type' to 'nil' always returns true}}
_ = Int.self == nil // expected-warning {{comparing non-optional value of type 'Int.Type' to 'nil' always returns false}}
_ = nil == Int.self // expected-warning {{comparing non-optional value of type 'Int.Type' to 'nil' always returns false}}
_ = Int.self != nil // expected-warning {{comparing non-optional value of type 'Int.Type' to 'nil' always returns true}}
_ = nil != Int.self // expected-warning {{comparing non-optional value of type 'Int.Type' to 'nil' always returns true}}
_ = Int.self == .none // expected-warning {{comparing non-optional value of type 'any (~Copyable & ~Escapable).Type' to 'Optional.none' always returns false}}
_ = .none == Int.self // expected-warning {{comparing non-optional value of type 'any (~Copyable & ~Escapable).Type' to 'Optional.none' always returns false}}

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -disable-constraint-solver-performance-hacks
// RUN: %target-typecheck-verify-swift
// Self-contained test case
protocol P1 {}; func f<T: P1>(_: T, _: T) -> T { fatalError() }

View File

@@ -0,0 +1,31 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -solver-expression-time-threshold=1
// REQUIRES: asserts,no_asan
// REQUIRES: objc_interop
// FIXME: This should be a scale-test but it doesn't allow passing `%clang-importer-sdk`
// This import is important because it brings CGFloat and
// enables Double<->CGFloat implicit conversion that affects
// literals below.
import Foundation
let p/*: [(String, Bool, Bool, Double)]*/ = [
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0),
("", true, true, 0 * 0.0 * 0.0)
]

View File

@@ -0,0 +1,10 @@
// RUN: %scale-test --begin 1 --end 10 --step 1 --select NumLeafScopes %s
// REQUIRES: asserts,no_asan
let _ = [
0,
%for i in range(2, N+2):
1/${i},
%end
1
] as [Float]

View File

@@ -0,0 +1,19 @@
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
// REQUIRES: OS=macosx,no_asan
// REQUIRES: objc_interop
import Foundation
import CoreGraphics
import simd
func test(
a: CGFloat,
b: CGFloat
) -> CGFloat {
exp(-a * b) *
(a * -sin(a * b) * a + ((a * b + a) / b) * cos(a * b) * a) +
exp(-a * b) *
(-b) *
(a * cos(a * b) + ((a * b + a) / b) * sin(a * b))
}

View File

@@ -0,0 +1,17 @@
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx10.15 -swift-version 5
// REQUIRES: OS=macosx
import SwiftUI
func test(a: [(offset: Int, element: Double)],
c: Color,
x: CGFloat,
n: Int
) -> some View {
ForEach(a, id: \.offset) { i, r in
RoundedRectangle(cornerRadius: r, style: .continuous)
.stroke(c, lineWidth: 1)
.padding(.horizontal, x / Double(n) * Double(n - 1 - i) / 2)
.padding(.vertical, x / Double(n) * Double(n - 1 - i) / 2)
}
}

View File

@@ -0,0 +1,35 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -typecheck -solver-expression-time-threshold=1
// REQUIRES: OS=macosx,no_asan
// REQUIRES: objc_interop
import Foundation
struct CGRect {
var x: CGFloat
init(x: CGFloat, y: CGFloat, width: CGFloat, height: CGFloat) { }
init(x: Double, y: Double, width: Double, height: Double) { }
}
protocol View {}
extension Optional: View where Wrapped: View {}
extension View {
func frame() -> some View { self }
func frame(x: Int, y: Int, w: Int, z: Int) -> some View { self }
func frame(y: Bool) -> some View { self }
}
struct NSView {
var frame: CGRect
}
func test(margin: CGFloat, view: NSView!) -> CGRect {
// `view` is first attempted as `NSView?` and only if that fails is force unwrapped
return CGRect(x: view.frame.x + margin,
y: view.frame.x + margin,
width: view.frame.x - view.frame.x - view.frame.x - (margin * 2),
height: margin)
}

View File

@@ -1,4 +1,4 @@
// RUN: %scale-test --invert-result --begin 1 --end 5 --step 1 --select NumLeafScopes %s
// RUN: %scale-test --begin 1 --end 10 --step 1 --select NumLeafScopes %s
// REQUIRES: asserts,no_asan
func t(_ x: Int?) -> Int {

View File

@@ -5,5 +5,4 @@
func test(bytes: Int, length: UInt32) {
// left-hand side of `>=` is `Int` and right-hand side is a chain of `UInt32` inferred from `length`
_ = bytes >= 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + length
// expected-error@-1 {{reasonable time}}
}

View File

@@ -0,0 +1,134 @@
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
// REQUIRES: tools-release,no_asan
public protocol Applicative {}
public struct Kind<X, Y> {}
public extension Applicative {
static func product<A1,B> (_ fa:Kind<Self,A1>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,B)> {
fatalError()
}
static func product<A1,A2,B> (_ fa:Kind<Self,(A1,A2)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,B)> {
fatalError()
}
static func product<A1,A2,A3,B> (_ fa:Kind<Self,(A1,A2,A3)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,B> (_ fa:Kind<Self,(A1,A2,A3,A4)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,B)> {
fatalError()
}
static func product<A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,A30,B> (_ fa:Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,A30)>, _ fb:Kind<Self,B>) -> Kind<Self,(A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,A30,B)> {
fatalError()
}
}
public extension Applicative {
static func zip<A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29> (_ fa0:Kind<Self,A0>, _ fa1:Kind<Self,A1>, _ fa2:Kind<Self,A2>, _ fa3:Kind<Self,A3>, _ fa4:Kind<Self,A4>, _ fa5:Kind<Self,A5>, _ fa6:Kind<Self,A6>, _ fa7:Kind<Self,A7>, _ fa8:Kind<Self,A8>, _ fa9:Kind<Self,A9>, _ fa10:Kind<Self,A10>, _ fa11:Kind<Self,A11>, _ fa12:Kind<Self,A12>, _ fa13:Kind<Self,A13>, _ fa14:Kind<Self,A14>, _ fa15:Kind<Self,A15>, _ fa16:Kind<Self,A16>, _ fa17:Kind<Self,A17>, _ fa18:Kind<Self,A18>, _ fa19:Kind<Self,A19>, _ fa20:Kind<Self,A20>, _ fa21:Kind<Self,A21>, _ fa22:Kind<Self,A22>, _ fa23:Kind<Self,A23>, _ fa24:Kind<Self,A24>, _ fa25:Kind<Self,A25>, _ fa26:Kind<Self,A26>, _ fa27:Kind<Self,A27>, _ fa28:Kind<Self,A28>, _ fa29:Kind<Self,A29>) -> Kind<Self,(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,A20,A21,A22,A23,A24,A25,A26,A27,A28,A29)> {
product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(product(fa0, fa1), fa2), fa3), fa4), fa5), fa6), fa7), fa8), fa9), fa10), fa11), fa12), fa13), fa14), fa15), fa16), fa17), fa18), fa19), fa20), fa21), fa22), fa23), fa24), fa25), fa26), fa27), fa28), fa29) // Ok
}
}

View File

@@ -5,7 +5,6 @@ let i: Int? = 1
let j: Int?
let k: Int? = 2
// expected-error@+1 {{the compiler is unable to type-check this expression in reasonable time}}
let _ = [i, j, k].reduce(0 as Int?) {
$0 != nil && $1 != nil ? $0! + $1! : ($0 != nil ? $0! : ($1 != nil ? $1! : nil))
}

View File

@@ -2,7 +2,6 @@
// REQUIRES: tools-release,no_asan
func test(n: Int) -> Int {
// expected-error@+1 {{the compiler is unable to type-check this expression in reasonable time}}
return n == 0 ? 0 : (0..<n).reduce(0) {
($0 > 0 && $1 % 2 == 0) ? ((($0 + $1) - ($0 + $1)) / ($1 - $0)) + (($0 + $1) / ($1 - $0)) : $0
}

View File

@@ -14,7 +14,6 @@ func memoize<T: Hashable, U>( body: @escaping ((T)->U, T)->U ) -> (T)->U {
}
let fibonacci = memoize {
// expected-error@-1 {{reasonable time}}
fibonacci, n in
n < 2 ? Double(n) : fibonacci(n - 1) + fibonacci(n - 2)
}

View File

@@ -3,5 +3,4 @@
func rdar31742586() -> Double {
return -(1 + 2) + -(3 + 4) + 5 - (-(1 + 2) + -(3 + 4) + 5)
// expected-error@-1 {{the compiler is unable to type-check this expression in reasonable time}}
}

View File

@@ -3,6 +3,5 @@
func test() {
let _: UInt = 1 * 2 + 3 * 4 + 5 * 6 + 7 * 8 + 9 * 10 + 11 * 12 + 13 * 14
// expected-error@-1 {{the compiler is unable to type-check this expression in reasonable time}}
}

View File

@@ -8,5 +8,4 @@ func wrap<T: ExpressibleByStringLiteral>(_ key: String, _ value: T) -> T { retur
func wrapped() -> Int {
return wrap("1", 1) + wrap("1", 1) + wrap("1", 1) + wrap("1", 1) + wrap("1", 1) + wrap("1", 1)
// expected-error@-1 {{the compiler is unable to type-check this expression in reasonable time}}
}

View File

@@ -9,7 +9,6 @@ func test() {
compute {
print(x)
let v: UInt64 = UInt64((24 / UInt32(1)) + UInt32(0) - UInt32(0) - 24 / 42 - 42)
// expected-error@-1 {{the compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions}}
print(v)
}
}

View File

@@ -1,4 +1,4 @@
// RUN: %scale-test --invert-result --begin 1 --end 5 --step 1 --select NumLeafScopes %s
// RUN: %scale-test --begin 1 --end 5 --step 1 --select NumLeafScopes %s
// REQUIRES: asserts,no_asan

View File

@@ -13,7 +13,7 @@ public class Cookie {
private let fixedByteSize: Int32 = 56
var totalByteCount: Int32 {
return fixedByteSize + // expected-error {{the compiler is unable to type-check this expression in reasonable time}}
return fixedByteSize +
(port != nil ? 2 : 0) +
Int32(comment?.utf8.count ?? 0) +
Int32(commentURL?.utf8.count ?? 0) +

View File

@@ -9,7 +9,7 @@ extension String {
func getProperties(
from ics: String
) -> [(name: String, value: String)] {
return ics // expected-error {{the compiler is unable to type-check this expression in reasonable time}}
return ics
.replacingOccurrences(of: "\r\n ", with: "")
.components(separatedBy: "\r\n")
.map { $0.split(separator: ":", maxSplits: 1, omittingEmptySubsequences: true) }

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -solver-scope-threshold=60000
// RUN: %target-swift-frontend -typecheck %s -solver-scope-threshold=60000
// REQUIRES: tools-release,no_asan
protocol ArgumentProtocol {}
@@ -47,7 +47,7 @@ struct Options {
static func evaluate(_ mode: CommandMode) -> Result<Options, ConcreteError> {
let defaultBuildDirectory = ""
return create // expected-error {{the compiler is unable to type-check this expression in reasonable time}}
return create
<*> mode <| Option(key: "", defaultValue: nil, usage: "")
<*> mode <| Option(key: "", defaultValue: nil, usage: "")
<*> mode <| Option(key: "", defaultValue: FileManager.default.currentDirectoryPath, usage: "")

View File

@@ -2,7 +2,7 @@
// REQUIRES: tools-release,no_asan
func g<T>(_: T) throws {
let _: T? = //expected-error {{the compiler is unable to type-check this expression in reasonable time}}
let _: T? =
(try? f() as? T) ??
(try? f() as? T) ??
(try? f() as? T) ??

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=10
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
// REQUIRES: no_asan
@@ -10,8 +10,11 @@ struct S {
}
}
// Note: One possible approach to this issue would be to determine when the array literal inside of the inner closure
// doesn't have any other possible bindings but Array and attempt it at that point. That would fail overload of flatMap
// that returns an optional value.
func f(x: Array<S>, y: Range<Int>) -> [S] {
return x.flatMap { z in
return x.flatMap { z in // expected-error {{the compiler is unable to type-check this expression in reasonable time}}
return ((y.lowerBound / 1)...(y.upperBound + 1) / 1).flatMap { w in
return [S(1 * Double(w) + 1.0 + z.t),
S(1 * Double(w) + 1.0 - z.t)]

View File

@@ -0,0 +1,18 @@
// RUN: %scale-test --invert-result --begin 1 --end 5 --step 1 --select NumLeafScopes %s -Xfrontend=-typecheck
// REQUIRES: asserts, no_asan
struct Value: RandomAccessCollection, RangeReplaceableCollection {
let startIndex = 0
let endIndex = 0
subscript(_: Int) -> Int { 0 }
func replaceSubrange<C: Collection>(_: Range<Int>, with: C) {}
}
func f(v: Value) {
let _ = v
%for i in range(0, N):
+ v
%end
}

View File

@@ -1,4 +1,4 @@
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1 -disable-constraint-solver-performance-hacks
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
// REQUIRES: tools-release,no_asan
// UNSUPPORTED: swift_test_mode_optimize_none && OS=linux-gnu

View File

@@ -1,3 +1,3 @@
// {"signature":"(anonymous namespace)::ExprWalker::rewriteTarget(swift::constraints::SyntacticElementTarget)"}
// RUN: not --crash %target-swift-frontend -typecheck %s
// RUN: not %target-swift-frontend -typecheck %s
{ Sendable(Sendable<<a

View File

@@ -1,3 +1,3 @@
// {"signature":"(anonymous namespace)::SyntacticElementConstraintGenerator::visitBraceStmt(swift::BraceStmt*)"}
// RUN: not --crash %target-swift-frontend -typecheck %s
// RUN: not %target-swift-frontend -typecheck %s
[ switch { case (let a)print(

View File

@@ -53,8 +53,8 @@ func testMixedSignArithmetic() {
Stride(1) - ${T}(0) // expected-error {{}} expected-note {{}}
var y: Stride = 0
y += ${T}(1) // expected-error {{cannot convert value of type '${T}' to expected argument type 'Int'}} {{10-10=Int(}}
y -= ${T}(1) // expected-error {{cannot convert value of type '${T}' to expected argument type 'Int'}} {{10-10=Int(}}
y += ${T}(1) // expected-error {{cannot convert value of type '${T}' to expected argument type 'Stride' (aka 'Int')}} {{10-10=Stride(}}
y -= ${T}(1) // expected-error {{cannot convert value of type '${T}' to expected argument type 'Stride' (aka 'Int')}} {{10-10=Stride(}}
}
% end
}