diff --git a/validation-test/compiler_crashers_2_fixed/0047-sr1307.swift b/validation-test/compiler_crashers_2_fixed/0047-sr1307.swift new file mode 100644 index 0000000000000..43f1851ed9c1c --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0047-sr1307.swift @@ -0,0 +1,47 @@ +// RUN: %target-swift-frontend %s -emit-ir + +enum SampleType: UInt8 { + case Value = 1 + case Array + case Dictionary +} + +protocol ByteConvertible { + init?(bytes: [UInt8], startOffset: Int) + func rawBytes() -> [UInt8] + func bytesNeeded() -> Int +} + +protocol TypeRequestable { + static func containerType() -> SampleType +} + +struct Sample { + let numberOfRecords: UInt32 + let sizeInBytes: UInt64 + var records: [T] = [] // problem line + + init(records: [T]) { + numberOfRecords = 0 + sizeInBytes = 0 + + self.records.reserveCapacity(records.count) + self.records += records + } +} + +extension Sample: ByteConvertible { + init?(bytes: [UInt8], startOffset: Int = 0) { + numberOfRecords = 0 + sizeInBytes = 0 + records = [] + } + + func rawBytes() -> [UInt8] { + return [] + } + + func bytesNeeded() -> Int { + return 0 + } +} diff --git a/validation-test/compiler_crashers_2_fixed/0048-sr2333.swift b/validation-test/compiler_crashers_2_fixed/0048-sr2333.swift new file mode 100644 index 0000000000000..8fdfc45447922 --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0048-sr2333.swift @@ -0,0 +1,17 @@ +// RUN: %target-swift-frontend %s -emit-ir + +public protocol Proto { + associatedtype One + associatedtype Two + + static func bar(elm: One, t: T) -> T +} + +struct S { + let x: P.Two + func foo(_ t: T) -> T where P.Two == P.One { + let x: P.Two = self.x + let elm: P.One = x as! P.One + return P.bar(elm: elm, t: t) + } +} diff --git a/validation-test/compiler_crashers_2_fixed/0049-sr2611.swift b/validation-test/compiler_crashers_2_fixed/0049-sr2611.swift new file mode 100644 index 0000000000000..c1f34c75ad6fe --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0049-sr2611.swift @@ -0,0 +1,18 @@ +// RUN: %target-swift-frontend %s -emit-ir + +protocol Foo { + associatedtype A + var value: A { get } + init(_ v: A) +} +extension Foo { + init(pairing other: T) + where + T: Foo, + Self.A == (T.A, T.A) // <-- Look at this, and then at the error below. + { + let otherValuePaired = (other.value, other.value) + let v: A = otherValuePaired // <-- Error: Cannot convert value of + self.init(v) // type '(T.A, T.A)' to specified type 'Self.A' + } +} diff --git a/validation-test/compiler_crashers_2_fixed/0050-sr3159.swift b/validation-test/compiler_crashers_2_fixed/0050-sr3159.swift new file mode 100644 index 0000000000000..dd8d6674e2ae2 --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0050-sr3159.swift @@ -0,0 +1,16 @@ +// RUN: %target-swift-frontend %s -emit-ir + +public class Entity{ +} +public class DataCollection{ +} +public protocol IEntityCollection : class{ + func AddEntity(_ entity:Entity) +} +public class EntityCollection : DataCollection, IEntityCollection{ + public func AddEntity(_ entity: Entity) {} +} +public class EntityReference2, TChildEntityCollection:EntityCollection, TChildEntity:Entity, TParentEntity:Entity> +{ + public let i = 0 +} diff --git a/validation-test/compiler_crashers_2_fixed/0051-sr3212.swift b/validation-test/compiler_crashers_2_fixed/0051-sr3212.swift new file mode 100644 index 0000000000000..ecead9e352552 --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0051-sr3212.swift @@ -0,0 +1,18 @@ +// RUN: %target-swift-frontend %s -emit-silgen + +protocol CType { + init() +} + +protocol BType { + associatedtype C: CType +} + +protocol A { + associatedtype B: BType + typealias C = B.C +} + +func test(_ a: T) -> T.C { + return T.C() +} diff --git a/validation-test/compiler_crashers_2_fixed/0052-sr3478.swift b/validation-test/compiler_crashers_2_fixed/0052-sr3478.swift new file mode 100644 index 0000000000000..53cdf47ad07ff --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0052-sr3478.swift @@ -0,0 +1,11 @@ +// RUN: %target-swift-frontend %s -typecheck + +protocol P { + associatedtype A +} + +struct S : P { + typealias A = Gen +} + +struct Gen {} diff --git a/validation-test/compiler_crashers_2_fixed/0053-sr490.swift b/validation-test/compiler_crashers_2_fixed/0053-sr490.swift new file mode 100644 index 0000000000000..97717dad67733 --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0053-sr490.swift @@ -0,0 +1,22 @@ +// RUN: %target-swift-frontend %s -emit-ir + +enum Value { + case IntValue(Int) +} + +protocol Storable { + associatedtype Representation + + static var storageKey : String? { get } + var representation : Representation { get } +} + +protocol RawProducable { + var rawValueForType : Int16 { get } + init(value: T) +} + +extension Int : Storable { + static var storageKey : String? { return "int64Value" } + var representation : Value { return Value.IntValue(self) } +} diff --git a/validation-test/compiler_crashers_2_fixed/0054-sr833.swift b/validation-test/compiler_crashers_2_fixed/0054-sr833.swift new file mode 100644 index 0000000000000..19314497ffd4d --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0054-sr833.swift @@ -0,0 +1,10 @@ +// RUN: %target-swift-frontend %s -emit-ir + +public class A { + public init() {} +} + +public class B : A { + public struct C { } + public override init() {} +} diff --git a/validation-test/compiler_crashers_2_fixed/0057-rdar29587093.swift b/validation-test/compiler_crashers_2_fixed/0057-rdar29587093.swift new file mode 100644 index 0000000000000..3df951d165a01 --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0057-rdar29587093.swift @@ -0,0 +1,30 @@ +// RUN: %target-swift-frontend %s -emit-ir + +protocol P { + associatedtype A + func f() +} + +extension P where A == Int { + func f() { + print("cool") + } +} +extension P { + func f() { print("semi-uncool") } + func g() { + f() + } +} +struct X : P { + typealias A = T +} + +extension X where A == Int { + func f() { + print("cool2") + } +} + +X().f() +X().g() diff --git a/validation-test/compiler_crashers_2_fixed/0058-rdar29223240.swift b/validation-test/compiler_crashers_2_fixed/0058-rdar29223240.swift new file mode 100644 index 0000000000000..61bfa54bdaa1b --- /dev/null +++ b/validation-test/compiler_crashers_2_fixed/0058-rdar29223240.swift @@ -0,0 +1,7 @@ +// RUN: %target-swift-frontend %s -emit-ir + +extension Array where Iterator.Element == UTF8.CodeUnit { + var u8str : String { + return "" + } +}