Files
swift-mirror/test/IRGen/bitcast_specialization.swift
Michael Gottesman fd4828e40a Eliminate -assume-parsing-unqualified-ownership-sil from tests.
I am doing this separately from the actual change to eliminate the option to
make it easier to review.
2018-12-19 12:54:13 -08:00

29 lines
769 B
Swift

// RUN: %target-swift-frontend -emit-object -O %s
// This is a compile-only test. It checks that the compiler does not crash for
// a (not executed) bitcast with different sizes. This appears in the
// specialized version fo myDictionaryBridge.
// <rdar://problem/17821040>
// A minimized version of _dictionaryBridgeToObjectiveC that used to be in the
// stdlib
public func myDictionaryBridge<
SrcType, DestType
>(
_ source: Dictionary<SrcType, Int>, _ keyBridgesDirectly : Bool
) -> DestType? {
for (key, value) in source {
if keyBridgesDirectly {
var bridgedKey = unsafeBitCast(key, to: DestType.self)
return bridgedKey
}
}
return nil
}
var dict1 = Dictionary<String, Int>()
var res : Int? = myDictionaryBridge(dict1, false)