Files
swift-mirror/test/decl/init/delegate-to-c-func-imported-as-member.swift
Joe Groff eae044c07d Sema: Type-check initializer delegation as a covariant expression.
If a convenience initializer in a subclass delegated to an inherited initializer from its base, we would end up type-checking the reference to the base class constructor as returning the base type, leading to type mismatches in the result AST and downstream crashes. We can wrap up the synthesized OtherConstructorRefExpr in a CovariantFunctionConversionExpr, which will trick the type checker into propagating the covariant result that gets rebound to `self` on return, avoiding this problem. (For now, I'm avoiding making the constructor decl formally have a Self return type, since that exposes a bunch of downstream breakage in code paths that only expect FuncDecls to be covariant, and also affects the mangling of constructors, causing a bunch of test case thrash we really don't want to inflict on the 3.1 branch.)
2017-02-16 13:19:11 -08:00

9 lines
204 B
Swift

// RUN: %target-swift-frontend -emit-sil -verify -import-objc-header %S/Inputs/c-func-member-init.h %s
// REQUIRES: objc_interop
extension MyObject {
convenience init() {
self.init(id: 1738)
}
}