Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/Sema/CodeSynthesis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,9 +2030,12 @@ static void configureDesignatedInitAttributes(TypeChecker &tc,
ctor->getAttrs().add(clonedAttr);
}

// Make sure the constructor is only as available as its superclass's
// constructor.
AvailabilityInference::applyInferredAvailableAttrs(ctor, superclassCtor, ctx);
// If the superclass has its own availability, make sure the synthesized
// constructor is only as available as its superclass's constructor.
if (superclassCtor->getAttrs().hasAttribute<AvailableAttr>()) {
AvailabilityInference::applyInferredAvailableAttrs(
ctor, {classDecl, superclassCtor}, ctx);
}

if (superclassCtor->isObjC()) {
// Inherit the @objc name from the superclass initializer, if it
Expand Down
13 changes: 13 additions & 0 deletions test/Sema/availability_versions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,19 @@ func useUnavailableExtension() {
// expected-note@-1 {{add 'if #available' version check}}
}

// Availability of synthesized designated initializers.

@available(OSX, introduced: 10.51)
class WidelyAvailableBase {
init() {}

@available(OSX, introduced: 10.52)
init(thing: ()) {}
}

@available(OSX, introduced: 10.53)
class EsotericSmallBatchHipsterThing : WidelyAvailableBase {}

// Useless #available(...) checks

func functionWithDefaultAvailabilityAndUselessCheck(_ p: Bool) {
Expand Down