content stringlengths 1 103k ⌀ | path stringlengths 8 216 | filename stringlengths 2 179 | language stringclasses 15
values | size_bytes int64 2 189k | quality_score float64 0.5 0.95 | complexity float64 0 1 | documentation_ratio float64 0 1 | repository stringclasses 5
values | stars int64 0 1k | created_date stringdate 2023-07-10 19:21:08 2025-07-09 19:11:45 | license stringclasses 4
values | is_test bool 2
classes | file_hash stringlengths 32 32 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s\n// REQUIRES: objc_interop\n\nimport Foundation\n\nfunc iuo_error(prop: IUOProperty) {\n let _: Coat? = prop.iuo.optional()\n // expected-error@-1 {{value of optional type '(() -> Coat?)?' must be unwrapped}}\n // expected-note@-2{{c... | dataset_sample\swift\apple_swift\test\Constraints\iuo_objc.swift | iuo_objc.swift | Swift | 2,447 | 0.95 | 0 | 0.45614 | react-lib | 191 | 2024-07-20T01:34:55.998872 | Apache-2.0 | true | 3fdf2cd4ae21c5877f66fbfd1dbd92e5 |
// RUN: %target-swift-frontend -enable-experimental-feature KeyPathWithMethodMembers -typecheck -verify %S/Inputs/keypath.swift -primary-file %s\n// REQUIRES: swift_feature_KeyPathWithMethodMembers\n\nstruct S {\n let i: Int\n\n init() {\n let _: WritableKeyPath<S, Int> = \.i // no error for Swift 3/4\n\n S()[k... | dataset_sample\swift\apple_swift\test\Constraints\keypath.swift | keypath.swift | Swift | 12,111 | 0.95 | 0.075581 | 0.222628 | vue-tools | 428 | 2024-06-23T23:43:04.867668 | GPL-3.0 | true | 56355a0c1e03c00187b416244df66d5f |
// RUN: %target-swift-frontend -typecheck -verify -primary-file %s\n\n// rdar://problem/57930643\nstruct School {\n var name: String\n}\nfunc testKeyPathClosureLiteralError() -> [School] {\n let slist = [School(name:"AHS"), School(name:"BHS")]\n return slist.sorted(by: \School.name) // expected-error {{cannot conver... | dataset_sample\swift\apple_swift\test\Constraints\keypath_closure_conv_mismatch.swift | keypath_closure_conv_mismatch.swift | Swift | 397 | 0.95 | 0.1 | 0.222222 | awesome-app | 356 | 2024-11-12T12:35:36.226485 | Apache-2.0 | true | 00c8ca0514a746a002fe8741dd5b86b8 |
// RUN: %target-swift-frontend -typecheck -verify -primary-file %s\n\n// rdar://problem/57930643\nstruct School {\n var name: String\n}\nfunc test<A, B>(_: (A, B) -> Bool) {} // expected-note {{in call to function 'test'}}\ntest(\School.name) // expected-error {{generic parameter 'A' could not be inferred}} // expecte... | dataset_sample\swift\apple_swift\test\Constraints\keypath_closure_conv_mismatch_generic.swift | keypath_closure_conv_mismatch_generic.swift | Swift | 469 | 0.95 | 0.222222 | 0.285714 | node-utils | 364 | 2024-03-10T02:34:13.541451 | MIT | true | d35ddfc0571377d85f088b4c0b7f1274 |
// RUN: %target-swift-frontend -typecheck -verify -primary-file %s\n\n// rdar://problem/57930643\nstruct School {\n var name: String\n}\nfunc testKeyPathClosureLiteralError() {\n let slist = [School(name:"AHS"), School(name:"BHS")]\n _ = slist.sorted(by: \School.name) // expected-error {{cannot convert key path into... | dataset_sample\swift\apple_swift\test\Constraints\keypath_closure_conv_mismatch_norettype.swift | keypath_closure_conv_mismatch_norettype.swift | Swift | 382 | 0.95 | 0.1 | 0.222222 | react-lib | 232 | 2025-03-29T02:17:23.985832 | GPL-3.0 | true | aec52b3609e22b10f209782678ef5bab |
// RUN: %target-swift-frontend -Xllvm -sil-print-types -emit-sil -verify -Xllvm -sil-disable-pass=simplification %s | %FileCheck %s\n\nstruct Point {\n let x: Int\n var y: Int\n}\n\nstruct Rectangle {\n var topLeft, bottomRight: Point\n}\n\n@dynamicMemberLookup\nstruct Lens<T> {\n var obj: T\n\n init(_ obj: T) {\n... | dataset_sample\swift\apple_swift\test\Constraints\keypath_dynamic_member_lookup.swift | keypath_dynamic_member_lookup.swift | Swift | 32,560 | 0.95 | 0.016071 | 0.302222 | node-utils | 970 | 2023-12-28T02:50:35.230312 | MIT | true | b4da11d0d72f0b3a4dae43576e95ad24 |
// RUN: %target-swift-frontend -typecheck -verify %S/Inputs/keypath.swift -primary-file %s -swift-version 5\n\nstruct S {\n let i: Int\n\n init() {\n let _: WritableKeyPath<S, Int> = \.i // expected-error {{cannot convert key path type 'KeyPath<S, Int>' to contextual type 'WritableKeyPath<S, Int>'}}\n\n S()[key... | dataset_sample\swift\apple_swift\test\Constraints\keypath_swift_5.swift | keypath_swift_5.swift | Swift | 1,113 | 0.8 | 0.027778 | 0.111111 | react-lib | 736 | 2025-06-17T18:37:05.176917 | GPL-3.0 | true | da11c0d74f8eb6380d6c0d4ba80da1db |
// RUN: %target-typecheck-verify-swift\n\nfunc f0(_ x: inout Int) {}\nfunc f1<T>(_ x: inout T) {}\nfunc f2(_ x: inout X) {}\nfunc f2(_ x: inout Double) {}\n\nclass Reftype {\n var property: Double { get {} set {} }\n}\n\nstruct X {\n subscript(i: Int) -> Float { get {} set {} }\n\n var property: Double { get {} set ... | dataset_sample\swift\apple_swift\test\Constraints\lvalues.swift | lvalues.swift | Swift | 11,340 | 0.95 | 0.016026 | 0.149798 | react-lib | 421 | 2024-12-14T19:03:18.603002 | BSD-3-Clause | true | fcc58c3aa394ac02c58df85b9b239439 |
// RUN: %target-typecheck-verify-swift -swift-version 5\n\n////\n// Members of structs\n////\n\nstruct X {\n func f0(_ i: Int) -> X { }\n\n func f1(_ i: Int) { }\n\n mutating func f1(_ f: Float) { }\n\n func f2<T>(_ x: T) -> T { }\n}\n\nstruct Y<T> {\n func f0(_: T) -> T {}\n func f1<U>(_ x: U, y: T) -> (T, U) {}... | dataset_sample\swift\apple_swift\test\Constraints\members.swift | members.swift | Swift | 28,284 | 0.95 | 0.089517 | 0.14202 | vue-tools | 402 | 2024-05-25T23:59:58.032383 | BSD-3-Clause | true | f59635a4c5e72170ede0ce20d2c1c649 |
// RUN: %target-typecheck-verify-swift -enable-objc-interop\n\nimport Swift\n\n@objc\nprotocol P2 {\n func bar(_ x: Int)\n static func pub(_ x: Int)\n}\n\nfunc existential(_ p2 : P2) {\n _ = p2.bar\n _ = P2.bar\n}\n\nfunc archetype<T: P2>(_ p2 : T) {\n _ = p2.bar\n _ = T.bar\n _ = T.pub\n}\n\n// rdar://problem/2... | dataset_sample\swift\apple_swift\test\Constraints\members_objc.swift | members_objc.swift | Swift | 728 | 0.95 | 0.058824 | 0.074074 | awesome-app | 770 | 2024-02-17T09:09:38.939283 | Apache-2.0 | true | d6dd1eeb7325d877d967c4f97b71bd9c |
// RUN: %target-typecheck-verify-swift\n\nclass A {}\nclass B : A {}\n\nlet test0 : A.Type = A.self\nlet test1 : A.Type = B.self\nlet test2 : B.Type = A.self // expected-error {{cannot convert value of type 'A.Type' to specified type 'B.Type'}}\nlet test3 : AnyClass = A.self\nlet test4 : AnyClass = B.self\n\nstruct S {... | dataset_sample\swift\apple_swift\test\Constraints\metatypes.swift | metatypes.swift | Swift | 1,410 | 0.95 | 0.096774 | 0.227273 | python-kit | 188 | 2024-01-13T12:06:38.137233 | GPL-3.0 | true | 28fd8dad759ee114f79eac2284d35ac2 |
// RUN: %target-swift-frontend -typecheck -verify %s\n\n// Tuples with noncopyable elements are not yet supported. Make sure we reject\n// them when code attempts to form such a type explicitly or by inference.\n\n struct Butt: ~Copyable {\n var x: Int\n}\n\nstruct Foo: ~Copyable {\n var t: (Int, Butt) // expecte... | dataset_sample\swift\apple_swift\test\Constraints\moveonly_tuples.swift | moveonly_tuples.swift | Swift | 1,039 | 0.8 | 0 | 0.142857 | vue-tools | 836 | 2024-07-17T17:40:03.565557 | GPL-3.0 | true | 3c83e44b3d8731b7f0394c8bc0240882 |
// RUN: %target-swift-frontend -typecheck -verify -swift-version 5 %s\n\nprotocol P {}\n\nstruct Foo {\n mutating func boom() {}\n}\n\nlet x = Foo.boom // expected-error{{cannot reference 'mutating' method as function value}}\nvar y = Foo()\nlet z0 = y.boom // expected-error{{cannot reference 'mutating' method as func... | dataset_sample\swift\apple_swift\test\Constraints\mutating_members.swift | mutating_members.swift | Swift | 1,524 | 0.95 | 0.361111 | 0.034483 | awesome-app | 629 | 2024-04-20T01:35:52.493084 | BSD-3-Clause | true | 996c20a69e29fc4c06aafe8926d8fe88 |
// RUN: %target-swift-frontend -typecheck -verify -swift-version 4 %s\n\nprotocol P {}\n\nstruct Foo {\n mutating func boom() {}\n}\n\nlet x = Foo.boom // expected-warning{{cannot reference 'mutating' method as function value; calling the function has undefined behavior and will be an error in future Swift versions}}\... | dataset_sample\swift\apple_swift\test\Constraints\mutating_members_compat.swift | mutating_members_compat.swift | Swift | 1,896 | 0.95 | 0.472222 | 0.034483 | awesome-app | 568 | 2024-12-29T02:09:52.274894 | MIT | true | 4cd93789ccae3a3fc3c85bd8a5aa4e27 |
// RUN: %target-typecheck-verify-swift\n\nstruct G<T> {\n init() {}\n init<U>(x:G<U>) { }\n\n func foo<U>(_ x: G<U>) { }\n\n func bar<U>(_ x: U) { }\n\n static func static_foo<U>(_ x: G<U>) { }\n static func static_bar<U>(_ x: U) { }\n}\n\ntypealias GInt = G<Int>\ntypealias GChar = G<UnicodeScalar>\nGInt(x: GChar... | dataset_sample\swift\apple_swift\test\Constraints\nested_generics.swift | nested_generics.swift | Swift | 418 | 0.8 | 0 | 0.0625 | python-kit | 4 | 2024-01-28T21:52:38.814794 | Apache-2.0 | true | 44a41548da3513507ceeede230147932 |
// RUN: %target-typecheck-verify-swift -target %target-swift-5.9-abi-triple\n\nfunc sameType<T>(_: T.Type, _: T.Type) {}\n\ntypealias A<each T, U, V> = (repeat (each T, U, V))\n\nstruct G<each T> {\n typealias B<each U, V> = (repeat A<repeat each T, each U, V>)\n\n struct H<each U> {\n typealias C<each V> = (repea... | dataset_sample\swift\apple_swift\test\Constraints\nested_pack_expansion.swift | nested_pack_expansion.swift | Swift | 2,902 | 0.8 | 0 | 0.041667 | react-lib | 593 | 2025-01-29T05:14:25.542382 | GPL-3.0 | true | 35c89b8499622ea00124d1e52782520a |
// RUN: %target-swift-frontend -dump-ast %s | %FileCheck %s\n\nstruct B {\n static var _none: B { B() }\n}\n\nstruct A {\n init(_ other: B) {}\n // CHECK: constructor_decl{{.*}}interface_type="(A.Type) -> (B?) -> A"\n init(_ other: B?) {\n // CHECK: dot_syntax_call_expr type="(B) -> A"\n self.init(other ?? ._... | dataset_sample\swift\apple_swift\test\Constraints\nil-coalescing-favoring.swift | nil-coalescing-favoring.swift | Swift | 321 | 0.8 | 0 | 0.25 | awesome-app | 278 | 2024-03-27T16:44:01.507884 | Apache-2.0 | true | 339c43e79bf6df286f414c4455549dd3 |
// RUN: %target-typecheck-verify-swift\n// REQUIRES: differentiable_programming\n\nimport _Differentiation\n\n// Allow Type -> @noDerivative Type\n//\nfunc test1(_ foo: @escaping @differentiable(reverse) (Float, Float) -> Float) {\n let fn: @differentiable(reverse) (Float, @noDerivative Float) -> Float = foo\n _ ... | dataset_sample\swift\apple_swift\test\Constraints\noderivative.swift | noderivative.swift | Swift | 1,016 | 0.95 | 0.076923 | 0.409091 | vue-tools | 258 | 2024-03-02T14:01:39.417371 | GPL-3.0 | true | 8af08c34af5bbec634ec0ecf42c80745 |
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s\n// REQUIRES: objc_interop\n\nimport Foundation\n\n@objc protocol P {\n @objc optional static func test(a: UnsafePointer<Int>, _: Int)\n // expected-note@-1 {{candidate has partially matching parameter list (a: UnsafePointer<Int>, Int... | dataset_sample\swift\apple_swift\test\Constraints\objc_optional_methods_diagnostics.swift | objc_optional_methods_diagnostics.swift | Swift | 715 | 0.95 | 0.05 | 0.25 | node-utils | 564 | 2024-01-23T14:10:40.355754 | Apache-2.0 | true | f136f5c00b79733eb0b3d92e0e660c44 |
// RUN: %empty-directory(%t/src)\n// RUN: %empty-directory(%t/sdk)\n// RUN: split-file %s %t/src\n\n// RUN: %target-swift-frontend -emit-module %t/src/Test.swift \\n// RUN: -module-name Test -swift-version 5 -enable-library-evolution \\n// RUN: -emit-module-path %t/Test.swiftmodule\n\n// RUN: %target-swift-frontend... | dataset_sample\swift\apple_swift\test\Constraints\observable_macro_shadowing.swift | observable_macro_shadowing.swift | Swift | 902 | 0.95 | 0.026316 | 0.428571 | react-lib | 643 | 2025-03-12T20:26:14.706260 | MIT | true | 596b44fe1237730647bd8e4c6664942b |
// RUN: %target-typecheck-verify-swift -target %target-swift-5.9-abi-triple\n\nlet t1: (_: Int) = (_: 3)\n\n// FIXME: diag::tuple_single_element should be diagnosed in the constraint system\n// instead of MiscDiagnostics, which will allow the compiler to emit that\n// error instead of bogus type mismatches for tuple ex... | dataset_sample\swift\apple_swift\test\Constraints\one_element_tuple.swift | one_element_tuple.swift | Swift | 971 | 0.8 | 0.034483 | 0.409091 | vue-tools | 320 | 2025-05-18T23:55:16.162190 | GPL-3.0 | true | 47eff1e5b446ea9bd7138a3f49659e61 |
// RUN: %target-typecheck-verify-swift -target %target-swift-5.7-abi-triple -dump-ast | %FileCheck %s\n\n/// Used to verify the type of an expression. Use like this:\n/// ```\n/// var types = SwiftTypePair(typeOf: expr, type2: SwiftType<Int>.self)\n/// types.assertTypesAreEqual()\n/// ```\nstruct SwiftType<T> {}\nstruc... | dataset_sample\swift\apple_swift\test\Constraints\opened_existentials.swift | opened_existentials.swift | Swift | 19,010 | 0.95 | 0.029982 | 0.217489 | awesome-app | 276 | 2024-11-17T02:40:19.962704 | Apache-2.0 | true | 054bb703687bc4da95080070b5e662a8 |
// RUN: %target-typecheck-verify-swift -target %target-swift-5.9-abi-triple\n\ndo {\n protocol P {}\n struct S<each T> {}\n\n func foo<T: P>(_: T, _: Optional<S<T>> = nil) {}\n\n let p: any P\n foo(p) // OK\n}\n | dataset_sample\swift\apple_swift\test\Constraints\opened_existentials_default_arg.swift | opened_existentials_default_arg.swift | Swift | 205 | 0.8 | 0 | 0.125 | awesome-app | 20 | 2023-07-20T20:08:16.885934 | MIT | true | df04f3931a2e308667c44b3d8805227f |
// RUN: %target-typecheck-verify-swift -enable-upcoming-feature ImplicitOpenExistentials\n// RUN: %target-typecheck-verify-swift -swift-version 6\n\n// REQUIRES: swift_feature_ImplicitOpenExistentials\n\n#if _runtime(_ObjC)\n@objc\nprotocol X {}\n\nfunc foo<T: X>(_ val: T.Type) {}\n\nfunc bar(_ val: X.Type) {\n // Onl... | dataset_sample\swift\apple_swift\test\Constraints\opened_existentials_feature.swift | opened_existentials_feature.swift | Swift | 496 | 0.8 | 0.045455 | 0.375 | awesome-app | 150 | 2025-04-13T00:31:41.808654 | Apache-2.0 | true | 95edd169ebf6e6c65da3e0b22b45c98f |
// RUN: %target-swift-frontend -typecheck -dump-ast -parse-as-library %s | %FileCheck %s\n\nprotocol P { }\nextension Optional: P where Wrapped: P { }\n\nfunc acceptsBox<T>(_ value: T) { }\nfunc acceptsBoxType<T>(_ value: T.Type) { }\n\n// CHECK: passBox\n// CHECK-NOT: open_existential_expr\nfunc passBox(p: P, obj: Any... | dataset_sample\swift\apple_swift\test\Constraints\opened_existentials_suppression.swift | opened_existentials_suppression.swift | Swift | 511 | 0.8 | 0 | 0.176471 | react-lib | 227 | 2025-07-07T17:32:06.596526 | MIT | true | 92aa20583d3cb587752adabb6a883976 |
// RUN: %target-swift-frontend -emit-ir %s\n\npublic func fetch() {\n sryMap { return "" }\n .napError{ $0.abc() }\n}\n\npublic func sryMap<String>(_ transform: () -> String) -> SryMap<String> {\n fatalError()\n}\n\npublic protocol MyError {}\nextension MyError {\n public func abc() -> Void { }\n}\n\npublic protoco... | dataset_sample\swift\apple_swift\test\Constraints\opened_existentials_type_variable.swift | opened_existentials_type_variable.swift | Swift | 559 | 0.95 | 0.035714 | 0.045455 | vue-tools | 500 | 2024-06-29T10:17:59.590648 | MIT | true | 7fd0a8d9f17963a4e1aaaac13a7a4fab |
// RUN: %target-typecheck-verify-swift\n\nprotocol P { }\n\nfunc foo<T: P>(_: T) {}\nfunc bar<T: P>(_: T.Type) {}\n\nfunc open(existential: P, mutExistential: inout P) {\n _openExistential(existential, do: foo)\n _openExistential(type(of: existential), do: bar)\n _openExistential(mutExistential, do: foo)\n _openExi... | dataset_sample\swift\apple_swift\test\Constraints\openExistential.swift | openExistential.swift | Swift | 571 | 0.8 | 0.043478 | 0.058824 | node-utils | 575 | 2024-05-31T18:12:13.181694 | GPL-3.0 | true | 817f8087c84c922aa4d12a3954d0617c |
// RUN: %target-typecheck-verify-swift\n\n// https://github.com/apple/swift/issues/43735\n// Test constraint simplification of chains of binary operators.\ndo {\n let a: String? = "a"\n let b: String? = "b"\n let c: String? = "c"\n let _: String? = a! + b! + c!\n\n let x: Double = 1\n _ = x + x + x\n\n // https:... | dataset_sample\swift\apple_swift\test\Constraints\operator.swift | operator.swift | Swift | 8,731 | 0.95 | 0.030211 | 0.146154 | node-utils | 167 | 2024-02-04T05:49:49.297206 | Apache-2.0 | true | a1765756e9124bd18535da6d51da3d1e |
// RUN: %target-typecheck-verify-swift -swift-version 4\n\n\n// rdar://problem/31592529\ninfix operator <=< : BitwiseShiftPrecedence\ninfix operator >=> : BitwiseShiftPrecedence\n\npublic protocol P {}\n\nextension P {\n public static func <=< <Other : P>(_ x: Self, _ y: Other) { }\n\n @available(swift, obsoleted: 4)... | dataset_sample\swift\apple_swift\test\Constraints\operator_availability.swift | operator_availability.swift | Swift | 822 | 0.8 | 0 | 0.090909 | python-kit | 308 | 2024-09-15T05:22:01.670243 | MIT | true | be27d8de6639a2931e7548eca4860059 |
// RUN: %target-typecheck-verify-swift\n\n// REQUIRES: objc_interop\n\nfunc markUsed<T>(_ t: T) {}\n\nclass A {\n @objc func do_a() {}\n\n @objc(do_b_2:) func do_b(_ x: Int) {}\n @objc func do_b(_ x: Float) {}\n\n @objc func do_c(x: Int) {} // expected-note {{incorrect labels for candidate (have: '(_:)', expected: ... | dataset_sample\swift\apple_swift\test\Constraints\optional.swift | optional.swift | Swift | 19,618 | 0.95 | 0.060302 | 0.154812 | node-utils | 45 | 2024-08-10T04:19:48.329517 | BSD-3-Clause | true | c654177bfd079772a5336e50f541fa6f |
// RUN: %target-typecheck-verify-swift\n\nfunc markUsed<T>(_ t: T) {}\n\nfunc f0(_: Float) -> Float {}\n// expected-note@-1 {{candidate expects value of type 'Float' for parameter #1 (got 'X')}}\nfunc f0(_: Int) -> Int {}\n// expected-note@-1 {{candidate expects value of type 'Int' for parameter #1 (got 'X')}}\n\nfunc ... | dataset_sample\swift\apple_swift\test\Constraints\overload.swift | overload.swift | Swift | 11,675 | 0.95 | 0.096866 | 0.175824 | python-kit | 181 | 2024-11-20T19:40:21.928145 | MIT | true | a860811b915994836fc1fdc870fea7c0 |
// RUN: %target-typecheck-verify-swift -debug-constraints 2>%t.err\n// RUN: %FileCheck %s < %t.err\n\n// This test ensures that we are filtering out overloads based on argument\n// labels, arity, etc., before those terms are visited. \n\nfunc foo(_: Int) { }\nfunc foo(_: Int, _: Int) { }\nfunc foo(_: Int, _: Int, _: In... | dataset_sample\swift\apple_swift\test\Constraints\overload_filtering.swift | overload_filtering.swift | Swift | 2,869 | 0.8 | 0.014286 | 0.466667 | python-kit | 619 | 2024-10-14T08:08:48.387590 | BSD-3-Clause | true | cbc984cf4d45c99da9f477cda4b9d699 |
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s -debug-constraints 2>%t.err\n// RUN: %FileCheck %s < %t.err\n\n// REQUIRES: objc_interop\n\n// This test ensures that we are filtering out overloads based on argument\n// labels, arity, etc., before those terms are visited. \n\nimport F... | dataset_sample\swift\apple_swift\test\Constraints\overload_filtering_objc.swift | overload_filtering_objc.swift | Swift | 914 | 0.95 | 0 | 0.352941 | vue-tools | 593 | 2024-06-23T01:17:48.999986 | BSD-3-Clause | true | 1022ee916364e5be346a9d7e5a3a85d7 |
// RUN: %target-typecheck-verify-swift\n\nclass Base {\n func foo() {}\n}\n\nclass Sub: Base {\n override func foo() {}\n}\n\nfunc removeOverrides<SomeSub: Sub>(concrete: Sub, generic: SomeSub) {\n concrete.foo()\n generic.foo()\n}\n\nclass Base1 {\n func foo1(a : Int, b : @escaping () -> ()) {} // expected-note{{p... | dataset_sample\swift\apple_swift\test\Constraints\override.swift | override.swift | Swift | 1,481 | 0.95 | 0.1875 | 0.04 | python-kit | 372 | 2024-07-03T09:45:33.980457 | GPL-3.0 | true | 44fac78dd3232a23b558aa7f4c3ec1da |
// RUN: %target-typecheck-verify-swift -target %target-swift-5.9-abi-triple\n\nfunc tuplify<each T>(_ t: repeat each T) -> (repeat each T) {\n return (repeat each t)\n}\n\nfunc prepend<First, each Rest>(value: First, to rest: repeat each Rest) -> (First, repeat each Rest) {\n return (value, repeat each rest)\n}\n\nfu... | dataset_sample\swift\apple_swift\test\Constraints\pack-expansion-expressions.swift | pack-expansion-expressions.swift | Swift | 27,842 | 0.95 | 0.0225 | 0.157729 | awesome-app | 201 | 2023-08-05T11:53:57.172137 | MIT | true | 6dae78dd3dcb47f8c9dbf0c9a5ad7702 |
// RUN: %target-typecheck-verify-swift\n\nfunc returnTuple1<each T>() -> (repeat each T) { fatalError() }\n// expected-note@-1 {{in call to function 'returnTuple1()'}}\n\nfunc returnTuple2<each T>() -> (Int, repeat each T) { fatalError() }\n// expected-note@-1 2 {{in call to function 'returnTuple2()'}}\n\nfunc returnTu... | dataset_sample\swift\apple_swift\test\Constraints\pack_expansion_types.swift | pack_expansion_types.swift | Swift | 15,497 | 0.95 | 0.023179 | 0.195455 | node-utils | 701 | 2024-07-17T18:25:25.333247 | MIT | true | 43244182c25bbdd6ba12cc7c61c4d518 |
// RUN: %target-typecheck-verify-swift -disable-availability-checking\n\nprotocol P<A> {\n associatedtype A\n\n func f() -> A\n}\n\nfunc f1(x: any P) -> any P<Int> {\n // FIXME: Bad diagnostic\n return x // expected-error {{type of expression is ambiguous without a type annotation}}\n}\n\nfunc f2(x: any P<Int>) -> ... | dataset_sample\swift\apple_swift\test\Constraints\parameterized_existentials.swift | parameterized_existentials.swift | Swift | 1,938 | 0.8 | 0 | 0.166667 | python-kit | 94 | 2024-11-17T19:43:21.524660 | GPL-3.0 | true | 9d98e33628680c28a6ff3a6f986e1f62 |
// RUN: %target-typecheck-verify-swift\n\n// We used to accept this in Swift 6.0, but it's incorrect;\n// the primary associated types of a derived protocol might\n// be completely unrelated to those of a base protocol.\n\nprotocol P<A> : Q {\n associatedtype A\n}\n\nprotocol Q<B> {\n associatedtype B\n\n func getB(... | dataset_sample\swift\apple_swift\test\Constraints\parameterized_existential_unrelated_args.swift | parameterized_existential_unrelated_args.swift | Swift | 1,156 | 0.8 | 0 | 0.275 | python-kit | 843 | 2023-09-30T03:01:42.657648 | Apache-2.0 | true | cd04774768314557035766e1ff2604db |
// RUN: %target-typecheck-verify-swift\n\n// Leaf expression patterns are matched to corresponding pieces of a switch\n// subject (TODO: or ~= expression) using ~= overload resolution.\nswitch (1, 2.5, "three") {\ncase (1, _, _):\n ()\n// Double is ExpressibleByIntegerLiteral\ncase (_, 2, _),\n (_, 2.5, _),\n ... | dataset_sample\swift\apple_swift\test\Constraints\patterns.swift | patterns.swift | Swift | 23,394 | 0.95 | 0.155718 | 0.139568 | python-kit | 288 | 2025-02-25T13:33:57.634894 | GPL-3.0 | true | d718790f24b4154e9ee5fe86657503f6 |
// RUN: %target-typecheck-verify-swift\n\n// This is an elaborate reduction for a problem where we create a TypeAliasType\n// with a concrete underlying type, but type variables in its substitutions.\n//\n// Specifically, we get something like `G<$1, $2>.B` below, but the underlying\n// type of B is just S, it does not... | dataset_sample\swift\apple_swift\test\Constraints\phantom_existential_typealias.swift | phantom_existential_typealias.swift | Swift | 998 | 0.8 | 0.02439 | 0.28125 | python-kit | 551 | 2024-01-02T01:46:45.928785 | GPL-3.0 | true | ddc0994beef49c709cd81a4083ad4546 |
// RUN: %target-swift-ide-test -code-completion -source-filename=%s -code-completion-token=CC\n\n// PR #39543: Make sure we can complete in this position without crashing.\nextension String {\n init(format: String, _: Any) { fatalError() }\n}\nextension RandomAccessCollection {\n func foo() {\n print(String(format... | dataset_sample\swift\apple_swift\test\Constraints\pr39543.swift | pr39543.swift | Swift | 380 | 0.8 | 0 | 0.2 | awesome-app | 841 | 2024-04-20T05:11:55.444973 | BSD-3-Clause | true | 10e582f941dac5213a29c70effdfea63 |
// RUN: %target-typecheck-verify-swift\n\nprotocol Fooable { func foo() }\nprotocol Barable { func bar() }\n\nextension Int : Fooable, Barable {\n func foo() {}\n func bar() {}\n}\n\nextension Float32 : Barable {\n func bar() {}\n}\n\nfunc f0(_: Barable) {}\nfunc f1(_ x: Fooable & Barable) {}\nfunc f2(_: Float) {}\n... | dataset_sample\swift\apple_swift\test\Constraints\protocols.swift | protocols.swift | Swift | 16,749 | 0.95 | 0.022453 | 0.126437 | node-utils | 334 | 2023-09-13T13:19:51.674742 | BSD-3-Clause | true | f1985a420f66c4bc4136325a96fa60e7 |
// RUN: %target-swift-emit-silgen -Xllvm -sil-print-types %s -verify -swift-version 5 | %FileCheck %s\n\nprotocol P {\n var p: P { get set }\n var q: P? { get set }\n func p(_: P)\n func q(_: P)\n}\n\nstruct S : P {\n var p: P\n var q: P?\n func p(_: P) {}\n func q(_: P) {}\n}\n\nclass Base : P {\n var p: P\n ... | dataset_sample\swift\apple_swift\test\Constraints\ranking.swift | ranking.swift | Swift | 16,823 | 0.95 | 0.026549 | 0.305913 | python-kit | 351 | 2024-09-02T20:08:07.175784 | MIT | true | 7eb71eadc9ae817d328ea3e0548f3a00 |
// RUN: %target-typecheck-verify-swift\n\n// We have a special ranking rule that only currently applies to constructors,\n// and compares the concrete parameter types.\n\nprotocol P {\n init()\n}\n\n// We currently only apply the constructor ranking rule to X() and not X.init().\nstruct S<T : P> {\n init(_ x: T = .in... | dataset_sample\swift\apple_swift\test\Constraints\ranking_ambiguities.swift | ranking_ambiguities.swift | Swift | 2,358 | 0.8 | 0.026667 | 0.177419 | python-kit | 718 | 2024-10-07T05:11:12.732854 | Apache-2.0 | true | 5670466297c54812a38d655eff4f8d0e |
// RUN: %target-typecheck-verify-swift\n\n// rdar://105080067 - This isn't currently allowed but make sure we don't\n// emit a spurious "cannot reference invalid declaration" error.\nfor b in [true] where if b { true } else { false } {}\n// expected-error@-1 {{'if' may only be used as expression in return, throw, or as... | dataset_sample\swift\apple_swift\test\Constraints\rdar105080067.swift | rdar105080067.swift | Swift | 346 | 0.8 | 0.5 | 0.8 | vue-tools | 435 | 2025-02-17T13:02:55.528640 | BSD-3-Clause | true | e9f3949f3968b15455afccf45d128fde |
// RUN: %target-typecheck-verify-swift\n\n// rdar://105781521\nenum MyEnum {\n case first(String)\n}\n\nfunc takeClosure(_ x: () -> Void) {}\n\nfunc test(value: MyEnum) {\n takeClosure {\n switch value {\n case .first(true):\n // expected-error@-1 {{expression pattern of type 'Bool' cannot match values of ... | dataset_sample\swift\apple_swift\test\Constraints\rdar105781521.swift | rdar105781521.swift | Swift | 372 | 0.8 | 0.05 | 0.176471 | react-lib | 531 | 2025-01-20T23:39:43.769273 | BSD-3-Clause | true | 3885c9060ec1c7f04745c0a5d6155227 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://105782480\nenum MyEnum {\n case second(Int?)\n}\n\nfunc takeClosure(_ x: () -> Void) {}\n\nfunc foo(value: MyEnum) {\n takeClosure {\n switch value {\n case .second(let drag).invalid:\n // expected-error@-1 {{value of type 'MyEnum' has no member 'invalid'... | dataset_sample\swift\apple_swift\test\Constraints\rdar105782480.swift | rdar105782480.swift | Swift | 418 | 0.8 | 0.052632 | 0.25 | react-lib | 345 | 2023-09-24T05:52:08.005860 | MIT | true | df8ac6ffabc33bd81925414ee21a2270 |
// RUN: %target-typecheck-verify-swift\n\nenum E: Error { case e }\n\n// rdar://106598067 – Make sure we don't crash.\nlet fn = {\n do {} catch let x as? E {}\n // expected-error@-1 {{cannot conditionally downcast in a type-casting pattern}}{{23-24=}}\n // expected-error@-2 {{expression pattern of type 'E?' cannot m... | dataset_sample\swift\apple_swift\test\Constraints\rdar106598067.swift | rdar106598067.swift | Swift | 1,032 | 0.8 | 0.125 | 0.47619 | python-kit | 775 | 2024-10-16T22:24:04.690567 | BSD-3-Clause | true | 4a93e748a9d350617a627c55023ff325 |
// RUN: %target-typecheck-verify-swift\n\nenum E {\n case e\n}\n\nfunc ~= (lhs: any Error, rhs: E) -> Bool { true }\n\n// rdar://107420031 – Make sure we don't crash.\n// TODO: This ought to compile.\nfunc foo(_ error: any Error) {\n switch error {\n case E.e: // expected-error {{pattern of type 'E' cannot match 'an... | dataset_sample\swift\apple_swift\test\Constraints\rdar107420031.swift | rdar107420031.swift | Swift | 358 | 0.8 | 0.055556 | 0.2 | python-kit | 501 | 2024-02-16T14:27:06.361552 | Apache-2.0 | true | 4d1594db7cd148c2c5ca7350fbca1098 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://107651291 – Make sure we don't crash\nfunc foo(xs: [String: [String]], ys: [String: [String]]) {\n for (key, value) in xs {\n guard let ys = ys.first(where: { $0.key == key }) else { return }\n for (a, b) in zip(xs, ys) {}\n // expected-error@-1 {{type 'Dict... | dataset_sample\swift\apple_swift\test\Constraints\rdar107651291.swift | rdar107651291.swift | Swift | 703 | 0.95 | 0.25 | 0.454545 | python-kit | 65 | 2024-06-16T13:30:44.522946 | MIT | true | 72d11947c5320bdad243b6302e7ab027 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://107709341 – Make sure we don't crash.\nfunc foo(_ x: Int) {\n let _ = {\n switch x {\n case Optional<Int>.some(x): // expected-error {{pattern of type 'Optional<Int>' cannot match 'Int'}} {{none}}\n break\n default:\n break\n }\n }\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar107709341.swift | rdar107709341.swift | Swift | 301 | 0.8 | 0.076923 | 0.166667 | node-utils | 386 | 2024-04-25T02:48:54.009369 | MIT | true | 2fd1446bce100d2ebd68946b089be0c9 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://107724970 – Make sure we don't crash.\nenum E {\n case e(Int)\n}\nfunc foo(_ x: E) {\n // https://github.com/apple/swift/issues/65062\n let fn = {\n switch x {\n case E.e(_, _):\n // expected-error@-1 {{tuple pattern has the wrong length for tuple type '... | dataset_sample\swift\apple_swift\test\Constraints\rdar107724970.swift | rdar107724970.swift | Swift | 342 | 0.8 | 0.125 | 0.266667 | node-utils | 589 | 2024-11-17T03:22:20.413216 | MIT | true | acac31f86784231991de2a165e3a27f8 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://108738034: Make sure we can type-check this.\nenum E<T>: Error {\n case e(T)\n}\n\nstruct S {\n func bar(_: (Error?) -> Void) {}\n}\n\nfunc foo(_ s: S) {\n s.bar { error in\n guard let error = error else {\n return\n }\n if case let E<Int>.e(y... | dataset_sample\swift\apple_swift\test\Constraints\rdar108738034.swift | rdar108738034.swift | Swift | 349 | 0.8 | 0.047619 | 0.111111 | awesome-app | 313 | 2025-01-19T14:24:18.350779 | Apache-2.0 | true | 61546a948655a1a5b0dd0622ce4f98b2 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://109419240 – Make sure we don't crash\nenum E { // expected-note {{'E' declared here}}\n case e(Int)\n}\n\nfunc foo(_ arr: [E]) -> Int {\n return arr.reduce(0) { (total, elem) -> Int in\n switch elem {\n case let e(x): // expected-error {{cannot find 'e' in sco... | dataset_sample\swift\apple_swift\test\Constraints\rdar109419240.swift | rdar109419240.swift | Swift | 371 | 0.8 | 0.066667 | 0.153846 | vue-tools | 782 | 2025-04-17T04:15:59.611706 | MIT | true | c64c1431e2d3744062e24752802f45b6 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://110617471: Make sure we can type-check this.\nclass C {\n var prop = 0\n}\n\nfunc foo(_ fn: () -> Void) {}\n\nclass D {\n let c = C()\n\n func bar() {\n foo { [c] in\n foo {\n switch 0 {\n case c.prop:\n break\n default:\n ... | dataset_sample\swift\apple_swift\test\Constraints\rdar110617471.swift | rdar110617471.swift | Swift | 342 | 0.95 | 0.12 | 0.095238 | python-kit | 97 | 2024-11-02T02:35:19.079551 | MIT | true | 3ce2fb80e680fb041c7ac22d067790dc |
// RUN: %target-typecheck-verify-swift\n\n// rdar://112264204: Make sure we can type-check this.\nfunc foo(_ fn: (Int) -> Void) {}\n\nfunc bar(_ x: Int) {\n foo { [x] y in\n switch y {\n case x:\n ()\n default:\n ()\n }\n }\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar112264204.swift | rdar112264204.swift | Swift | 237 | 0.8 | 0.066667 | 0.153846 | awesome-app | 38 | 2025-02-10T00:55:42.041306 | BSD-3-Clause | true | 8d7569841cd73e1205514d3a12a9ffed |
// RUN: %target-typecheck-verify-swift\n\nstruct S {\n enum E: Error {\n case e(Int)\n case f\n }\n}\n\nfunc foo() throws {}\n\n// rdar://113025351: Avoid emitting a separate diagnostic complaining that a\n// 'let' cannot be nested in an expression, as it just adds noise.\nfunc bar() throws {\n do {\n try f... | dataset_sample\swift\apple_swift\test\Constraints\rdar113025351.swift | rdar113025351.swift | Swift | 699 | 0.8 | 0.173913 | 0.157895 | react-lib | 162 | 2024-09-17T00:19:19.708636 | Apache-2.0 | true | a2ccc739141de39afa0c266da01224d7 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://113326835 - Make sure we type-check the conjunctions in source order,\n// the first closure should be type-checked before we attempt the\n// TapExpr/SingleValueExpr conjunctions, since they rely on 'k' being resolved.\n\nfunc global<T>(_ x: T) -> String { "" }\nfunc g... | dataset_sample\swift\apple_swift\test\Constraints\rdar113326835.swift | rdar113326835.swift | Swift | 1,058 | 0.8 | 0.043478 | 0.128205 | node-utils | 476 | 2024-10-04T02:40:52.364877 | GPL-3.0 | true | 83f117bd5156cdb1d3d07d59d9353a28 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://114402042 - Make sure we connect the SingleValueStmtExpr to the outer\n// closure's return type.\nfunc foo<T>(_: () -> T) {}\nfunc bar<T>(_ x: T) {}\nfunc test() {\n foo {\n bar(if true { return } else { return })\n // expected-error@-1 {{'if' may only be used ... | dataset_sample\swift\apple_swift\test\Constraints\rdar114402042.swift | rdar114402042.swift | Swift | 1,298 | 0.8 | 0.28125 | 0.241379 | python-kit | 946 | 2024-06-08T04:34:37.306910 | GPL-3.0 | true | 911bcddd5eb78b9deccb9c36e0b877d5 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://116956363 - Make sure we don't crash here.\n@resultBuilder\nstruct Builder {\n static func buildBlock<T>(_ x: T) -> T { x }\n}\n\nfunc bar(_ fn: () -> Void) -> Int { 0 }\n\n@Builder\nfunc foo(_ b: Bool) -> Int {\n bar {\n let _ = if b {\n 1\n } else {\n ... | dataset_sample\swift\apple_swift\test\Constraints\rdar116956363.swift | rdar116956363.swift | Swift | 322 | 0.8 | 0.05 | 0.117647 | python-kit | 37 | 2025-05-04T04:11:55.787097 | MIT | true | 3796f1b4bf22ce7a1b5ed99c8178c759 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://119055010 - greedy key path type assignment breaks keypath-to-function conversion\n\nprotocol Executable {}\n\nfinal class Wrapper<Value> {\n func update<Return>(_ work: (inout Value) throws -> Return) rethrows -> Return {\n fatalError()\n }\n}\n\nenum Lookup<Val... | dataset_sample\swift\apple_swift\test\Constraints\rdar119055010.swift | rdar119055010.swift | Swift | 788 | 0.95 | 0.046512 | 0.060606 | vue-tools | 465 | 2023-09-13T19:59:16.901174 | MIT | true | 420624bdc4e2d70e113feecd5227ffb5 |
// RUN: %target-typecheck-verify-swift\n\nstruct S<A> {\n let v:any P<A>\n func map<B> (_ f:(A) -> B) -> S<B> {\n v.map(f).k()\n }\n}\n\nprotocol P<A> {\n associatedtype A\n func map<D> (_ g:(A) -> D) -> any P<D>\n func k() -> S<A>\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar120791071.swift | rdar120791071.swift | Swift | 231 | 0.8 | 0 | 0.083333 | react-lib | 644 | 2023-08-04T03:07:24.376943 | Apache-2.0 | true | 15560d48390e4247152bfa7b4e2e29db |
// RUN: %target-typecheck-verify-swift\n\nprotocol P<A>: AnyObject {\n associatedtype A: P2\n var x: A.A2 { get set }\n}\n\nprotocol P2 {\n associatedtype A2\n var x: A2 { get }\n}\n\nfunc test<T: P2>(x: T.A2, y: any P<T>, z: any P2) {\n y.x = x // Ok\n y.x = z.x // expected-error {{cannot assign value of type 'A... | dataset_sample\swift\apple_swift\test\Constraints\rdar121214563.swift | rdar121214563.swift | Swift | 329 | 0.8 | 0 | 0.076923 | node-utils | 1,000 | 2023-07-18T16:58:33.355842 | MIT | true | aaef9dee3f47cadf528a7c3e692b49bf |
// RUN: %target-swift-emit-silgen %s -verify -swift-version 6\n\nstruct S: Equatable {\n static func foo() -> Self { fatalError() }\n static func bar(_ x: Int) -> Self { fatalError() }\n static func baz(x: Int, y: Int) -> Self { fatalError() }\n public static func == (_: Self, _: Self) -> Bool { false }\n}\n\n// rd... | dataset_sample\swift\apple_swift\test\Constraints\rdar139234188.swift | rdar139234188.swift | Swift | 602 | 0.8 | 0.08 | 0.130435 | python-kit | 220 | 2024-09-25T05:36:36.890895 | GPL-3.0 | true | ecb4d67cbf1d0876da7f0dde7dd17a09 |
// RUN: %target-typecheck-verify-swift %clang-importer-sdk\n\n// REQUIRES: objc_interop\n\n// rdar://139812024 - error: cannot convert return expression of type 'NSObject' to return type 'NSImage'\n\nimport Foundation\n\n@objc\nfinal class Image: NSObject {\n}\n\n@available(*, unavailable)\nextension Image: Sendable {}... | dataset_sample\swift\apple_swift\test\Constraints\rdar139812024.swift | rdar139812024.swift | Swift | 857 | 0.95 | 0.108108 | 0.107143 | python-kit | 131 | 2025-01-19T09:27:18.762788 | MIT | true | ab41a80aca85b2f91d7f7e3e4cbf9ba6 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://139913219 - Make sure we don't crash.\n\nfunc bar(_ x: Int.Type, _: Int) {}\nfunc bar<T>(_ x: T.Type, _: Int) {}\n\nfunc foo() {\n bar(X<Int?>.self, .zero)\n // expected-error@-1 {{cannot find 'X' in scope}}\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar139913219.swift | rdar139913219.swift | Swift | 255 | 0.8 | 0 | 0.375 | vue-tools | 787 | 2024-09-06T06:39:21.041668 | GPL-3.0 | true | e1b8a0f0b4a971e8ee6c9a60831efa3f |
// RUN: %target-swift-emit-silgen %s -verify -swift-version 6\n\n// rdar://140212823 - Make sure we build curry thunks using the adjusted\n// reference type, such that the ParenExpr agrees with the type.\n\nclass C: @unchecked Sendable {\n func foo() {}\n}\nclass D: C, @unchecked Sendable {\n func bar() {\n let _ ... | dataset_sample\swift\apple_swift\test\Constraints\rdar140212823.swift | rdar140212823.swift | Swift | 618 | 0.95 | 0.068966 | 0.130435 | vue-tools | 898 | 2024-02-11T13:30:48.875977 | BSD-3-Clause | true | 1e89a1e6ec897015484e458933a7edce |
// RUN: %target-typecheck-verify-swift\n\nstruct Test {\n var v: String\n var i: Int\n}\n\ndo {\n let _ = Array(1 ... 20).map { i in\n _ = 0\n return Test(v: "\(i * 1000)", i: 1)\n }\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar143340082.swift | rdar143340082.swift | Swift | 200 | 0.8 | 0 | 0.090909 | node-utils | 527 | 2024-01-03T03:00:20.441379 | MIT | true | 5ef593b78d1ca670b7b23ee96b2529b1 |
// RUN: %target-typecheck-verify-swift\n\nextension Collection {\n func myMap<T>(_: (Self.Element) -> T) -> [T] { fatalError() }\n}\n\nprotocol SignedInteger {}\n\nextension SignedInteger {\n init<T: BinaryFloatingPoint>(_: T) { fatalError() }\n init<T: BinaryInteger>(_: T) { fatalError() }\n}\n\nstruct Int32: Signe... | dataset_sample\swift\apple_swift\test\Constraints\rdar143474242.swift | rdar143474242.swift | Swift | 421 | 0.8 | 0 | 0.066667 | python-kit | 309 | 2024-06-06T22:03:45.902522 | GPL-3.0 | true | 38974be0d6616a80080a68c475df01a7 |
// RUN: %target-typecheck-verify-swift\n\nfunc f(a: Array<Int>, n: Int) {\n let _: Array = a.prefix(n) + a.suffix(a.count - n - 1)\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar145092838.swift | rdar145092838.swift | Swift | 131 | 0.8 | 0 | 0.25 | node-utils | 446 | 2024-01-07T12:36:43.542146 | MIT | true | ffe288117befb83f62b80cec9886c906 |
// RUN: %target-typecheck-verify-swift -swift-version 6\n\n// rdar://145593552 - Make sure we don't crash.\nfunc foo(_ x: Int) {} // expected-note {{'foo' declared here}}\nfoo<Void>("")\n// expected-error@-1 {{cannot explicitly specialize global function 'foo'}}\n// expected-error@-2 {{cannot convert value of type 'Str... | dataset_sample\swift\apple_swift\test\Constraints\rdar145593552.swift | rdar145593552.swift | Swift | 512 | 0.95 | 0.2 | 0.5 | vue-tools | 971 | 2024-11-13T02:02:23.871422 | MIT | true | 96ba5886703f2546e800d8782dbe9ff0 |
// RUN: %target-typecheck-verify-swift\n\n// rdar://problem/32726044 - shrink reduced domains too far\npublic protocol P_32726044 {}\n\nextension Int: P_32726044 {}\nextension Float: P_32726044 {}\n\npublic func *(lhs: P_32726044, rhs: P_32726044) -> Double {\n fatalError()\n}\n\nfunc rdar32726044() -> Float {\n var ... | dataset_sample\swift\apple_swift\test\Constraints\rdar32726044.swift | rdar32726044.swift | Swift | 397 | 0.8 | 0 | 0.142857 | vue-tools | 568 | 2025-03-12T12:41:37.850461 | BSD-3-Clause | true | 879931ce4b9bded07b0f00d4089ef010 |
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s\n\nfunc foo<T>(_ a: T) -> Int {\n return 0\n}\n\nfunc foo(_ a: (Int) -> (Int)) -> Int {\n return 42\n}\n\n// CHECK: function_ref @$s12rdar351421213fooyS3iXEF :\nlet _ = foo({ (a: Int) -> Int in a + 1 })\n | dataset_sample\swift\apple_swift\test\Constraints\rdar35142121.swift | rdar35142121.swift | Swift | 262 | 0.95 | 0 | 0.222222 | vue-tools | 325 | 2024-09-09T08:00:14.094654 | BSD-3-Clause | true | 50c1d15cd6045f1426c3ca6cba60c0d9 |
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s\n\nfunc foo(a: Int) {}\nfunc foo(q: String = "", a: Int) {}\n\n// CHECK: function_ref @$s12rdar362268743foo1aySi_tF : $@convention(thin) (Int) -> ()\nfoo(a: 42)\n\nfunc bar(a: Int, c: Int) {}\nfunc bar(a: Int, b: Int = 0, c: Int) {}\n\n// CHECK: functi... | dataset_sample\swift\apple_swift\test\Constraints\rdar36226874.swift | rdar36226874.swift | Swift | 405 | 0.95 | 0 | 0.333333 | node-utils | 683 | 2025-01-05T20:37:35.978580 | GPL-3.0 | true | f12556e21e2065e55a943ec6845405f4 |
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s\n\nfunc foo(_ f: @autoclosure () -> Int) {}\nfunc foo(_ f: () -> Int) {}\n\nfunc bar(_ f: () throws -> Int) {}\nfunc bar(_ f: () -> Int) {}\n\nfunc baz(a1: @autoclosure () -> Int,\n a2: () -> Int,\n b1: () throws -> Int,\n b2: (... | dataset_sample\swift\apple_swift\test\Constraints\rdar37160679.swift | rdar37160679.swift | Swift | 584 | 0.95 | 0 | 0.277778 | react-lib | 952 | 2023-09-01T11:17:52.945334 | BSD-3-Clause | true | 1264a2d9b92b5eb62a6fee582e098184 |
// RUN: %target-typecheck-verify-swift\n\nextension Collection where Element: Numeric {\n var v: Element {\n return self.reduce(0, +)\n }\n}\n\nstruct R<T> {}\nfunc ==<T: Equatable>(lhs: R<T>, rhs: T?) {}\n\nfunc foo<T>(_ e: @autoclosure @escaping () throws -> T?) -> R<T> {\n return R<T>()\n}\n\nfunc bar<T>(_ e: ... | dataset_sample\swift\apple_swift\test\Constraints\rdar37291371.swift | rdar37291371.swift | Swift | 410 | 0.8 | 0 | 0.0625 | node-utils | 826 | 2025-06-16T13:47:30.302995 | GPL-3.0 | true | a6dc2fcbeab843dade473dd83ee24fa2 |
// RUN: %target-typecheck-verify-swift\n\nclass P {}\nclass A : P {\n func foo() throws {}\n}\n\nclass B : P {\n func foo() throws {}\n}\n\ntypealias C = (P) throws -> Void\ntypealias E = (c: P.Type, arr: [(String, C)])\n\nfunc foo<T: P>(_: [(String, (T) -> () throws -> Void)]) -> E { fatalError() }\nfunc foo<T: P>(_... | dataset_sample\swift\apple_swift\test\Constraints\rdar37303482.swift | rdar37303482.swift | Swift | 441 | 0.95 | 0.15 | 0.066667 | node-utils | 427 | 2024-07-22T21:29:01.304367 | MIT | true | a88ed3224a0793c2a59e1e6f12ef0519 |
// RUN: %target-typecheck-verify-swift\n\nprotocol A {\n associatedtype V\n associatedtype E: Error\n\n init(value: V)\n init(error: E)\n\n func foo<U>(value: (V) -> U, error: (E) -> U) -> U\n}\n\nenum R<T, E: Error> : A {\n case foo(T)\n case bar(E)\n\n init(value: T) { self = .foo(value) }\n init(error: E) {... | dataset_sample\swift\apple_swift\test\Constraints\rdar37790062.swift | rdar37790062.swift | Swift | 916 | 0.95 | 0.043478 | 0.027778 | react-lib | 18 | 2024-02-25T17:26:08.824614 | MIT | true | 675a6b7cad78de09228abc12f1de6c9a |
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s\n// REQUIRES: objc_interop\n\nimport Foundation\n\nprotocol P {}\n\nclass C {\n init<T: NSObject>(values: [T]) where T: P {}\n}\n\nfunc foo<T: NSObject>(value: T) where T: P {\n _ = C(values: [value]) // Ok\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar38535743.swift | rdar38535743.swift | Swift | 285 | 0.95 | 0.071429 | 0.2 | awesome-app | 832 | 2024-12-05T09:20:47.156753 | MIT | true | 7c2be0bd470921764683a7d11b4a0bf6 |
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s\nfunc foo<T>(_: Any) -> T {\n fatalError()\n}\n\nfunc foo<T>(_: Any?) -> T {\n fatalError()\n}\n\n// CHECK: function_ref @$s12rdar386258243fooyxyplF : $@convention(thin) <τ_0_0> (@in_guaranteed Any) -> @out τ_0_0\nvar _: String = foo("hello")\n | dataset_sample\swift\apple_swift\test\Constraints\rdar38625824.swift | rdar38625824.swift | Swift | 305 | 0.95 | 0 | 0.222222 | python-kit | 450 | 2025-04-21T05:21:26.408867 | MIT | true | 14fffb0aa23bddbd5b5d4068dd2682a9 |
// RUN: %target-typecheck-verify-swift\n\nstruct S: Hashable {\n let e: E?\n}\n\nenum E: Hashable {\n case foo\n case bar\n}\n\nlet a = S(e: .foo)\nlet b = S(e: .bar)\n\n_ = a == b\n | dataset_sample\swift\apple_swift\test\Constraints\rdar39209245.swift | rdar39209245.swift | Swift | 170 | 0.8 | 0 | 0.090909 | python-kit | 690 | 2024-08-24T21:19:16.791266 | GPL-3.0 | true | a5968e92e55cc10d709c2f0e8c982b3d |
// RUN: %target-typecheck-verify-swift -swift-version 5\n\nclass A<T> {\n var foo: Int? { return 42 }\n func baz() -> T { fatalError() }\n func fiz() -> Int { return 42 }\n}\n\nprotocol P1 {\n associatedtype T\n var foo: Int? { get }\n func baz() -> T\n func fiz() -> Int\n}\n\nprotocol P2 : P1 {\n var bar: Int?... | dataset_sample\swift\apple_swift\test\Constraints\rdar39401774.swift | rdar39401774.swift | Swift | 465 | 0.95 | 0.037037 | 0.043478 | node-utils | 639 | 2025-06-01T18:57:41.638227 | GPL-3.0 | true | 25cb3a556eccf884f634b01c8b7fc05b |
// RUN: %target-typecheck-verify-swift\n// RUN: not %target-swift-frontend -typecheck %s -debug-generic-signatures 2>&1 | %FileCheck %s\n\nprotocol P {}\n\nstruct S<T> {}\n\nclass C : P {}\n\nextension S where T : P { // expected-note {{where 'T' = 'T'}}\n typealias A = Int\n typealias B<U> = S<U>\n}\n\nextension S w... | dataset_sample\swift\apple_swift\test\Constraints\rdar39931339.swift | rdar39931339.swift | Swift | 1,693 | 0.95 | 0.056604 | 0.2 | node-utils | 918 | 2025-06-10T00:35:45.835792 | MIT | true | 0f1e5fafda08b9e133d4dec92b0cd02d |
// RUN: %target-typecheck-verify-swift\n\nprotocol P {\n func b(i: @escaping (inout Int) -> Double)\n}\n\nfunc foo<T: P>(_ bar: T) {\n bar.b { a in Double((a, a += 1).0) }\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar39931475.swift | rdar39931475.swift | Swift | 169 | 0.8 | 0 | 0.142857 | react-lib | 240 | 2024-09-22T05:57:28.479356 | GPL-3.0 | true | f10c76637c35736786faab6af7fe1297 |
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s\n// REQUIRES: objc_interop\n\nimport Foundation\n\nstruct S {\n init<T: NSNumber>(_ num: T) { // expected-note {{where 'T' = 'Bool'}}\n self.init(num != 0) // expected-error {{initializer 'init(_:)' requires that 'Bool' inherit from... | dataset_sample\swift\apple_swift\test\Constraints\rdar40002266.swift | rdar40002266.swift | Swift | 427 | 0.95 | 0 | 0.333333 | python-kit | 638 | 2023-09-03T14:38:04.877401 | Apache-2.0 | true | 763a1bb016a38cfdc3422e71c741488d |
// RUN: %target-typecheck-verify-swift\n\nclass A {\n static var a: Int = 0\n static var b: Int = 42\n\n func foo(_ ptr: UnsafeMutableRawPointer?) {\n switch ptr {\n case (&A.a)?: break\n case (&A.b)?: break\n default: break\n }\n }\n\n func bar(_ ptr: UnsafeRawPointer) {\n switch ptr {\n ... | dataset_sample\swift\apple_swift\test\Constraints\rdar40945329.swift | rdar40945329.swift | Swift | 381 | 0.95 | 0.136364 | 0.052632 | node-utils | 923 | 2024-12-21T12:31:38.460114 | MIT | true | ab4f5a524b83a9ba3aab4fa091009d09 |
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s\n// REQUIRES: objc_interop\n\nimport Foundation\n\nclass A {\n static var `default` = A()\n\n func foo(arg: String) -> Bool {\n return false\n }\n\n func foo(arg: String, _ flag: UnsafeMutablePointer<ObjCBool>?) -> Bool {\n re... | dataset_sample\swift\apple_swift\test\Constraints\rdar42056741.swift | rdar42056741.swift | Swift | 472 | 0.95 | 0.086957 | 0.111111 | awesome-app | 811 | 2025-04-05T00:46:15.144921 | GPL-3.0 | true | 20176a29ad7e56a0372f001f49aa31b3 |
// RUN: %target-typecheck-verify-swift\n\nfunc foo(chr: Character) -> String {\n return String(repeating: String(chr)) // expected-error {{missing argument for parameter 'count' in call}} {{39-39=, count: <#Int#>}}\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar42678836.swift | rdar42678836.swift | Swift | 215 | 0.8 | 0.2 | 0.25 | python-kit | 657 | 2023-08-07T14:11:55.906097 | MIT | true | bc72bc2f8ac1bc292fc23b37309f1017 |
// RUN: %target-typecheck-verify-swift\n\nprotocol P : Equatable {\n associatedtype T = String\n}\n\nstruct S : Hashable {\n var key: String\n\n init(_ key: String) {\n self.key = key\n }\n}\n\nextension S : ExpressibleByStringLiteral {\n public init(stringLiteral value: String) {\n self.init(value)\n ... | dataset_sample\swift\apple_swift\test\Constraints\rdar42750089.swift | rdar42750089.swift | Swift | 1,145 | 0.95 | 0.028571 | 0.018182 | react-lib | 539 | 2023-08-19T08:35:21.400037 | BSD-3-Clause | true | d73374e0bcd1a0b972b59fec61e22ed0 |
// RUN: %target-typecheck-verify-swift\n\nprotocol P {}\nstruct S<V> where V: P { // expected-note {{where 'V' = 'Double'}}\n var value: V\n}\n\nstruct A {\n subscript<T>(_ v: S<T>) -> A {\n fatalError()\n }\n}\n\nfunc foo(_ v: Double) {\n _ = A()[S(value: v)]\n // expected-error@-1 {{generic struct 'S' requires... | dataset_sample\swift\apple_swift\test\Constraints\rdar44569159.swift | rdar44569159.swift | Swift | 339 | 0.95 | 0 | 0.142857 | react-lib | 491 | 2024-08-02T00:36:30.196379 | MIT | true | 5f660e880b80a3ad1183994acd73a552 |
// RUN: %target-typecheck-verify-swift\n\nprotocol P {\n associatedtype A\n}\n\nfunc foo<T: P>(_: () throws -> T) -> T.A? { // expected-note {{where 'T' = 'Never'}}\n fatalError()\n}\n\nlet _ = foo() {fatalError()} & nil\n// expected-error@-1 {{global function 'foo' requires that 'Never' conform to 'P'}}\n// expected... | dataset_sample\swift\apple_swift\test\Constraints\rdar44770297.swift | rdar44770297.swift | Swift | 610 | 0.95 | 0.133333 | 0.416667 | vue-tools | 461 | 2024-01-05T00:12:53.930023 | BSD-3-Clause | true | 9aaf14a44df8092f88f52143ac74bfda |
// RUN: %target-typecheck-verify-swift\n\nclass A {}\nclass B: A {}\nclass C: A {}\n\nstruct S {\n func foo<T: A>(types: [T.Type]) {}\n}\n\nfunc bar(_ s: S, _ forced_s: S!) {\n s.foo(types: [A.self, B.self]) // ok\n s.foo(types: [B.self, A.self]) // ok\n forced_s.foo(types: [A.self, B.self]) // ok\n forced_s.foo(t... | dataset_sample\swift\apple_swift\test\Constraints\rdar44816848.swift | rdar44816848.swift | Swift | 338 | 0.95 | 0.1875 | 0.076923 | python-kit | 787 | 2024-10-12T06:58:02.803325 | Apache-2.0 | true | 6f40b342a4ad6b17796b7603da622ea2 |
// RUN: %target-typecheck-verify-swift -module-name M\n\nprotocol P {\n var v: String { get }\n}\n\nfunc foo(bar: [P], baz: [P]) {\n// expected-note@-1 {{'foo(bar:baz:)' declared here}}\n}\n\nstruct S {\n static func bar(fiz: [P], baz: [P]) {}\n// expected-note@-1 {{'bar(fiz:baz:)' declared here}}\n}\n\ndo {\n let _... | dataset_sample\swift\apple_swift\test\Constraints\rdar45242032.swift | rdar45242032.swift | Swift | 617 | 0.8 | 0.090909 | 0.176471 | python-kit | 358 | 2024-09-10T04:40:26.776084 | Apache-2.0 | true | 7bfa0bb1dfdb4dca67edf094110fed6c |
// RUN: %target-typecheck-verify-swift\n\nfinal class A<T> {\n init(_: T) {}\n}\n\nextension A: ExpressibleByNilLiteral where T: ExpressibleByNilLiteral {\n convenience init(nilLiteral: ()) {\n self.init(nil)\n }\n}\n\nstruct B {\n var foo: A<B?> = A(nil)\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar45415874.swift | rdar45415874.swift | Swift | 252 | 0.95 | 0.066667 | 0.083333 | awesome-app | 341 | 2024-08-27T05:18:21.630323 | MIT | true | 7b8b5cf9453d59ae7d54bfd499999c9f |
// RUN: %target-typecheck-verify-swift\n\nprotocol X {}\nclass B : Equatable {\n static func == (lhs: B, rhs: B) -> Bool { fatalError() }\n}\nclass C : B {}\nextension C : X {}\n\nfunc f<T: Equatable>(_ lhs: T, _ rhs: T) {}\n\nextension Optional where Wrapped : Equatable {\n static func f(_ lhs: Wrapped?, _ rhs: Wrap... | dataset_sample\swift\apple_swift\test\Constraints\rdar45490737.swift | rdar45490737.swift | Swift | 529 | 0.95 | 0.136364 | 0.222222 | react-lib | 695 | 2024-11-15T05:57:36.235673 | BSD-3-Clause | true | 25b43123f10cd553d886a9ba79c20200 |
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -verify %s\n// REQUIRES: objc_interop\n\nimport Foundation\n\nprotocol A: RawRepresentable {}\n\nextension A {\n static func +(lhs: RawValue, rhs: Self) -> Self {\n fatalError()\n }\n}\n\nclass Foo<Bar: NSObject> {\n var foobar: Bar {\n f... | dataset_sample\swift\apple_swift\test\Constraints\rdar45511837.swift | rdar45511837.swift | Swift | 647 | 0.95 | 0.04 | 0.25 | awesome-app | 200 | 2024-04-22T09:12:36.368308 | BSD-3-Clause | true | c259495883904d5adcc37d7bce48ed27 |
// RUN: %target-typecheck-verify-swift\n\nclass Foo {\n init(lhs: @autoclosure () -> Int,\n rhs: @autoclosure () -> Undefined) {\n // expected-error@-1 {{cannot find type 'Undefined' in scope}}\n }\n}\n\nfunc foo() -> Foo {\n return Foo(lhs: 2, rhs: 2)\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar46377919.swift | rdar46377919.swift | Swift | 258 | 0.95 | 0.083333 | 0.2 | node-utils | 725 | 2024-12-15T23:38:27.149693 | BSD-3-Clause | true | d770bc51af7b7bc11191d91c9cc08b84 |
// RUN: %target-typecheck-verify-swift\n\nstruct D {}\n\nclass Future<T> {\n func then<U>(_ fn: @escaping (T) -> Future<U>) -> Future<U> { fatalError() } // expected-note {{in call to function 'then'}}\n func thenThrowing<U>(_ fn: @escaping (T) throws -> U) -> Future<U> { fatalError() }\n func whenFailure(_ fn: @esc... | dataset_sample\swift\apple_swift\test\Constraints\rdar46544601.swift | rdar46544601.swift | Swift | 996 | 0.95 | 0.064516 | 0.04 | python-kit | 43 | 2024-09-18T01:44:23.943738 | Apache-2.0 | true | 71d6017439b3abfdb32075ca88e91335 |
// RUN: %target-swift-frontend -emit-sil -verify %s | %FileCheck %s\n\nprotocol P {\n init(value: Int)\n}\n\nclass C {\n init(value: Int, otherValue: String = "") {}\n}\n\nfunc make<T: P & C>(type: T.Type) -> T {\n // CHECK: [[INIT:.*]] = witness_method $T, #P.init\n return T.init(value: 0)\n}\n | dataset_sample\swift\apple_swift\test\Constraints\rdar47787705.swift | rdar47787705.swift | Swift | 286 | 0.95 | 0.071429 | 0.181818 | awesome-app | 904 | 2023-11-22T15:17:09.679762 | Apache-2.0 | true | a224d01160a0bcc23f1c047f6ce45f4a |
// RUN: %target-typecheck-verify-swift -disable-availability-checking -swift-version 5\n\nstruct S {\n @available(swift, obsoleted: 4.2)\n init(foo: Int) throws {}\n\n @available(swift, introduced: 4.2)\n init?(foo: Int) throws {}\n}\n\n_ = try S(foo: 42)\n | dataset_sample\swift\apple_swift\test\Constraints\rdar60898369.swift | rdar60898369.swift | Swift | 250 | 0.8 | 0.090909 | 0.125 | node-utils | 595 | 2024-12-01T07:46:39.330360 | GPL-3.0 | true | d1ecbf3e57d8065f235dc9b3805feddd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.