Skip to content

Commit 86b162b

Browse files
committed
---
yaml --- r: 344059 b: refs/heads/master-rebranch c: d3a4f3d h: refs/heads/master i: 344057: 791cc5a 344055: 1a7f4a3
1 parent 4e3b4ea commit 86b162b

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: e1e6f0e7ba89bd7a1e369a291bf419cf250919d5
1458+
refs/heads/master-rebranch: d3a4f3ded088448a57407462dc34661a8aa1b2b4
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/include/swift/AST/DiagnosticsSema.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,6 +2655,8 @@ ERROR(dynamic_self_invalid_method,none,
26552655
"covariant 'Self' can only appear at the top level of method result type", ())
26562656
ERROR(dynamic_self_stored_property_init,none,
26572657
"covariant 'Self' type cannot be referenced from a stored property initializer", ())
2658+
ERROR(dynamic_self_default_arg,none,
2659+
"covariant 'Self' type cannot be referenced from a default argument expression", ())
26582660

26592661
//------------------------------------------------------------------------------
26602662
// MARK: Type Check Attributes

branches/master-rebranch/lib/Sema/TypeCheckCaptures.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,11 @@ void TypeChecker::computeCaptures(AnyFunctionRef AFR) {
624624
/*isObjC=*/false);
625625
E->walk(finder);
626626

627+
if (finder.getDynamicSelfCaptureLoc().isValid()) {
628+
Context.Diags.diagnose(finder.getDynamicSelfCaptureLoc(),
629+
diag::dynamic_self_default_arg);
630+
}
631+
627632
auto captures = finder.getCaptureInfo();
628633
if (isGeneric)
629634
captures.setGenericParamCaptures(true);

branches/master-rebranch/test/decl/func/dynamic_self.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,3 +437,11 @@ class Iterable : Sequence {
437437
return DummyIterator()
438438
}
439439
}
440+
441+
// Default arguments of methods cannot capture 'Self' or 'self'
442+
class MathClass {
443+
func invalidDefaultArg(s: Int = Self.intMethod()) {}
444+
// expected-error@-1 {{covariant 'Self' type cannot be referenced from a default argument expression}}
445+
446+
static func intMethod() -> Int { return 0 }
447+
}

0 commit comments

Comments
 (0)