File tree Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Expand file tree Collapse file tree 2 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,7 @@ ParameterList *ParameterList::clone(const ASTContext &C,
6060
6161 // Remap the ParamDecls inside of the ParameterList.
6262 for (auto &decl : params) {
63- bool hadDefaultArgument =
64- decl->getDefaultArgumentKind () == DefaultArgumentKind::Normal;
63+ auto defaultArgKind = decl->getDefaultArgumentKind ();
6564
6665 decl = ParamDecl::cloneWithoutType (C, decl);
6766 if (options & Implicit)
@@ -74,11 +73,18 @@ ParameterList *ParameterList::clone(const ASTContext &C,
7473
7574 // If we're inheriting a default argument, mark it as such.
7675 // FIXME: Figure out how to clone default arguments as well.
77- if (hadDefaultArgument) {
78- if (options & Inherited)
76+ if (options & Inherited) {
77+ switch (defaultArgKind) {
78+ case DefaultArgumentKind::Normal:
79+ case DefaultArgumentKind::StoredProperty:
7980 decl->setDefaultArgumentKind (DefaultArgumentKind::Inherited);
80- else
81- decl->setDefaultArgumentKind (DefaultArgumentKind::None);
81+ break ;
82+
83+ default :
84+ break ;
85+ }
86+ } else {
87+ decl->setDefaultArgumentKind (DefaultArgumentKind::None);
8288 }
8389 }
8490
Original file line number Diff line number Diff line change @@ -434,6 +434,23 @@ func testCallableWithDefault(_ x: CallableWithDefault) {
434434 x ( y: 5 )
435435}
436436
437+ enum E {
438+ // CHECK-LABEL: sil hidden [ossa] @$s17default_arguments1EO6ResultV4name9platformsAESS_SaySiGtcfcfA0_ : $@convention(thin) () -> @owned Array<Int>
439+ struct Result {
440+ var name : String
441+ var platforms : [ Int ] = [ ]
442+ }
443+
444+ // CHECK-LABEL: sil hidden [ossa] @$s17default_arguments1EO4testyyFZ : $@convention(method) (@thin E.Type) -> ()
445+ static func test( ) {
446+ // CHECK: function_ref @$s17default_arguments1EO6ResultV4name9platformsAESS_SaySiGtcfcfA0_ : $@convention(thin) () -> @owned Array<Int>
447+ // CHECK: function_ref @$s17default_arguments1EO4testyyFZAC6ResultVSS_SaySiGtcfu_ : $@convention(thin) (@guaranteed String, @guaranteed Array<Int>) -> @owned E.Result
448+
449+ // CHECK-LABEL: sil private [ossa] @$s17default_arguments1EO4testyyFZAC6ResultVSS_SaySiGtcfu_ : $@convention(thin) (@guaranteed String, @guaranteed Array<Int>) -> @owned E.Result
450+ var result = Self . Result ( name: " " )
451+ }
452+ }
453+
437454// FIXME: Arguably we shouldn't allow calling a constructor like this, as
438455// we usually require the user write an explicit '.init'.
439456struct WeirdUMEInitCase {
You can’t perform that action at this time.
0 commit comments