Skip to content

Commit 7d7a499

Browse files
committed
Reject module selectors on SPI groups
1 parent b975d7f commit 7d7a499

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
@@ -686,6 +686,7 @@ bool Parser::parseSpecializeAttributeArguments(
686686
consumeToken();
687687
return false;
688688
}
689+
diagnoseAndConsumeIfModuleSelector("SPI group");
689690
auto text = Tok.getText();
690691
spiGroups.push_back(Context.getIdentifier(text));
691692
consumeToken();
@@ -1861,6 +1862,8 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
18611862
return false;
18621863
}
18631864

1865+
diagnoseAndConsumeIfModuleSelector("SPI group");
1866+
18641867
auto text = Tok.getText();
18651868
spiGroups.push_back(Context.getIdentifier(text));
18661869
consumeToken();

test/NameLookup/module_selector.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,15 @@ func badModuleNames() {
470470
let y: A.NonexistentModule::MyChildType = fatalError()
471471
// expected-error@-1 {{'NonexistentModule::MyChildType' is not a member type of struct 'ModuleSelectorTestingKit.A'}}
472472
}
473+
474+
@_spi(main::Private)
475+
// expected-error@-1 {{name of SPI group declaration cannot be qualified with module selector}} {{7-13=}}
473476
public struct BadImplementsAttr: CustomStringConvertible {
474477
@_implements(CustomStringConvertible, Swift::description)
475478
// expected-error@-1 {{name cannot be qualified with module selector here}} {{41-48=}}
476479
public var stringValue: String { fatalError() }
480+
481+
@_specialize(spi: main::Private, where T == Swift::Int)
482+
// expected-error@-1 {{name of SPI group declaration cannot be qualified with module selector}} {{21-27=}}
483+
public func fn<T>() -> T { fatalError() }
477484
}

0 commit comments

Comments
 (0)