mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This addresses SR-15272. When you have a function (e.g. 'foo') which is used in a constructor initializer (e.g. constructor of some class 'Bar'), and you use the constructor from swift code without directly using the function (e.g. Bar's ctor is used from swift but foo isn't, foo is used from Bar's ctor), you will get a link error. My fix is as follows: When walking the clangAST to be imported, make sure you look at each CXXCtorInitializer for each CXXConstructorDecl you see.
25 lines
590 B
Swift
25 lines
590 B
Swift
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-cxx-interop)
|
|
//
|
|
// REQUIRES: executable_test
|
|
|
|
import ConstructorCallsFunction
|
|
import StdlibUnittest
|
|
|
|
var MembersTestSuite = TestSuite("MembersTestSuite")
|
|
|
|
MembersTestSuite.test("constructor calls function (explicit)") {
|
|
expectEqual(42, callConstructor(41))
|
|
}
|
|
|
|
MembersTestSuite.test("constructor calls function (implicit)") {
|
|
let holder = Hold42()
|
|
expectEqual(42, holder.m)
|
|
}
|
|
|
|
MembersTestSuite.test("constructor calls template function (implicit)") {
|
|
let holder = Hold23()
|
|
expectEqual(23, holder.m)
|
|
}
|
|
|
|
runAllTests()
|