Differentiate between Swift 5 and “Swift 6” #file

In -swift-version 5 and earlier, #file will continue to be a synonym for #filePath; in a future -swift-version (“Swift 6 mode”), it will become a synonym for #fileID. #file in libraries will be interpreted according to the language mode the library was compiled in, not the language mode its client uses.

Implement this behavior, tied to a frontend flag instead of a language version. We do so by splitting the old `MagicIdentifierLiteralExprKind::File` into two separate cases, `FileIDSpelledAsFile` and `FilePathSpelledAsFile`, and propagating this distinction throughout the AST. This seems cleaner than looking up the setting for the module the declaration belongs to every time we see `File`.

This doesn’t handle module interfaces yet; we’ll take care of those in a separate commit.
This commit is contained in:
Brent Royal-Gordon
2020-07-03 18:57:01 -07:00
parent 745dbef3ef
commit 9a838bb654
9 changed files with 74 additions and 18 deletions

View File

@@ -1121,9 +1121,10 @@ static uint8_t getRawStableDefaultArgumentKind(swift::DefaultArgumentKind kind)
CASE(Normal)
CASE(Inherited)
CASE(Column)
CASE(File)
CASE(FileID)
CASE(FilePath)
CASE(FileIDSpelledAsFile)
CASE(FilePathSpelledAsFile)
CASE(Line)
CASE(Function)
CASE(DSOHandle)