Skip to content

Commit dfd16a0

Browse files
authored
Merge pull request #85070 from slavapestov/three-regression-tests
Add regression tests for fixed crashers
2 parents 32913de + 4998cd6 commit dfd16a0

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: not %target-swift-frontend -typecheck %s
2+
// REQUIRES: objc_interop
3+
4+
import Foundation.NSZone
5+
6+
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
7+
@dynamicMemberLookup public struct AttributedSubstring : Sendable {
8+
}
9+
10+
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
11+
extension AttributedSubstring : AttributedStringProtocol {
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: not %target-swift-frontend -typecheck %s
2+
// REQUIRES: objc_interop
3+
4+
import Foundation
5+
6+
protocol AttributedStringKey {
7+
associatedtype Value : Hashable
8+
}
9+
10+
protocol AttributedStringProtocol {
11+
subscript<K>(_: K.Type) -> K.Value? where K : AttributedStringKey { get set }
12+
subscript<R>(bounds: R) -> AttributedSubstring where R : RangeExpression, R.Bound == AttributedString.Index { get }
13+
}
14+
15+
public struct AttributedSubstring : Sendable {
16+
}
17+
18+
extension AttributedSubstring : AttributedStringProtocol {
19+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -disable-availability-checking
2+
3+
public protocol IntoTuple {
4+
func asTuple<each E>() -> (repeat each E)
5+
func asTuples<each E>() -> (repeat each E)
6+
}
7+
8+
extension InlineArray: IntoTuple {
9+
public func asTuple<each E>() -> (repeat each E)
10+
{
11+
var indices = self.indices.makeIterator()
12+
return (repeat self[indices.next()!] as! each E)
13+
}
14+
15+
// Convert nested InlineArrays
16+
public func asTuples<each E>() -> (repeat each E)
17+
where Element: IntoTuple
18+
{
19+
var indices = self.indices.makeIterator()
20+
return (repeat self[indices.next()!].asTuple() as each E)
21+
}
22+
23+
public func asTuples<each E>() -> (repeat each E)
24+
{
25+
return self.asTuple()
26+
}
27+
}
28+
29+
let x: ((Float, Float), (Float, Float)) = [2 of [2 of _]](repeating: [1.0, 2.0]).asTuples()
30+
print(x)
31+

0 commit comments

Comments
 (0)