Allow a protocol extension to define a default implementation for a requirement of its own protocol.

Based on Dave’s hack, this allows one to define a “default implementation” as, e.g.,

  protocol P {
    func foo()
  }

  extension P {
    final func foo() { … }
  }

Swift SVN r28949
This commit is contained in:
Doug Gregor
2015-05-23 03:40:41 +00:00
parent 1b0dbd0100
commit 98314777f2
6 changed files with 155 additions and 11 deletions

View File

@@ -51,7 +51,7 @@ const uint16_t VERSION_MAJOR = 0;
/// To ensure that two separate changes don't silently get merged into one
/// in source control, you should also update the comment to briefly
/// describe what change you made.
const uint16_t VERSION_MINOR = 201; // Last change: extension decls
const uint16_t VERSION_MINOR = 202; // Last change: xref protocol vs. ext
using DeclID = Fixnum<31>;
using DeclIDField = BCFixed<31>;
@@ -1155,13 +1155,15 @@ namespace decls_block {
using XRefValuePathPieceLayout = BCRecordLayout<
XREF_VALUE_PATH_PIECE,
TypeIDField, // type
IdentifierIDField // name
TypeIDField, // type
IdentifierIDField, // name
BCFixed<1> // restrict to protocol extension
>;
using XRefInitializerPathPieceLayout = BCRecordLayout<
XREF_INITIALIZER_PATH_PIECE,
TypeIDField, // type
BCFixed<1>, // restrict to protocol extension
CtorInitializerKindField // initializer kind
>;