mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
* When constructing instructions which have substitution maps: initialize those with the canonical SubstitutionMap * Also initialize SILFunction::ForwardingSubMap with the canonical one Non-canonical substitution maps may prevent generic specializations. This fixes a problem in Embedded Swift where an error is given because a function cannot be specialized, although it should. https://github.com/swiftlang/swift/issues/83895 rdar://159065157
34 lines
894 B
Swift
34 lines
894 B
Swift
// RUN: %target-swift-frontend %s -emit-sil -o - | %FileCheck %s
|
|
|
|
// https://github.com/apple/swift/issues/49620
|
|
|
|
public final class GenClass<Element: Cl> {
|
|
public subscript(index: Int) -> Element {
|
|
get { return unsafeBitCast(0, to: Element.self) }
|
|
}
|
|
}
|
|
|
|
public protocol Proto { }
|
|
|
|
public struct Iter<Element: Proto>: IteratorProtocol {
|
|
public mutating func next() -> Element? { return nil }
|
|
}
|
|
|
|
extension GenClass: RandomAccessCollection {
|
|
public func makeIterator() -> Iter<Element> { return Iter() }
|
|
public var startIndex: Int { return 0 }
|
|
public var endIndex: Int { return 0 }
|
|
}
|
|
|
|
open class Cl: Proto { }
|
|
|
|
class Bar: Cl {
|
|
var x: Int?
|
|
}
|
|
|
|
// CHECK-LABEL: sil hidden @$s4main5crash4barsSbAA8GenClassCyAA3BarCG_tF
|
|
func crash(bars: GenClass<Bar>) -> Bool {
|
|
// CHECK: apply [[FN:%.*]]<Bar, Array<Bar>>
|
|
return Array(bars.filter { $0.x == nil }).isEmpty
|
|
}
|