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,
60
60
61
61
// Remap the ParamDecls inside of the ParameterList.
62
62
for (auto &decl : params) {
63
- bool hadDefaultArgument =
64
- decl->getDefaultArgumentKind () == DefaultArgumentKind::Normal;
63
+ auto defaultArgKind = decl->getDefaultArgumentKind ();
65
64
66
65
decl = ParamDecl::cloneWithoutType (C, decl);
67
66
if (options & Implicit)
@@ -74,11 +73,18 @@ ParameterList *ParameterList::clone(const ASTContext &C,
74
73
75
74
// If we're inheriting a default argument, mark it as such.
76
75
// 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:
79
80
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);
82
88
}
83
89
}
84
90
Original file line number Diff line number Diff line change @@ -434,6 +434,23 @@ func testCallableWithDefault(_ x: CallableWithDefault) {
434
434
x ( y: 5 )
435
435
}
436
436
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
+
437
454
// FIXME: Arguably we shouldn't allow calling a constructor like this, as
438
455
// we usually require the user write an explicit '.init'.
439
456
struct WeirdUMEInitCase {
You can’t perform that action at this time.
0 commit comments