Files
swift-mirror/test/Interpreter/field_offset_generic.swift
Arnold Schwaighofer 4cd16ae489 IRGen: Empty fields do have an entry in the field offset vector
This is an error introduced as the result of a refactoring a while ago
and means that we will store dependently typed stored properties at the
wrong offset in a generic struct if it has stored properties of empty
types before said property.

rdar://36384871
2018-01-12 13:00:13 -08:00

28 lines
540 B
Swift

// RUN: %target-run-simple-swift | %FileCheck %s
// REQUIRES: executable_test
public protocol Proto { }
public struct MyImpl: Proto { }
public struct EmptyStruct {}
private struct GenericStruct<T : Proto> {
var empty: EmptyStruct = EmptyStruct()
var dummy: Int = 0
var opt: Optional<T> = nil
init() {
}
}
public func test() {
let s = GenericStruct<MyImpl>()
assert(s.dummy == 0, "Expecting dummy == 0")
assert(s.opt == nil, "Expecting opt == nil")
// CHECK: dummy: 0
print("dummy: \(s.dummy)")
}
test()