Skip to content

Commit 09a91d8

Browse files
Merge pull request #2845 from swiftwasm/main
[pull] swiftwasm from main
2 parents cd63202 + 38efe16 commit 09a91d8

File tree

194 files changed

+67664
-2159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+67664
-2159
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ CHANGELOG
2828
Swift Next
2929
----------
3030

31+
* [SE-0299][]:
32+
33+
It is now possible to use leading-dot syntax in generic contexts to access static members of protocol extensions where `Self` is constrained to a fully concrete type:
34+
35+
```swift
36+
public protocol ToggleStyle { ... }
37+
38+
public struct DefaultToggleStyle: ToggleStyle { ... }
39+
40+
extension ToggleStyle where Self == DefaultToggleStyle {
41+
public static var `default`: Self { .init() }
42+
}
43+
44+
struct Toggle {
45+
func applyToggle<T: ToggleStyle>(_ style: T) { ... }
46+
}
47+
48+
Toggle(...).applyToggle(.default)
49+
```
50+
3151
* Whenever a reference to `Self` does not impede the usage of a protocol as a value type, or a protocol member on a value of protocol type, the same is now true for references to `[Self]` and `[Key : Self]`:
3252

3353
```swift

include/swift-c/SyntaxParser/SwiftSyntaxParser.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ typedef struct {
103103
uint16_t leading_trivia_count;
104104
uint16_t trailing_trivia_count;
105105
swiftparse_token_kind_t kind;
106+
/// Represents the range for the node, including trivia.
107+
swiftparse_range_t range;
106108
} swiftparse_token_data_t;
107109

108110
typedef struct {
@@ -115,9 +117,6 @@ typedef struct {
115117
swiftparse_token_data_t token_data;
116118
swiftparse_layout_data_t layout_data;
117119
};
118-
/// Represents the range for the node. For a token node the range includes
119-
/// the trivia associated with it.
120-
swiftparse_range_t range;
121120
/// The syntax kind. A value of '0' means this is a token node.
122121
swiftparse_syntax_kind_t kind;
123122
bool present;

include/swift/ABI/MetadataValues.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,8 @@ namespace SpecialPointerAuthDiscriminators {
11831183
const uint16_t AsyncContextYield = 0xe207; // = 57863
11841184
const uint16_t CancellationNotificationFunction = 0x1933; // = 6451
11851185
const uint16_t EscalationNotificationFunction = 0x5be4; // = 23524
1186+
const uint16_t AsyncThinNullaryFunction = 0x0f08; // = 3848
1187+
const uint16_t AsyncFutureFunction = 0x720f; // = 29199
11861188

11871189
/// Swift async context parameter stored in the extended frame info.
11881190
const uint16_t SwiftAsyncContextExtendedFrameEntry = 0xc31a; // = 49946

include/swift/ABI/Task.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,15 @@ class FutureAsyncContext : public AsyncContext {
553553
using AsyncContext::AsyncContext;
554554
};
555555

556+
/// An asynchronous context within a task that describes a general "Future"
557+
/// task that was started with a closure context.
558+
class FutureClosureAsyncContext : public FutureAsyncContext {
559+
public:
560+
HeapObject *closureContext;
561+
562+
using FutureAsyncContext::FutureAsyncContext;
563+
};
564+
556565
} // end namespace swift
557566

558567
#endif

include/swift/AST/Builtins.def

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -747,14 +747,6 @@ BUILTIN_MISC_OPERATION_WITH_SILGEN(GetCurrentAsyncTask, "getCurrentAsyncTask", "
747747
/// Cancel the given asynchronous task.
748748
BUILTIN_MISC_OPERATION_WITH_SILGEN(CancelAsyncTask, "cancelAsyncTask", "", Special)
749749

750-
/// createAsyncTask(): (
751-
/// Int, Builtin.NativeObject?, @escaping () async throws -> Void
752-
/// ) -> Builtin.NativeObject
753-
///
754-
/// Create a new asynchronous task, given flags, an (optional) parent task, and
755-
/// a function to execute.
756-
BUILTIN_MISC_OPERATION_WITH_SILGEN(CreateAsyncTask, "createAsyncTask", "", Special)
757-
758750
/// createAsyncTaskFuture(): (
759751
/// Int, Builtin.NativeObject?, @escaping () async throws -> T
760752
/// ) -> Builtin.NativeObject

include/swift/AST/Builtins.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ llvm::AtomicOrdering decodeLLVMAtomicOrdering(StringRef O);
137137
bool canBuiltinBeOverloadedForType(BuiltinValueKind ID, Type Ty);
138138

139139
/// Retrieve the AST-level AsyncTaskAndContext type, used for the
140-
/// createAsyncTask builtin.
140+
/// createAsyncTask* builtins.
141141
Type getAsyncTaskAndContextType(ASTContext &ctx);
142142

143143
}

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,11 @@ REMARK(interface_file_lock_failure,none,
394394
REMARK(interface_file_lock_timed_out,none,
395395
"timed out waiting to acquire lock file for module interface '%0'", (StringRef))
396396

397+
ERROR(error_option_required,none, "option '%0' is required", (StringRef))
398+
ERROR(error_nonexistent_output_dir,none,
399+
"'-output-dir' argument '%0' does not exist or is not a directory", (StringRef))
400+
401+
397402
// Dependency Verifier Diagnostics
398403
ERROR(missing_member_dependency,none,
399404
"expected "

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4287,8 +4287,8 @@ ERROR(actor_isolated_non_self_reference,none,
42874287
"%select{from inside the actor|on 'self'}2",
42884288
(DescriptiveDeclKind, DeclName, bool, unsigned))
42894289
ERROR(actor_isolated_self_independent_context,none,
4290-
"actor-isolated %0 %1 can not be %select{referenced|mutated|used 'inout'}2 from an "
4291-
"'@actorIndependent' context",
4290+
"actor-isolated %0 %1 can not be %select{referenced|mutated|used 'inout'}2 from a "
4291+
"non-isolated context",
42924292
(DescriptiveDeclKind, DeclName, unsigned))
42934293
ERROR(actor_isolated_inout_state,none,
42944294
"actor-isolated %0 %1 cannot be passed 'inout' to"
@@ -4311,7 +4311,7 @@ ERROR(global_actor_from_other_global_actor_context,none,
43114311
(DescriptiveDeclKind, DeclName, Type, Type, unsigned, bool))
43124312
ERROR(global_actor_from_nonactor_context,none,
43134313
"%0 %1 isolated to global actor %2 can not be %select{referenced|mutated|used 'inout'}4"
4314-
" from %select{this|an '@actorIndependent'}3%select{| synchronous}5 context",
4314+
" from %select{this|a non-isolated}3%select{| synchronous}5 context",
43154315
(DescriptiveDeclKind, DeclName, Type, bool, unsigned, bool))
43164316
ERROR(actor_isolated_partial_apply,none,
43174317
"actor-isolated %0 %1 can not be partially applied",

include/swift/AST/SemanticAttrs.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
SEMANTICS_ATTR(STRING_EQUALS, "string.equals")
2828
SEMANTICS_ATTR(STRING_MAKE_UTF8, "string.makeUTF8")
29+
SEMANTICS_ATTR(STRING_GET_UTF8_CSTRING, "string.getUTF8CString")
2930
SEMANTICS_ATTR(STRING_ESCAPE_PERCENT_GET, "string.escapePercent.get")
3031
SEMANTICS_ATTR(STRING_CONCAT, "string.concat")
3132
SEMANTICS_ATTR(STRING_APPEND, "string.append")

include/swift/Option/Options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ namespace options {
3838
ModuleInterfaceOption = (1 << 13),
3939
SupplementaryOutput = (1 << 14),
4040
SwiftAPIExtractOption = (1 << 15),
41+
SwiftSymbolGraphExtractOption = (1 << 16),
4142
};
4243

4344
enum ID {
4445
OPT_INVALID = 0, // This is not an option ID.
4546
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
4647
HELPTEXT, METAVAR, VALUES) \
47-
OPT_##ID,
48+
OPT_##ID,
4849
#include "swift/Option/Options.inc"
4950
LastOption
5051
#undef OPTION

include/swift/Option/Options.td

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ def SupplementaryOutput : OptionFlag;
5858
// The option should be accepted by swift-api-extract.
5959
def SwiftAPIExtractOption : OptionFlag;
6060

61+
// The option should be accepted by swift-symbolgraph-extract.
62+
def SwiftSymbolGraphExtractOption : OptionFlag;
63+
6164
/////////
6265
// Options
6366

@@ -173,7 +176,8 @@ def driver_mode : Joined<["--"], "driver-mode=">, Flags<[HelpHidden]>,
173176

174177
def help : Flag<["-", "--"], "help">,
175178
Flags<[FrontendOption, AutolinkExtractOption, ModuleWrapOption,
176-
SwiftIndentOption, SwiftAPIExtractOption]>,
179+
SwiftIndentOption, SwiftAPIExtractOption,
180+
SwiftSymbolGraphExtractOption]>,
177181
HelpText<"Display available options">;
178182
def h : Flag<["-"], "h">, Alias<help>;
179183
def help_hidden : Flag<["-", "--"], "help-hidden">,
@@ -202,10 +206,12 @@ def o : JoinedOrSeparate<["-"], "o">,
202206
def j : JoinedOrSeparate<["-"], "j">, Flags<[DoesNotAffectIncrementalBuild]>,
203207
HelpText<"Number of commands to execute in parallel">, MetaVarName<"<n>">;
204208

205-
def sdk : Separate<["-"], "sdk">, Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption]>,
209+
def sdk : Separate<["-"], "sdk">,
210+
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
206211
HelpText<"Compile against <sdk>">, MetaVarName<"<sdk>">;
207212

208-
def swift_version : Separate<["-"], "swift-version">, Flags<[FrontendOption, ModuleInterfaceOption, SwiftAPIExtractOption]>,
213+
def swift_version : Separate<["-"], "swift-version">,
214+
Flags<[FrontendOption, ModuleInterfaceOption, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
209215
HelpText<"Interpret input according to a specific Swift language version number">,
210216
MetaVarName<"<vers>">;
211217

@@ -222,16 +228,18 @@ def tools_directory : Separate<["-"], "tools-directory">,
222228
def D : JoinedOrSeparate<["-"], "D">, Flags<[FrontendOption]>,
223229
HelpText<"Marks a conditional compilation flag as true">;
224230

225-
def F : JoinedOrSeparate<["-"], "F">, Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption]>,
231+
def F : JoinedOrSeparate<["-"], "F">,
232+
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
226233
HelpText<"Add directory to framework search path">;
227234
def F_EQ : Joined<["-"], "F=">, Flags<[FrontendOption, ArgumentIsPath]>,
228235
Alias<F>;
229236

230237
def Fsystem : Separate<["-"], "Fsystem">,
231-
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption]>,
238+
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
232239
HelpText<"Add directory to system framework search path">;
233240

234-
def I : JoinedOrSeparate<["-"], "I">, Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption]>,
241+
def I : JoinedOrSeparate<["-"], "I">,
242+
Flags<[FrontendOption, ArgumentIsPath, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
235243
HelpText<"Add directory to the import search path">;
236244
def I_EQ : Joined<["-"], "I=">, Flags<[FrontendOption, ArgumentIsPath]>,
237245
Alias<I>;
@@ -377,7 +385,8 @@ def localization_path : Separate<["-"], "localization-path">,
377385
MetaVarName<"<path>">;
378386

379387
def module_cache_path : Separate<["-"], "module-cache-path">,
380-
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath, SwiftAPIExtractOption]>,
388+
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath, SwiftAPIExtractOption,
389+
SwiftSymbolGraphExtractOption]>,
381390
HelpText<"Specifies the Clang module cache path">;
382391

383392
def enable_library_evolution : Flag<["-"], "enable-library-evolution">,
@@ -398,7 +407,8 @@ def define_availability : Separate<["-"], "define-availability">,
398407
MetaVarName<"<macro>">;
399408

400409
def module_name : Separate<["-"], "module-name">,
401-
Flags<[FrontendOption, ModuleInterfaceOption, SwiftAPIExtractOption]>,
410+
Flags<[FrontendOption, ModuleInterfaceOption, SwiftAPIExtractOption,
411+
SwiftSymbolGraphExtractOption]>,
402412
HelpText<"Name of the module to build">;
403413
def module_name_EQ : Joined<["-"], "module-name=">, Flags<[FrontendOption]>,
404414
Alias<module_name>;
@@ -670,7 +680,8 @@ def framework : Separate<["-"], "framework">, Group<linker_option_Group>,
670680
HelpText<"Specifies a framework which should be linked against">;
671681

672682
def L : JoinedOrSeparate<["-"], "L">, Group<linker_option_Group>,
673-
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath, SwiftAPIExtractOption]>,
683+
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath, SwiftAPIExtractOption,
684+
SwiftSymbolGraphExtractOption]>,
674685
HelpText<"Add directory to library link search path">;
675686
def L_EQ : Joined<["-"], "L=">, Group<linker_option_Group>,
676687
Flags<[FrontendOption, DoesNotAffectIncrementalBuild, ArgumentIsPath]>,
@@ -1021,7 +1032,7 @@ def num_threads : Separate<["-"], "num-threads">,
10211032
def Xfrontend : Separate<["-"], "Xfrontend">, Flags<[HelpHidden]>,
10221033
MetaVarName<"<arg>">, HelpText<"Pass <arg> to the Swift frontend">;
10231034

1024-
def Xcc : Separate<["-"], "Xcc">, Flags<[FrontendOption]>,
1035+
def Xcc : Separate<["-"], "Xcc">, Flags<[FrontendOption, SwiftSymbolGraphExtractOption]>,
10251036
MetaVarName<"<arg>">,
10261037
HelpText<"Pass <arg> to the C/C++/Objective-C compiler">;
10271038

@@ -1033,12 +1044,12 @@ def Xllvm : Separate<["-"], "Xllvm">,
10331044
MetaVarName<"<arg>">, HelpText<"Pass <arg> to LLVM.">;
10341045

10351046
def resource_dir : Separate<["-"], "resource-dir">,
1036-
Flags<[FrontendOption, HelpHidden, ArgumentIsPath]>,
1047+
Flags<[FrontendOption, SwiftSymbolGraphExtractOption, HelpHidden, ArgumentIsPath]>,
10371048
MetaVarName<"</usr/lib/swift>">,
10381049
HelpText<"The directory that holds the compiler resource files">;
10391050

10401051
def target : Separate<["-"], "target">,
1041-
Flags<[FrontendOption, ModuleWrapOption, ModuleInterfaceOption, SwiftAPIExtractOption]>,
1052+
Flags<[FrontendOption, ModuleWrapOption, ModuleInterfaceOption, SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
10421053
HelpText<"Generate code for the given target <triple>, such as x86_64-apple-macos10.9">, MetaVarName<"<triple>">;
10431054
def target_legacy_spelling : Joined<["--"], "target=">,
10441055
Flags<[FrontendOption]>, Alias<target>;
@@ -1194,8 +1205,23 @@ def emit_symbol_graph_dir : Separate<["-"], "emit-symbol-graph-dir">,
11941205
HelpText<"Emit a symbol graph to directory <dir>">,
11951206
MetaVarName<"<dir>">;
11961207

1197-
// Swift API Extraction only options
1198-
def pretty_print: Flag<["-"], "pretty-print">, Flags<[SwiftAPIExtractOption]>,
1208+
def pretty_print: Flag<["-"], "pretty-print">,
1209+
Flags<[SwiftAPIExtractOption, SwiftSymbolGraphExtractOption]>,
11991210
HelpText<"Pretty-print the output JSON">;
12001211

1212+
// swift-symbolgraph-extract-only options
1213+
def output_dir : Separate<["-"], "output-dir">,
1214+
Flags<[NoDriverOption, SwiftSymbolGraphExtractOption, ArgumentIsPath]>,
1215+
HelpText<"Symbol Graph JSON Output Directory (Required)">,
1216+
MetaVarName<"<dir>">;
1217+
1218+
def skip_synthesized_members: Flag<[ "-" ], "skip-synthesized-members">,
1219+
Flags<[NoDriverOption, SwiftSymbolGraphExtractOption]>,
1220+
HelpText<"Skip members inherited through classes or default implementations">;
1221+
1222+
def minimum_access_level : Separate<["-"], "minimum-access-level">,
1223+
Flags<[NoDriverOption, SwiftSymbolGraphExtractOption]>,
1224+
HelpText<"Include symbols with this access level or more">,
1225+
MetaVarName<"<level>">;
1226+
12011227
include "FrontendOptions.td"

0 commit comments

Comments
 (0)