Skip to content

Commit a23bb43

Browse files
author
ematejska
authored
Merge pull request #4335 from milseman/import_as_member
[Import as Member] Inferred inits are factory
2 parents e9c452c + 7b1ec7e commit a23bb43

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,6 +2567,11 @@ auto ClangImporter::Implementation::importFullName(
25672567
else if (inference.isSetter())
25682568
result.AccessorKind = ImportedAccessorKind::PropertySetter;
25692569

2570+
// Inits are factory. These C functions are neither convenience nor
2571+
// designated, as they return a fully formed object of that type.
2572+
if (inference.isInit())
2573+
result.InitKind = CtorInitializerKind::Factory;
2574+
25702575
return result;
25712576
}
25722577
}

test/ClangModules/CoreGraphics_test.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ public func testColorRenames(color: CGColor,
8787
// CHECK: ret void
8888
}
8989

90+
// Test factory-ness of inferred imports
91+
extension CGMutablePath {
92+
// CHECK-LABEL: define %{{.*}}CGMutablePath* {{.*}}CGMutablePath{{.*}}(i1{{.*}})
93+
public convenience init(p: Bool) {
94+
self.init()
95+
// CHECK: tail call %struct.CGPath* @CGPathCreateMutable()
96+
}
97+
}
98+
9099
// CHECK-LABEL: define void {{.*}}testRenames{{.*}} {
91100
public func testRenames(transform: CGAffineTransform, context: CGContext,
92101
point: CGPoint, size: CGSize, rect: CGRect,

0 commit comments

Comments
 (0)