Files
swift-mirror/test/Serialization/vtable-lookup.swift
Erik Eckstein c957c50e28 Serialization: use the mangled class name for serializing vtables.
To distinguish between classes which have the same name (but are in different contexts).
Fixes a miscompile if classes with the same name are used from a different module.

SR-10634
rdar://problem/50538534
2019-05-11 08:30:15 -07:00

28 lines
815 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -parse-as-library -module-name Classes -emit-module -emit-module-path %t/Classes.swiftmodule %S/Inputs/classes.swift
// RUN: %target-build-swift -parse-as-library -module-name Classes -c -o %t/classes.o %S/Inputs/classes.swift
// RUN: %target-build-swift -I %t %s %t/classes.o -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: executable_test
import Classes
// Check if the right vtable is deserialized in case of two classes which have
// the same name (but are in different contexts).
func testit() {
let a = StructA.Testclass()
// CHECK: true
print(type(of: a) == StructA.Testclass.self)
}
extension StructA.Testclass {
convenience init() {
self.init(data: 0)
}
}
testit()