Skip to content

Commit 610d99b

Browse files
committed
Reject module selectors on SPI groups
1 parent f6db4ee commit 610d99b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ bool Parser::parseSpecializeAttributeArguments(
687687
consumeToken();
688688
return false;
689689
}
690+
diagnoseAndConsumeIfModuleSelector("SPI group");
690691
auto text = Tok.getText();
691692
spiGroups.push_back(Context.getIdentifier(text));
692693
consumeToken();
@@ -2974,6 +2975,8 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
29742975
return makeParserSuccess();
29752976
}
29762977

2978+
diagnoseAndConsumeIfModuleSelector("SPI group");
2979+
29772980
auto text = Tok.getText();
29782981
// An spi group name can be '_' as in @_spi(_), a specifier for implicit import of the SPI.
29792982
// '_' in source code is represented as an empty identifier in AST so match the behavior

test/NameLookup/module_selector.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,15 @@ func badModuleNames() {
474474
let y: A.NonexistentModule::MyChildType = fatalError()
475475
// expected-error@-1 {{'NonexistentModule::MyChildType' is not a member type of struct 'ModuleSelectorTestingKit.A'}}
476476
}
477+
478+
@_spi(main::Private)
479+
// expected-error@-1 {{name of SPI group declaration cannot be qualified with module selector}} {{7-13=}}
477480
public struct BadImplementsAttr: CustomStringConvertible {
478481
@_implements(CustomStringConvertible, Swift::description)
479482
// expected-error@-1 {{name cannot be qualified with module selector here}} {{41-48=}}
480483
public var stringValue: String { fatalError() }
484+
485+
@_specialize(spi: main::Private, where T == Swift::Int)
486+
// expected-error@-1 {{name of SPI group declaration cannot be qualified with module selector}} {{21-27=}}
487+
public func fn<T>() -> T { fatalError() }
481488
}

0 commit comments

Comments
 (0)