Skip to content

[test] Add a couple of test cases #39343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions test/Constraints/array_literal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,10 @@ func testSR8385() {
let _: [SR8385] = ["hello", SR8385.text("world")]
let _: [SR8385] = ["hello", .text("world")]
}

struct TestMultipleOverloadedInits {
var x: Double
func foo() {
let _ = [Float(x), Float(x), Float(x), Float(x)]
}
}
9 changes: 9 additions & 0 deletions test/Constraints/iuo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,12 @@ let _: Int = r
// SR-11998 / rdar://problem/58455441
class C<T> {}
var sub: C! = C<Int>()

// FIXME: We probably shouldn't support this, we don't support other
// 'direct call' features such as default arguments for curried calls.
struct CurriedIUO {
func silly() -> Int! { nil }
func testSilly() {
let _: Int = CurriedIUO.silly(self)()
}
}
9 changes: 9 additions & 0 deletions test/Constraints/tuple_arguments.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1768,3 +1768,12 @@ func noescapeSplat() {
}
}

func variadicSplat() {
func takesFnWithVarg(fn: (Int, Int...) -> Void) {}
takesFnWithVarg { x in // expected-error {{contextual closure type '(Int, Int...) -> Void' expects 2 arguments, but 1 was used in closure body}}
_ = x.1.count
}
takesFnWithVarg { x, y in
_ = y.count
}
}
8 changes: 8 additions & 0 deletions test/Index/index_keypath_member_lookup.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,11 @@ extension Foo {
// CHECK: [[@LINE-1]]:5 | instance-property/Swift | prop | [[PROP_USR]] | Ref,Read,RelCont | rel: 1
}
}

// Also make sure we don't crash for multiple overloads.
@dynamicMemberLookup
protocol P {}
extension P {
subscript<T>(dynamicMember keyPath: KeyPath<Bar, T>) -> Int { 0 }
subscript<T>(dynamicMember keyPath: KeyPath<P, T>) -> Int { 0 }
}