Skip to content

Commit 59896a1

Browse files
committed
typecheck: diagnose malformed @_spi_available
1 parent ce07ce2 commit 59896a1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,6 +1542,9 @@ ERROR(optional_attribute_initializer,none,
15421542
ERROR(unavailable_method_non_objc_protocol,none,
15431543
"protocol members can only be marked unavailable in an @objc protocol",
15441544
())
1545+
ERROR(spi_available_malformed,none,
1546+
"SPI available only supports introducing version on specific platform",
1547+
())
15451548
ERROR(missing_in_class_init_1,none,
15461549
"stored property %0 requires an initial value%select{| or should be "
15471550
"@NSManaged}1", (Identifier, bool))

lib/Sema/TypeCheckAttr.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1611,6 +1611,13 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) {
16111611
if (Ctx.LangOpts.DisableAvailabilityChecking)
16121612
return;
16131613

1614+
while (attr->IsSPI) {
1615+
if (attr->hasPlatform() && attr->Introduced.hasValue())
1616+
break;
1617+
diagnoseAndRemoveAttr(attr, diag::spi_available_malformed);
1618+
break;
1619+
}
1620+
16141621
if (auto *PD = dyn_cast<ProtocolDecl>(D->getDeclContext())) {
16151622
if (auto *VD = dyn_cast<ValueDecl>(D)) {
16161623
if (VD->isProtocolRequirement()) {

0 commit comments

Comments
 (0)