Merge pull request #3739 from practicalswift/normalize-headers

diff --git a/apinotes/Foundation.apinotes b/apinotes/Foundation.apinotes
index 4ea5208..8942e03 100644
--- a/apinotes/Foundation.apinotes
+++ b/apinotes/Foundation.apinotes
@@ -1007,8 +1007,6 @@
   SwiftName: NSURLHandle
 - Name: NSMachPort
   SwiftName: NSMachPort
-- Name: NSOutputStream
-  SwiftName: NSOutputStream
 - Name: NSRegularExpression
   SwiftName: NSRegularExpression
 - Name: NSComparisonPredicate
diff --git a/cmake/modules/SwiftSharedCMakeConfig.cmake b/cmake/modules/SwiftSharedCMakeConfig.cmake
index 2c8de4e..5f0dda9 100644
--- a/cmake/modules/SwiftSharedCMakeConfig.cmake
+++ b/cmake/modules/SwiftSharedCMakeConfig.cmake
@@ -91,7 +91,7 @@
   include(AddSwiftTableGen) # This imports TableGen from LLVM.
   include(HandleLLVMOptions)
 
-  # HACK: this ugly tweaking is to prevent the propogation of the flag from LLVM
+  # HACK: this ugly tweaking is to prevent the propagation of the flag from LLVM
   # into swift.  The use of this flag pollutes all targets, and we are not able
   # to remove it on a per-target basis which breaks cross-compilation.
   string(REGEX REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
diff --git a/docs/ABI.rst b/docs/ABI.rst
index 07a015a..65ad414 100644
--- a/docs/ABI.rst
+++ b/docs/ABI.rst
@@ -1018,7 +1018,6 @@
   impl-function-attribute ::= 'Cm'            // compatible with Swift method
   impl-function-attribute ::= 'CO'            // compatible with ObjC method
   impl-function-attribute ::= 'Cw'            // compatible with protocol witness
-  impl-function-attribute ::= 'N'             // noreturn
   impl-function-attribute ::= 'G'             // generic
   impl-function-attribute ::= 'g'             // pseudogeneric
   impl-parameter ::= impl-convention type
@@ -1029,8 +1028,8 @@
 implementation details of a function type.
 
 Any ``<impl-function-attribute>`` productions must appear in the order
-in which they are specified above: e.g. a noreturn C function is
-mangled with ``CcN``.  ``g`` and ``G`` are exclusive and mark the presence
+in which they are specified above: e.g. a pseudogeneric C function is
+mangled with ``Ccg``.  ``g`` and ``G`` are exclusive and mark the presence
 of a generic signature immediately following.
 
 Note that the convention and function-attribute productions do not
diff --git a/docs/Generics.rst b/docs/Generics.rst
index 091d686..eceff59 100644
--- a/docs/Generics.rst
+++ b/docs/Generics.rst
@@ -855,7 +855,7 @@
 
 by splitting the '>>' operator token into two '>' operator tokens.
 
-However, this is manageable, and is already implemented for the (now depreacted)
+However, this is manageable, and is already implemented for the (now deprecated)
 protocol composition syntax (protocol<>). The larger problem occurs at expression
 context, where the parser cannot disambiguate the tokens::
 
diff --git a/docs/Lexicon.rst b/docs/Lexicon.rst
index 0702741..71db7b1 100644
--- a/docs/Lexicon.rst
+++ b/docs/Lexicon.rst
@@ -84,7 +84,7 @@
 
   IWYU (include what you use)
     The accepted wisdom that implementation files (``.cpp``, ``.c``, ``.m``,
-    ``.mm``) should explicity ``#include`` or ``#import`` the headers they use.
+    ``.mm``) should explicitly ``#include`` or ``#import`` the headers they use.
     Doing so prevents compilation errors when header files are included in a
     different order, or when header files are modified to use forward
     declarations instead of direct includes.
diff --git a/docs/SIL.rst b/docs/SIL.rst
index 9f8c1c3..f281643 100644
--- a/docs/SIL.rst
+++ b/docs/SIL.rst
@@ -1216,8 +1216,8 @@
 ``switch`` statement failing to cover all possible values of its subject.
 The guaranteed dead code elimination pass can eliminate truly unreachable
 basic blocks, or ``unreachable`` instructions may be dominated by applications
-of ``@noreturn`` functions. An ``unreachable`` instruction that survives
-guaranteed DCE and is not immediately preceded by a ``@noreturn``
+of functions returning uninhabited types. An ``unreachable`` instruction that
+survives guaranteed DCE and is not immediately preceded by an no-return
 application is a dataflow error.
 
 Runtime Failure
@@ -3912,12 +3912,8 @@
 - A class tuple element of the destination type may be a superclass or
   subclass of the source type's corresponding tuple element.
 
-The function types may also differ in attributes, with the following
-caveats:
-
-- The ``convention`` attribute cannot be changed.
-- A ``@noreturn`` function may be converted to a non-``@noreturn``
-  type and vice-versa.
+The function types may also differ in attributes, except that the
+``convention`` attribute cannot be changed.
 
 thin_function_to_pointer
 ````````````````````````
@@ -4133,7 +4129,7 @@
 Indicates that control flow must not reach the end of the current basic block.
 It is a dataflow error if an unreachable terminator is reachable from the entry
 point of a function and is not immediately preceded by an ``apply`` of a
-``@noreturn`` function.
+no-return function.
 
 return
 ``````
diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h
index f8f63eb..02f28c1 100644
--- a/include/swift/AST/Decl.h
+++ b/include/swift/AST/Decl.h
@@ -4838,35 +4838,13 @@
   /// depending on the function context.
   bool argumentNameIsAPIByDefault() const;
 
+  /// \brief Returns the "natural" number of argument clauses taken by this
+  /// function.  This value is one for free-standing functions, and two for
+  /// methods.
   unsigned getNumParameterLists() const {
     return AbstractFunctionDeclBits.NumParameterLists;
   }
 
-  /// \brief Returns the "natural" number of argument clauses taken by this
-  /// function.  This value is always at least one, and it may be more if the
-  /// function is implicitly or explicitly curried.
-  ///
-  /// For example, this function:
-  /// \code
-  ///   func negate(x : Int) -> Int { return -x }
-  /// \endcode
-  /// has a natural argument count of 1 if it is freestanding.  If it is
-  /// a method, it has a natural argument count of 2, as does this
-  /// curried function:
-  /// \code
-  ///   func add(x : Int)(y : Int) -> Int { return x + y }
-  /// \endcode
-  ///
-  /// This value never exceeds the number of chained function types
-  /// in the function's type, but it can be less for functions which
-  /// return a value of function type:
-  /// \code
-  ///   func const(x : Int) -> () -> Int { return { x } } // NAC==1
-  /// \endcode
-  unsigned getNaturalArgumentCount() const {
-    return getNumParameterLists();
-  }
-
   /// \brief Returns the parameter pattern(s) for the function definition that
   /// determine the parameter names bound in the function body.
   ///
diff --git a/include/swift/AST/DiagnosticsSema.def b/include/swift/AST/DiagnosticsSema.def
index 370c609..ba3b30d 100644
--- a/include/swift/AST/DiagnosticsSema.def
+++ b/include/swift/AST/DiagnosticsSema.def
@@ -1118,6 +1118,9 @@
 WARNING(non_trailing_closure_before_default_args,none,
         "closure parameter prior to parameters with default arguments will "
         "not be treated as a trailing closure", ())
+ERROR(noreturn_not_supported,none,
+      "'@noreturn' has been removed; functions that never return should have a "
+      "return type of 'Never' instead", ())
 
 // Extensions
 ERROR(non_nominal_extension,none,
@@ -1326,8 +1329,6 @@
      "candidate is marked 'mutating' but protocol does not allow it", ())
 NOTE(protocol_witness_settable_conflict,none,
      "candidate is not settable, but protocol requires it", ())
-NOTE(protocol_witness_noreturn_conflict,none,
-     "candidate is not @noreturn, but protocol requires it", ())
 NOTE(protocol_witness_rethrows_conflict,none,
      "candidate is not 'rethrows', but protocol requires it", ())
 NOTE(protocol_witness_throws_conflict,none,
@@ -1775,9 +1776,6 @@
       "'final' cannot be applied to accessors, it must be put on the "
       "%select{var|let|subscript}0", (unsigned))
 
-ERROR(override_noreturn_with_return,none,
-      "an override of a @noreturn method should also be @noreturn", ())
-
 ERROR(override_rethrows_with_non_rethrows,none,
       "override of 'rethrows' %select{method|initializer}0 should also "
       "be 'rethrows'", (bool))
diff --git a/include/swift/AST/Expr.h b/include/swift/AST/Expr.h
index 07e9ce6..00e6470 100644
--- a/include/swift/AST/Expr.h
+++ b/include/swift/AST/Expr.h
@@ -2844,8 +2844,6 @@
     return parameterList ? parameterList : ArrayRef<const ParameterList *>();
   }
 
-  unsigned getNaturalArgumentCount() const { return 1; }
-
   /// \brief Retrieve the result type of this closure.
   Type getResultType() const;
 
diff --git a/include/swift/AST/PrintOptions.h b/include/swift/AST/PrintOptions.h
index da90d22..21bfc0d 100644
--- a/include/swift/AST/PrintOptions.h
+++ b/include/swift/AST/PrintOptions.h
@@ -313,7 +313,7 @@
   /// \brief The information for converting archetypes to specialized types.
   std::shared_ptr<TypeTransformContext> TransformContext;
 
-  /// \brief If this is not \c nullptr then functions (incuding accessors and
+  /// \brief If this is not \c nullptr then functions (including accessors and
   /// constructors) will be printed with a body that is determined by this
   /// function.
   std::function<std::string(const ValueDecl *)> FunctionBody;
diff --git a/include/swift/AST/Types.h b/include/swift/AST/Types.h
index d2683fb..f1a219b 100644
--- a/include/swift/AST/Types.h
+++ b/include/swift/AST/Types.h
@@ -2125,15 +2125,14 @@
     // you'll need to adjust both the Bits field below and
     // BaseType::AnyFunctionTypeBits.
 
-    //   |representation|isAutoClosure|noReturn|noEscape|throws|
-    //   |    0 .. 3    |      4      |   5    |    6   |   7  |
+    //   |representation|isAutoClosure|noEscape|throws|
+    //   |    0 .. 3    |      4      |    5   |   6  |
     //
     enum : uint16_t { RepresentationMask     = 0x00F };
     enum : uint16_t { AutoClosureMask        = 0x010 };
-    enum : uint16_t { NoReturnMask           = 0x020 };
-    enum : uint16_t { NoEscapeMask           = 0x040 };
-    enum : uint16_t { ThrowsMask             = 0x080 };
-    enum : uint16_t { ExplicitlyEscapingMask = 0x100 };
+    enum : uint16_t { NoEscapeMask           = 0x020 };
+    enum : uint16_t { ThrowsMask             = 0x040 };
+    enum : uint16_t { ExplicitlyEscapingMask = 0x080 };
 
     uint16_t Bits;
 
@@ -2148,23 +2147,20 @@
     }
 
     // Constructor for polymorphic type.
-    ExtInfo(Representation Rep, bool IsNoReturn, bool Throws) {
-      Bits = ((unsigned) Rep) |
-             (IsNoReturn ? NoReturnMask : 0) |
-             (Throws ? ThrowsMask : 0);
+    ExtInfo(Representation Rep, bool Throws) {
+      Bits = ((unsigned) Rep) | (Throws ? ThrowsMask : 0);
     }
 
     // Constructor with no defaults.
-    ExtInfo(Representation Rep, bool IsNoReturn,
+    ExtInfo(Representation Rep,
             bool IsAutoClosure, bool IsNoEscape, bool IsExplicitlyEscaping,
             bool Throws)
-      : ExtInfo(Rep, IsNoReturn, Throws) {
+      : ExtInfo(Rep, Throws) {
       Bits |= (IsAutoClosure ? AutoClosureMask : 0);
       Bits |= (IsNoEscape ? NoEscapeMask : 0);
       Bits |= (IsExplicitlyEscaping ? ExplicitlyEscapingMask : 0);
     }
 
-    bool isNoReturn() const { return Bits & NoReturnMask; }
     bool isAutoClosure() const { return Bits & AutoClosureMask; }
     bool isNoEscape() const { return Bits & NoEscapeMask; }
     bool isExplicitlyEscaping() const { return Bits & ExplicitlyEscapingMask; }
@@ -2211,12 +2207,6 @@
       return ExtInfo((Bits & ~RepresentationMask)
                      | (unsigned)Rep);
     }
-    ExtInfo withIsNoReturn(bool IsNoReturn = true) const {
-      if (IsNoReturn)
-        return ExtInfo(Bits | NoReturnMask);
-      else
-        return ExtInfo(Bits & ~NoReturnMask);
-    }
     ExtInfo withIsAutoClosure(bool IsAutoClosure = true) const {
       if (IsAutoClosure)
         return ExtInfo(Bits | AutoClosureMask);
@@ -2285,10 +2275,6 @@
     return getExtInfo().getRepresentation();
   }
   
-  bool isNoReturn() const {
-    return getExtInfo().isNoReturn();
-  }
-
   /// \brief True if this type allows an implicit conversion from a function
   /// argument expression of type T to a function of type () -> T.
   bool isAutoClosure() const {
@@ -2866,14 +2852,13 @@
   class ExtInfo {
     // Feel free to rearrange or add bits, but if you go over 15,
     // you'll need to adjust both the Bits field below and
-    // BaseType::AnyFunctionTypeBits.
+    // TypeBase::AnyFunctionTypeBits.
 
-    //   |representation|noReturn|pseudogeneric|
-    //   |    0 .. 3    |   4    |      5      |
+    //   |representation|pseudogeneric|
+    //   |    0 .. 3    |      4      |
     //
     enum : uint16_t { RepresentationMask = 0x00F };
-    enum : uint16_t { NoReturnMask       = 0x010 };
-    enum : uint16_t { PseudogenericMask  = 0x020 };
+    enum : uint16_t { PseudogenericMask  = 0x010 };
 
     uint16_t Bits;
 
@@ -2886,9 +2871,8 @@
     ExtInfo() : Bits(0) { }
 
     // Constructor for polymorphic type.
-    ExtInfo(Representation rep, bool isNoReturn, bool isPseudogeneric) {
+    ExtInfo(Representation rep, bool isPseudogeneric) {
       Bits = ((unsigned) rep) |
-             (isNoReturn ? NoReturnMask : 0) |
              (isPseudogeneric ? PseudogenericMask : 0);
     }
 
@@ -2896,9 +2880,6 @@
     /// is not permitted to dynamically depend on its type arguments.
     bool isPseudogeneric() const { return Bits & PseudogenericMask; }
 
-    /// Do functions of this type return normally?
-    bool isNoReturn() const { return Bits & NoReturnMask; }
-
     /// What is the abstract representation of this function value?
     Representation getRepresentation() const {
       return Representation(Bits & RepresentationMask);
@@ -2956,12 +2937,6 @@
       return ExtInfo((Bits & ~RepresentationMask)
                      | (unsigned)Rep);
     }
-    ExtInfo withIsNoReturn(bool IsNoReturn = true) const {
-      if (IsNoReturn)
-        return ExtInfo(Bits | NoReturnMask);
-      else
-        return ExtInfo(Bits & ~NoReturnMask);
-    }
     ExtInfo withIsPseudogeneric(bool isPseudogeneric = true) const {
       if (isPseudogeneric)
         return ExtInfo(Bits | PseudogenericMask);
@@ -3207,10 +3182,6 @@
     return getExtInfo().getRepresentation();
   }
 
-  bool isNoReturn() const {
-    return getExtInfo().isNoReturn();
-  }
-
   bool isPseudogeneric() const {
     return getExtInfo().isPseudogeneric();
   }
diff --git a/include/swift/SIL/SILOpenedArchetypesTracker.h b/include/swift/SIL/SILOpenedArchetypesTracker.h
index 2ab3cd9..7b9cad5 100644
--- a/include/swift/SIL/SILOpenedArchetypesTracker.h
+++ b/include/swift/SIL/SILOpenedArchetypesTracker.h
@@ -49,7 +49,7 @@
 
   const SILFunction &getFunction() const { return F; }
 
-  // Register a definiton of a given opened archetype.
+  // Register a definition of a given opened archetype.
   void addOpenedArchetypeDef(Type archetype, SILValue Def);
 
   void removeOpenedArchetypeDef(Type archetype, SILValue Def) {
diff --git a/include/swift/SILOptimizer/Analysis/ARCAnalysis.h b/include/swift/SILOptimizer/Analysis/ARCAnalysis.h
index 7a77fa2..9c73a3e 100644
--- a/include/swift/SILOptimizer/Analysis/ARCAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/ARCAnalysis.h
@@ -393,10 +393,10 @@
 
 namespace swift {
 
-/// EpilogueARCBlockState - Keep track of whether a epilogue ARC instruction has
-/// been found.
+/// EpilogueARCBlockState - Keep track of whether an epilogue ARC instruction
+/// has been found.
 struct EpilogueARCBlockState {
-  /// Keep track of whether a eplogue release has been found before and after
+  /// Keep track of whether a epilogue release has been found before and after
   /// this basic block.
   bool BBSetIn;
   /// The basic block local SILValue we are interested to find epilogue ARC in.
diff --git a/include/swift/Serialization/ModuleFormat.h b/include/swift/Serialization/ModuleFormat.h
index aa1960d..2ba98d9 100644
--- a/include/swift/Serialization/ModuleFormat.h
+++ b/include/swift/Serialization/ModuleFormat.h
@@ -53,7 +53,7 @@
 /// in source control, you should also update the comment to briefly
 /// describe what change you made. The content of this comment isn't important;
 /// it just ensures a conflict if two people change the module format.
-const uint16_t VERSION_MINOR = 255; // Last change: bind_memory instruction
+const uint16_t VERSION_MINOR = 256; // Last change: remove noreturn bit
 
 using DeclID = PointerEmbeddedInt<unsigned, 31>;
 using DeclIDField = BCFixed<31>;
@@ -587,7 +587,6 @@
     TypeIDField, // output
     FunctionTypeRepresentationField, // representation
     BCFixed<1>,  // auto-closure?
-    BCFixed<1>,  // noreturn?
     BCFixed<1>,  // noescape?
     BCFixed<1>,  // explicitlyEscaping?
     BCFixed<1>   // throws?
@@ -681,7 +680,6 @@
     TypeIDField, // output
     DeclIDField, // decl that owns the generic params
     FunctionTypeRepresentationField, // representation
-    BCFixed<1>,  // noreturn?
     BCFixed<1>   // throws?
     // Trailed by its generic parameters, if the owning decl ID is 0.
   >;
@@ -691,7 +689,6 @@
     TypeIDField,         // input
     TypeIDField,         // output
     FunctionTypeRepresentationField, // representation
-    BCFixed<1>,          // noreturn?
     BCFixed<1>,          // throws?
     BCArray<TypeIDField> // generic parameters
                          // followed by requirements
@@ -701,7 +698,6 @@
     SIL_FUNCTION_TYPE,
     ParameterConventionField, // callee convention
     SILFunctionTypeRepresentationField, // representation
-    BCFixed<1>,            // noreturn?
     BCFixed<1>,            // pseudogeneric?
     BCFixed<1>,            // error result?
     BCFixed<30>,           // number of parameters
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 3b36541..a975ff8 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -169,9 +169,6 @@
   /// The declaration of Swift.Void.
   TypeAliasDecl *VoidDecl = nullptr;
 
-  /// The declaration of Swift.Any.
-  TypeAliasDecl *AnyDecl = nullptr;
-
   /// The declaration of ObjectiveC.ObjCBool.
   StructDecl *ObjCBoolDecl = nullptr;
 
diff --git a/lib/AST/ASTDumper.cpp b/lib/AST/ASTDumper.cpp
index 3df8f0a..241228c 100644
--- a/lib/AST/ASTDumper.cpp
+++ b/lib/AST/ASTDumper.cpp
@@ -2869,7 +2869,6 @@
         break;
       }
 
-      printFlag(T->isNoReturn(), "noreturn");
       printFlag(T->isAutoClosure(), "autoclosure");
       printFlag(T->isNoEscape(), "noescape");
       printFlag(T->isExplicitlyEscaping(), "escaping");
diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp
index a4d1c07..f198703 100644
--- a/lib/AST/ASTPrinter.cpp
+++ b/lib/AST/ASTPrinter.cpp
@@ -3752,9 +3752,6 @@
         break;
       }
     }
-
-    if (info.isNoReturn())
-      Printer << "@noreturn ";
   }
 
   void printFunctionExtInfo(SILFunctionType::ExtInfo info) {
@@ -3789,9 +3786,6 @@
 
     if (info.isPseudogeneric())
       Printer << "@pseudogeneric ";
-
-    if (info.isNoReturn())
-      Printer << "@noreturn ";
   }
 
   void visitFunctionType(FunctionType *T) {
diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp
index 790be77..54edf0f 100644
--- a/lib/AST/ASTVerifier.cpp
+++ b/lib/AST/ASTVerifier.cpp
@@ -2304,7 +2304,7 @@
       // If a decl has the Throws bit set, the function type should throw,
       // and vice versa.
       auto fnTy = AFD->getType()->castTo<AnyFunctionType>();
-      for (unsigned i = 1, e = AFD->getNaturalArgumentCount(); i != e; ++i)
+      for (unsigned i = 1, e = AFD->getNumParameterLists(); i != e; ++i)
         fnTy = fnTy->getResult()->castTo<AnyFunctionType>();
 
       if (AFD->hasThrows() != fnTy->getExtInfo().throws()) {
diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp
index 477be25..6ce7b30 100644
--- a/lib/AST/Builtins.cpp
+++ b/lib/AST/Builtins.cpp
@@ -984,7 +984,7 @@
   auto HandleTy = Context.TheRawPointerType;
   auto VoidTy = Context.TheEmptyTupleType;
   auto Thin = FunctionType::ExtInfo(FunctionTypeRepresentation::Thin,
-                                    /*noreturn*/ false, /*throws*/ false);
+                                    /*throws*/ false);
   
   auto BlockTy = FunctionType::get(VoidTy, VoidTy, Thin);
   return getBuiltinFunction(Id, {HandleTy, BlockTy}, VoidTy);
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index b7d7ca4..46328a9 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1426,12 +1426,12 @@
 /// we may need to compare the extended information.
 ///
 /// In the type of the function declaration, none of the extended information
-/// is relevant. We cannot overload purely on @noreturn, 'throws', or the
-/// calling convention of the declaration itself.
+/// is relevant. We cannot overload purely on 'throws' or the calling
+/// convention of the declaration itself.
 ///
 /// For function parameter types, we do want to be able to overload on
 /// 'throws', since that is part of the mangled symbol name, but not
-/// @noreturn or @noescape.
+/// @noescape.
 static AnyFunctionType::ExtInfo
 mapSignatureExtInfo(AnyFunctionType::ExtInfo info,
                     bool topLevelFunction) {
@@ -4415,7 +4415,7 @@
   if (resultTy->is<ErrorType>())
     return resultTy;
 
-  for (unsigned i = 0, e = getNaturalArgumentCount(); i != e; ++i)
+  for (unsigned i = 0, e = getNumParameterLists(); i != e; ++i)
     resultTy = resultTy->castTo<AnyFunctionType>()->getResult();
 
   if (!resultTy)
diff --git a/lib/AST/Mangle.cpp b/lib/AST/Mangle.cpp
index b559d07..a5bec80 100644
--- a/lib/AST/Mangle.cpp
+++ b/lib/AST/Mangle.cpp
@@ -979,7 +979,6 @@
     // <impl-function-attribute> ::= 'Cc'             // C global function
     // <impl-function-attribute> ::= 'Cm'             // Swift method
     // <impl-function-attribute> ::= 'CO'             // ObjC method
-    // <impl-function-attribute> ::= 'N'              // noreturn
     // <impl-function-attribute> ::= 'g'              // pseudogeneric
     // <impl-function-attribute> ::= 'G'              // generic
     // <impl-parameter> ::= <impl-convention> <type>
@@ -1042,7 +1041,6 @@
       break;
     }
     
-    if (fn->isNoReturn()) Buffer << 'N';
     if (fn->isPolymorphic()) {
       Buffer << (fn->isPseudogeneric() ? 'g' : 'G');
       mangleGenericSignature(fn->getGenericSignature());
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 508e558..ec7158a 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -1541,8 +1541,6 @@
       return false;
     if (fMe->getRepresentation() != fThem->getRepresentation())
       return false;
-    if (fMe->isNoReturn() != fThem->isNoReturn())
-      return false;
     if (!fMe->getInput()->isSpelledLike(fThem->getInput()))
       return false;
     if (!fMe->getResult()->isSpelledLike(fThem->getResult()))
@@ -2421,13 +2419,10 @@
     if (!fn1)
       return false;
 
-    // Allow ExtInfos to differ in these ways:
-    //   - the overriding type may be noreturn even if the base type isn't
-    //   - the base type may be throwing even if the overriding type isn't
+    // Allow the base type to be throwing even if the overriding type isn't
     auto ext1 = fn1->getExtInfo();
     auto ext2 = fn2->getExtInfo();
     if (ext2.throws()) ext1 = ext1.withThrows(true);
-    if (ext1.isNoReturn()) ext2 = ext2.withIsNoReturn(true);
     if (ext1 != ext2)
       return false;
 
diff --git a/lib/AST/TypeRepr.cpp b/lib/AST/TypeRepr.cpp
index 294dbc4..b5f533d 100644
--- a/lib/AST/TypeRepr.cpp
+++ b/lib/AST/TypeRepr.cpp
@@ -275,7 +275,6 @@
 
 void AttributedTypeRepr::printAttrs(ASTPrinter &Printer) const {
   const TypeAttributes &Attrs = getAttrs();
-  if (Attrs.has(TAK_noreturn))     Printer << "@noreturn ";
 
   switch (Attrs.has(TAK_autoclosure)*2 + Attrs.has(TAK_noescape)) {
   case 0: break;  // Nothing specified.
diff --git a/lib/Basic/Demangle.cpp b/lib/Basic/Demangle.cpp
index 4e18b05..1eb45c6 100644
--- a/lib/Basic/Demangle.cpp
+++ b/lib/Basic/Demangle.cpp
@@ -2122,7 +2122,6 @@
   // impl-function-attribute ::= 'Cm'            // compatible with Swift method
   // impl-function-attribute ::= 'CO'            // compatible with ObjC method
   // impl-function-attribute ::= 'Cw'            // compatible with protocol witness
-  // impl-function-attribute ::= 'N'             // noreturn
   // impl-function-attribute ::= 'G'             // generic
   NodePointer demangleImplFunctionType() {
     NodePointer type = NodeFactory::create(Node::Kind::ImplFunctionType);
@@ -2145,9 +2144,6 @@
         return nullptr;
     }
 
-    if (Mangled.nextIf('N'))
-      addImplFunctionAttribute(type, "@noreturn");
-
     // Enter a new generic context if this type is generic.
     // FIXME: replace with std::optional, when we have it.
     bool isPseudogeneric = false;
diff --git a/lib/Basic/Remangle.cpp b/lib/Basic/Remangle.cpp
index 61ccbca..36de4c2 100644
--- a/lib/Basic/Remangle.cpp
+++ b/lib/Basic/Remangle.cpp
@@ -1125,8 +1125,6 @@
     Out << "CO";
   } else if (text == "@convention(witness_method)") {
     Out << "Cw";
-  } else if (text == "@noreturn") {
-    Out << "CN";
   } else {
     unreachable("bad impl-function-attribute");
   }
diff --git a/lib/IRGen/GenObjC.cpp b/lib/IRGen/GenObjC.cpp
index 2859951..7ab2f22 100644
--- a/lib/IRGen/GenObjC.cpp
+++ b/lib/IRGen/GenObjC.cpp
@@ -740,7 +740,6 @@
   };
   auto result = SILResultInfo(classType, ResultConvention::Owned);
   auto extInfo = SILFunctionType::ExtInfo(SILFunctionType::Representation::ObjCMethod,
-                                          /*noreturn*/ false,
                                           /*pseudogeneric*/ true);
 
   return SILFunctionType::get(nullptr, extInfo,
diff --git a/lib/Immediate/ImmediateImpl.h b/lib/Immediate/ImmediateImpl.h
index b3be672..62a8dc9 100644
--- a/lib/Immediate/ImmediateImpl.h
+++ b/lib/Immediate/ImmediateImpl.h
@@ -35,7 +35,7 @@
 namespace immediate {
 
 // Returns a handle to the runtime suitable for other 'dlsym' or 'dlclose' 
-// calls or 'NULL' if an error occured. 
+// calls or 'NULL' if an error occurred.
 void *loadSwiftRuntime(StringRef runtimeLibPath);
 bool tryLoadLibraries(ArrayRef<LinkLibrary> LinkLibraries,
                       SearchPathOptions SearchPathOpts,
diff --git a/lib/Parse/ParseType.cpp b/lib/Parse/ParseType.cpp
index 3ce3768..249c103 100644
--- a/lib/Parse/ParseType.cpp
+++ b/lib/Parse/ParseType.cpp
@@ -417,8 +417,8 @@
       SourceLoc RAngleLoc = consumeStartingGreater();
       auto AnyRange = SourceRange(ProtocolLoc, RAngleLoc);
       
-      // Warn that 'protocol<>' is depreacted and offer to
-      // repalace with the 'Any' keyword
+      // Warn that 'protocol<>' is deprecated and offer to
+      // replace with the 'Any' keyword
       diagnose(LAngleLoc, diag::deprecated_any_composition)
         .fixItReplace(AnyRange, "Any");
       
diff --git a/lib/RemoteAST/RemoteAST.cpp b/lib/RemoteAST/RemoteAST.cpp
index d28841c..844cfcc 100644
--- a/lib/RemoteAST/RemoteAST.cpp
+++ b/lib/RemoteAST/RemoteAST.cpp
@@ -274,7 +274,6 @@
     }
 
     auto einfo = AnyFunctionType::ExtInfo(representation,
-                                          /*noreturn*/ false,
                                           /*throws*/ flags.throws());
 
     // The result type must be materializable.
diff --git a/lib/SIL/DynamicCasts.cpp b/lib/SIL/DynamicCasts.cpp
index 6872b7a..8960126 100644
--- a/lib/SIL/DynamicCasts.cpp
+++ b/lib/SIL/DynamicCasts.cpp
@@ -343,12 +343,6 @@
       if (sourceFunction->throws() && !targetFunction->throws())
         return DynamicCastFeasibility::WillFail;
       
-      // A noreturn source function can be cast to a returning target type,
-      // but not vice versa.
-      // (noreturn isn't really reified at runtime though.)
-      if (targetFunction->isNoReturn() && !sourceFunction->isNoReturn())
-        return DynamicCastFeasibility::WillFail;
-      
       // The cast can't change the representation at runtime.
       if (targetFunction->getRepresentation()
             != sourceFunction->getRepresentation())
diff --git a/lib/SIL/SILBuilder.cpp b/lib/SIL/SILBuilder.cpp
index 307f59c..eaaf246 100644
--- a/lib/SIL/SILBuilder.cpp
+++ b/lib/SIL/SILBuilder.cpp
@@ -40,10 +40,8 @@
   auto params = FTI->getParameters();
   auto newParams = params.slice(0, params.size() - argCount);
 
-  auto extInfo = SILFunctionType::ExtInfo(
-                                        SILFunctionType::Representation::Thick,
-                                        FTI->isNoReturn(),
-                                        FTI->isPseudogeneric());
+  auto extInfo = FTI->getExtInfo().withRepresentation(
+      SILFunctionType::Representation::Thick);
 
   // If the original method has an @unowned_inner_pointer return, the partial
   // application thunk will lifetime-extend 'self' for us, converting the
diff --git a/lib/SIL/SILFunctionType.cpp b/lib/SIL/SILFunctionType.cpp
index 5359ccd..b0f6c0a 100644
--- a/lib/SIL/SILFunctionType.cpp
+++ b/lib/SIL/SILFunctionType.cpp
@@ -817,8 +817,7 @@
   //   We should bring it back when we have those optimizations.
   auto silExtInfo = SILFunctionType::ExtInfo()
     .withRepresentation(extInfo.getSILRepresentation())
-    .withIsPseudogeneric(pseudogeneric)
-    .withIsNoReturn(extInfo.isNoReturn());
+    .withIsPseudogeneric(pseudogeneric);
   
   return SILFunctionType::get(genericSig,
                               silExtInfo, calleeConvention,
@@ -2427,12 +2426,6 @@
     if (fnType->getExtInfo().throws())
       extInfo = extInfo.withThrows();
 
-    // The @noreturn property of the uncurried function really comes
-    // from the innermost function. It is not meaningful for intermediate
-    // functions to also be @noreturn, but we don't prohibit it here.
-    if (fnType->getExtInfo().isNoReturn())
-      extInfo = extInfo.withIsNoReturn();
-
     if (uncurryLevel-- == 0)
       break;
     fnType = cast<AnyFunctionType>(fnType.getResult());
diff --git a/lib/SIL/SILType.cpp b/lib/SIL/SILType.cpp
index 104bc66..33f529c 100644
--- a/lib/SIL/SILType.cpp
+++ b/lib/SIL/SILType.cpp
@@ -71,12 +71,8 @@
 }
 
 bool SILType::isNoReturnFunction() const {
-  if (auto funcTy = dyn_cast<SILFunctionType>(getSwiftRValueType())) {
-    if (funcTy->isNoReturn())
-      return true;
-
+  if (auto funcTy = dyn_cast<SILFunctionType>(getSwiftRValueType()))
     return funcTy->getSILResult().getSwiftRValueType()->isNever();
-  }
 
   return false;
 }
diff --git a/lib/SIL/TypeLowering.cpp b/lib/SIL/TypeLowering.cpp
index 2d089c2..b488aad 100644
--- a/lib/SIL/TypeLowering.cpp
+++ b/lib/SIL/TypeLowering.cpp
@@ -1683,7 +1683,6 @@
          && "There are no foreign destroying destructors");
   AnyFunctionType::ExtInfo extInfo =
             AnyFunctionType::ExtInfo(FunctionType::Representation::Thin,
-                                     /*noreturn*/ false,
                                      /*throws*/ false);
   if (isForeign)
     extInfo = extInfo
@@ -1714,7 +1713,6 @@
   auto emptyTupleTy = TupleType::getEmpty(ctx)->getCanonicalType();
   CanType resultType = isDestroyer? emptyTupleTy : classType;
   auto extInfo = AnyFunctionType::ExtInfo(FunctionType::Representation::Thin,
-                                          /*noreturn*/ false,
                                           /*throws*/ false);
   extInfo = extInfo
     .withSILRepresentation(isObjC? SILFunctionTypeRepresentation::ObjCMethod
@@ -1768,7 +1766,6 @@
                                                                 captureInfo);
 
   auto innerExtInfo = AnyFunctionType::ExtInfo(FunctionType::Representation::Thin,
-                                               funcType->isNoReturn(),
                                                funcType->throws());
 
   // If we don't have any local captures (including function captures),
@@ -1794,7 +1791,6 @@
   // Add an extra empty tuple level to represent the captures. We'll append the
   // lowered capture types here.
   auto extInfo = AnyFunctionType::ExtInfo(FunctionType::Representation::Thin,
-                                          /*noreturn*/ false,
                                           /*throws*/ false);
 
   if (genericSig) {
diff --git a/lib/SILGen/SILGenApply.cpp b/lib/SILGen/SILGenApply.cpp
index 7913267..d26a621 100644
--- a/lib/SILGen/SILGenApply.cpp
+++ b/lib/SILGen/SILGenApply.cpp
@@ -298,7 +298,6 @@
       buildSubstSelfType(selfType, protocolSelfType, ctx);
 
     auto extInfo = FunctionType::ExtInfo(FunctionType::Representation::Thin,
-                                         /*noreturn*/ false,
                                          /*throws*/ OrigFormalInterfaceType->throws());
 
     SubstFormalType = CanFunctionType::get(substSelfType, SubstFormalType,
diff --git a/lib/SILOptimizer/Transforms/CSE.cpp b/lib/SILOptimizer/Transforms/CSE.cpp
index 2e45e91..bb41f87 100644
--- a/lib/SILOptimizer/Transforms/CSE.cpp
+++ b/lib/SILOptimizer/Transforms/CSE.cpp
@@ -673,7 +673,7 @@
   SILOpenedArchetypesTracker OpenedArchetypesTracker(*Inst->getFunction());
   // Register the new archetype to be used.
   OpenedArchetypesTracker.registerOpenedArchetypes(dyn_cast<SILInstruction>(V));
-  // Use a cloner. It makes copying the instruction and remaping of
+  // Use a cloner. It makes copying the instruction and remapping of
   // opened archetypes trivial.
   InstructionCloner Cloner(I->getFunction());
   Cloner.registerOpenedExistentialRemapping(
@@ -744,7 +744,7 @@
     if (ValueBase *V = AvailableValues->lookup(Inst)) {
       DEBUG(llvm::dbgs() << "SILCSE CSE: " << *Inst << "  to: " << *V << '\n');
       // Instructions producing a new opened archetype need a special handling,
-      // because replacing these intructions may require a replacement
+      // because replacing these instructions may require a replacement
       // of the opened archetype type operands in some of the uses.
       if (!isa<OpenExistentialRefInst>(Inst) ||
           processOpenExistentialRef(Inst, V, I)) {
diff --git a/lib/Sema/CSApply.cpp b/lib/Sema/CSApply.cpp
index 34ace82..84d9321 100644
--- a/lib/Sema/CSApply.cpp
+++ b/lib/Sema/CSApply.cpp
@@ -577,7 +577,7 @@
       if (auto func = dyn_cast<AbstractFunctionDecl>(member)) {
         // For functions, close the existential once the function
         // has been fully applied.
-        return func->getNaturalArgumentCount();
+        return func->getNumParameterLists();
       } else {
         // For storage, close the existential either when it's
         // accessed (if it's an rvalue only) or when it is loaded or
@@ -1388,7 +1388,7 @@
     Expr *bridgeErrorToObjectiveC(Expr *value) {
       auto &tc = cs.getTypeChecker();
 
-      // Use _bridgeErrorToNSError to conver to an NSError.
+      // Use _bridgeErrorToNSError to convert to an NSError.
       auto fn = tc.Context.getBridgeErrorToNSError(&tc);
       SourceLoc loc = value->getLoc();
       if (!fn) {
@@ -5596,10 +5596,8 @@
       // throwing subexpressions. We also don't want to change the convention
       // of the original closure.
       auto fromEI = fromFunc->getExtInfo(), toEI = toFunc->getExtInfo();
-      if ((toEI.isNoEscape() && !fromEI.isNoEscape()) ||
-          (toEI.isNoReturn() && !fromEI.isNoReturn())) {
+      if (toEI.isNoEscape() && !fromEI.isNoEscape()) {
         swift::AnyFunctionType::ExtInfo newEI(fromEI.getRepresentation(),
-                                        toEI.isNoReturn() | fromEI.isNoReturn(),
                                         toEI.isAutoClosure(),
                                         toEI.isNoEscape() | fromEI.isNoEscape(),
                                         toEI.isExplicitlyEscaping() | fromEI.isExplicitlyEscaping(),
diff --git a/lib/Sema/CSDiag.cpp b/lib/Sema/CSDiag.cpp
index c18181e..c3d806a 100644
--- a/lib/Sema/CSDiag.cpp
+++ b/lib/Sema/CSDiag.cpp
@@ -2279,7 +2279,7 @@
         if (decl0->getName() == decl0->getASTContext().Id_MatchOperator) {
           assert(binaryExpr->getArg()->getElements().size() == 2);
 
-          // If the rhs of '~=' is the enum type, a single dot suffices
+          // If the rhs of '~=' is the enum type, a single dot suffixes
           // since the type can be inferred
           Type secondArgType = binaryExpr->getArg()->getElement(1)->getType();
           if (secondArgType->isEqual(enumMetatype->getInstanceType())) {
@@ -2438,7 +2438,7 @@
 
         // See through function decl context
         if (auto parent = CS->DC->getParent())
-        // If we are in an protocol extension of 'Proto' and we see
+        // If we are in a protocol extension of 'Proto' and we see
         // 'Proto.static', suggest 'Self.static'
         if (auto extensionContext = parent->getAsProtocolExtensionContext()) {
           if (extensionContext->getDeclaredType()->getCanonicalType()
@@ -2580,7 +2580,7 @@
   }
   
   // If we're trying to convert something from optional type to Bool, then a
-  // comparision against nil was probably expected.
+  // comparison against nil was probably expected.
   // TODO: It would be nice to handle "!x" --> x == false, but we have no way
   // to get to the parent expr at present.
   if (exprType->getAnyOptionalObjectType()) {
diff --git a/lib/Sema/CSGen.cpp b/lib/Sema/CSGen.cpp
index 35d0b7e..27739cd 100644
--- a/lib/Sema/CSGen.cpp
+++ b/lib/Sema/CSGen.cpp
@@ -595,9 +595,6 @@
         }
       }
 
-      // If there might be replacement constraints, get them now.
-      SmallVector<Constraint *, 4> replacementConstraints;
-
       // Copy over the existing bindings, dividing the constraints up
       // into "favored" and non-favored lists.
       SmallVector<Constraint *, 4> favoredConstraints;
diff --git a/lib/Sema/CSSimplify.cpp b/lib/Sema/CSSimplify.cpp
index eb8c734..082d891 100644
--- a/lib/Sema/CSSimplify.cpp
+++ b/lib/Sema/CSSimplify.cpp
@@ -875,12 +875,6 @@
       return SolutionKind::Error;
   }
 
-  // A @noreturn function type can be a subtype of a non-@noreturn function
-  // type.
-  if (func1->isNoReturn() != func2->isNoReturn() &&
-      (func2->isNoReturn() || kind < TypeMatchKind::SameType))
-    return SolutionKind::Error;
-
   // A non-@noescape function type can be a subtype of a @noescape function
   // type.
   if (func1->isNoEscape() != func2->isNoEscape() &&
diff --git a/lib/Sema/ConstraintSystem.cpp b/lib/Sema/ConstraintSystem.cpp
index a0073df..284aaeb 100644
--- a/lib/Sema/ConstraintSystem.cpp
+++ b/lib/Sema/ConstraintSystem.cpp
@@ -1601,8 +1601,6 @@
         auto extInfo = ft->getExtInfo();
         if (it->second.isNoEscape())
           extInfo = extInfo.withNoEscape();
-        if (it->second.isNoReturn())
-          extInfo = extInfo.withIsNoReturn();
         if (it->second.throws())
           extInfo = extInfo.withThrows();
         return FunctionType::get(ft->getInput(), ft->getResult(), extInfo);
@@ -1631,8 +1629,6 @@
         auto extInfo = ft->getExtInfo();
         if (it->second.isNoEscape())
           extInfo = extInfo.withNoEscape();
-        if (it->second.isNoReturn())
-          extInfo = extInfo.withIsNoReturn();
         if (it->second.throws())
           extInfo = extInfo.withThrows();
         return FunctionType::get(simplifyType(tc, ft->getInput()),
diff --git a/lib/Sema/MiscDiagnostics.cpp b/lib/Sema/MiscDiagnostics.cpp
index 7779fa8..a43eb67 100644
--- a/lib/Sema/MiscDiagnostics.cpp
+++ b/lib/Sema/MiscDiagnostics.cpp
@@ -182,7 +182,7 @@
       if (expr->getArg()->getType()->hasInOut()) {
         // We need to apply all argument clauses.
         InvalidPartialApplications.insert({
-          fnExpr, {fn->getNaturalArgumentCount(), kind}
+          fnExpr, {fn->getNumParameterLists(), kind}
         });
       }
     }
diff --git a/lib/Sema/TypeCheckAttr.cpp b/lib/Sema/TypeCheckAttr.cpp
index 59d9735..36ddada 100644
--- a/lib/Sema/TypeCheckAttr.cpp
+++ b/lib/Sema/TypeCheckAttr.cpp
@@ -59,7 +59,6 @@
   IGNORED_ATTR(Inline)
   IGNORED_ATTR(NSApplicationMain)
   IGNORED_ATTR(NSCopying)
-  IGNORED_ATTR(NoReturn)
   IGNORED_ATTR(NonObjC)
   IGNORED_ATTR(ObjC)
   IGNORED_ATTR(ObjCBridged)
@@ -84,6 +83,65 @@
   IGNORED_ATTR(DiscardableResult)
 #undef IGNORED_ATTR
 
+  // @noreturn has been replaced with a 'Never' return type.
+  void visitNoReturnAttr(NoReturnAttr *attr) {
+    if (auto FD = dyn_cast<FuncDecl>(D)) {
+      auto &SM = TC.Context.SourceMgr;
+
+      auto diag = TC.diagnose(attr->getLocation(),
+                              diag::noreturn_not_supported);
+      auto range = attr->getRangeWithAt();
+      if (range.isValid())
+        range.End = range.End.getAdvancedLoc(1);
+      diag.fixItRemove(range);
+
+      auto *last = FD->getParameterList(FD->getNumParameterLists() - 1);
+
+      // If the declaration already has a result type, we're going
+      // to change it to 'Never'.
+      bool hadResultType = false;
+      bool isEndOfLine = false;
+      SourceLoc resultLoc;
+      if (FD->getBodyResultTypeLoc().hasLocation()) {
+        const auto &typeLoc = FD->getBodyResultTypeLoc();
+        hadResultType = true;
+        resultLoc = typeLoc.getSourceRange().Start;
+
+      // If the function 'throws', insert the result type after the
+      // 'throws'.
+      } else {
+        if (FD->getThrowsLoc().isValid()) {
+          resultLoc = FD->getThrowsLoc();
+
+        // Otherwise, insert the result type after the final parameter
+        // list.
+        } else if (last->getRParenLoc().isValid()) {
+          resultLoc = last->getRParenLoc();
+        }
+
+        if (Lexer::getLocForEndOfToken(SM, resultLoc).getAdvancedLoc(1) ==
+            Lexer::getLocForEndOfLine(SM, resultLoc))
+          isEndOfLine = true;
+
+        resultLoc = Lexer::getLocForEndOfToken(SM, resultLoc);
+      }
+
+      if (hadResultType) {
+        diag.fixItReplace(resultLoc, "Never");
+      } else {
+        std::string fix = " -> Never";
+
+        if (!isEndOfLine)
+          fix = fix + " ";
+
+        diag.fixItInsert(resultLoc, fix);
+      }
+
+      FD->getBodyResultTypeLoc() = TypeLoc::withoutLoc(
+          TC.Context.getNeverType());
+    }
+  }
+
   void visitAlignmentAttr(AlignmentAttr *attr) {
     // Alignment must be a power of two.
     unsigned value = attr->Value;
@@ -1651,21 +1709,6 @@
   var->overwriteType(ReferenceStorageType::get(type, ownershipKind, Context));
 }
 
-AnyFunctionType::ExtInfo
-TypeChecker::applyFunctionTypeAttributes(AbstractFunctionDecl *func,
-                                         unsigned i) {
-  auto info = AnyFunctionType::ExtInfo();
-
-  // For curried functions, 'throws' and 'noreturn' only applies to the
-  // innermost function.
-  if (i == 0) {
-    info = info.withIsNoReturn(func->getAttrs().hasAttribute<NoReturnAttr>());
-    info = info.withThrows(func->hasThrows());
-  }
-
-  return info;
-}
-
 Optional<Diag<>>
 TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable(const Decl *D) {
   DeclContext *DC = D->getDeclContext();
diff --git a/lib/Sema/TypeCheckDecl.cpp b/lib/Sema/TypeCheckDecl.cpp
index a8b70b1..b47f74b 100644
--- a/lib/Sema/TypeCheckDecl.cpp
+++ b/lib/Sema/TypeCheckDecl.cpp
@@ -4004,8 +4004,11 @@
       } else if (e - i - 1 == 0 && outerGenericParams) {
         params = outerGenericParams;
       }
-      
-      auto Info = TC.applyFunctionTypeAttributes(FD, i);
+
+      // 'throws' only applies to the innermost function.
+      AnyFunctionType::ExtInfo Info;
+      if (i == 0 && FD->hasThrows())
+        Info = Info.withThrows();
       
       if (params) {
         funcTy = PolymorphicFunctionType::get(argTy, funcTy, params, Info);
@@ -4561,7 +4564,7 @@
     if (auto func = dyn_cast<FuncDecl>(decl)) {
       if (func->hasDynamicSelf()) {
         type = type->replaceCovariantResultType(subclass,
-                                                func->getNaturalArgumentCount());
+                                                func->getNumParameterLists());
       }
     } else if (isa<ConstructorDecl>(decl)) {
       type = type->replaceCovariantResultType(subclass, /*uncurryLevel=*/2);
@@ -4799,10 +4802,12 @@
   }
 
   static void adjustFunctionTypeForOverride(Type &type) {
-    // Drop 'noreturn' and 'throws'.
+    // Drop 'throws'.
+    // FIXME: Do we want to allow overriding a function returning a value
+    // with one returning Never?
     auto fnType = type->castTo<AnyFunctionType>();
     auto extInfo = fnType->getExtInfo();
-    extInfo = extInfo.withThrows(false).withIsNoReturn(false);
+    extInfo = extInfo.withThrows(false);
     if (fnType->getExtInfo() != extInfo)
       type = fnType->withExtInfo(extInfo);
   }
@@ -5366,6 +5371,7 @@
     UNINTERESTING_ATTR(Mutating)
     UNINTERESTING_ATTR(NonMutating)
     UNINTERESTING_ATTR(NonObjC)
+    UNINTERESTING_ATTR(NoReturn)
     UNINTERESTING_ATTR(NSApplicationMain)
     UNINTERESTING_ATTR(NSCopying)
     UNINTERESTING_ATTR(NSManaged)
@@ -5452,15 +5458,6 @@
       TC.diagnose(Base, diag::overridden_here);
     }
 
-    void visitNoReturnAttr(NoReturnAttr *attr) {
-      // Disallow overriding a @noreturn function with a returning one.
-      if (Base->getAttrs().hasAttribute<NoReturnAttr>() &&
-          !Override->getAttrs().hasAttribute<NoReturnAttr>()) {
-        TC.diagnose(Override, diag::override_noreturn_with_return);
-        TC.diagnose(Base, diag::overridden_here);
-      }
-    }
-
     void visitDynamicAttr(DynamicAttr *attr) {
       if (!Override->getAttrs().hasAttribute<DynamicAttr>())
         // Dynamic is inherited.
diff --git a/lib/Sema/TypeCheckError.cpp b/lib/Sema/TypeCheckError.cpp
index 9fe14b4..7881957 100644
--- a/lib/Sema/TypeCheckError.cpp
+++ b/lib/Sema/TypeCheckError.cpp
@@ -56,7 +56,7 @@
     : TheKind(Kind::Function),
       IsRethrows(fn->getAttrs().hasAttribute<RethrowsAttr>()),
       IsProtocolMethod(isProtocolMethod),
-      ParamCount(fn->getNaturalArgumentCount()) {
+      ParamCount(fn->getNumParameterLists()) {
     TheFunction = fn;
   }
 
@@ -64,7 +64,7 @@
     : TheKind(Kind::Closure),
       IsRethrows(false),
       IsProtocolMethod(false),
-      ParamCount(closure->getNaturalArgumentCount()) {
+      ParamCount(1) {
     TheClosure = closure;
   }
 
@@ -380,11 +380,6 @@
   }
 }
 
-template <class T>
-static ThrowingKind classifyFunctionBodyWithoutContext(T *fn) {
-  return classifyFunctionByType(fn->getType(), fn->getNaturalArgumentCount());
-}
-
 /// A class for collecting information about rethrowing functions.
 class ApplyClassifier {
   llvm::DenseMap<void*, ThrowingKind> Cache;
@@ -850,9 +845,8 @@
   };
 
 private:
-  template <class T>
-  static Kind getKindForFunctionBody(T *fn) {
-    switch (classifyFunctionBodyWithoutContext(fn)) {
+  static Kind getKindForFunctionBody(Type type, unsigned numArgs) {
+    switch (classifyFunctionByType(type, numArgs)) {
     case ThrowingKind::None:
       return Kind::NonThrowingFunction;
     case ThrowingKind::Invalid:
@@ -885,7 +879,8 @@
       result.RethrowsDC = D;
       return result;
     }
-    return Context(getKindForFunctionBody(D));
+    return Context(getKindForFunctionBody(
+        D->getType(), D->getNumParameterLists()));
   }
 
   static Context forInitializer(Initializer *init) {
@@ -908,7 +903,7 @@
   }
 
   static Context forClosure(AbstractClosureExpr *E) {
-    auto kind = getKindForFunctionBody(E);
+    auto kind = getKindForFunctionBody(E->getType(), 1);
     if (kind != Kind::Handled && isa<AutoClosureExpr>(E))
       kind = Kind::NonThrowingAutoClosure;
     return Context(kind);
diff --git a/lib/Sema/TypeCheckGeneric.cpp b/lib/Sema/TypeCheckGeneric.cpp
index a31d063..c159b88 100644
--- a/lib/Sema/TypeCheckGeneric.cpp
+++ b/lib/Sema/TypeCheckGeneric.cpp
@@ -633,7 +633,15 @@
         initArgTy = argTy;
     }
 
-    auto info = applyFunctionTypeAttributes(func, i);
+    // 'throws' only applies to the innermost function.
+    AnyFunctionType::ExtInfo info;
+    if (i == 0 && func->hasThrows())
+      info = info.withThrows();
+
+    assert(!argTy->hasArchetype());
+    assert(!funcTy->hasArchetype());
+    if (initFuncTy)
+      assert(!initFuncTy->hasArchetype());
 
     if (sig && i == e-1) {
       funcTy = GenericFunctionType::get(sig, argTy, funcTy, info);
@@ -647,12 +655,9 @@
   }
 
   // Record the interface type.
-  assert(!funcTy->hasArchetype());
   func->setInterfaceType(funcTy);
-  if (initFuncTy) {
-    assert(!initFuncTy->hasArchetype());
+  if (initFuncTy)
     cast<ConstructorDecl>(func)->setInitializerInterfaceType(initFuncTy);
-  }
 
   if (func->getGenericParams()) {
     // Collect all generic params referenced in parameter types,
diff --git a/lib/Sema/TypeCheckProtocol.cpp b/lib/Sema/TypeCheckProtocol.cpp
index f907e12..3b5b0ef 100644
--- a/lib/Sema/TypeCheckProtocol.cpp
+++ b/lib/Sema/TypeCheckProtocol.cpp
@@ -122,9 +122,6 @@
     /// \brief The witness did not match because of mutating conflicts.
     MutatingConflict,
 
-    /// The witness is not @noreturn, but the requirement is.
-    NoReturnConflict,
-
     /// The witness is not rethrows, but the requirement is.
     RethrowsConflict,
 
@@ -315,7 +312,6 @@
       case MatchKind::PrefixNonPrefixConflict:
       case MatchKind::PostfixNonPostfixConflict:
       case MatchKind::MutatingConflict:
-      case MatchKind::NoReturnConflict:
       case MatchKind::RethrowsConflict:
       case MatchKind::ThrowsConflict:
       case MatchKind::NonObjC:
@@ -339,7 +335,6 @@
       case MatchKind::PrefixNonPrefixConflict:
       case MatchKind::PostfixNonPostfixConflict:
       case MatchKind::MutatingConflict:
-      case MatchKind::NoReturnConflict:
       case MatchKind::RethrowsConflict:
       case MatchKind::ThrowsConflict:
       case MatchKind::NonObjC:
@@ -729,11 +724,6 @@
     if (checkMutating(funcReq, funcWitness, funcWitness))
       return RequirementMatch(witness, MatchKind::MutatingConflict);
 
-    /// If the requirement is @noreturn, the witness must also be @noreturn.
-    if (reqAttrs.hasAttribute<NoReturnAttr>() &&
-        !witnessAttrs.hasAttribute<NoReturnAttr>())
-      return RequirementMatch(witness, MatchKind::NoReturnConflict);
-
     // If the requirement is rethrows, the witness must either be
     // rethrows or be non-throwing.
     if (reqAttrs.hasAttribute<RethrowsAttr>() &&
@@ -1784,10 +1774,6 @@
     // FIXME: Could emit a Fix-It here.
     tc.diagnose(match.Witness, diag::protocol_witness_mutating_conflict);
     break;
-  case MatchKind::NoReturnConflict:
-    // FIXME: Could emit a Fix-It here.
-    tc.diagnose(match.Witness, diag::protocol_witness_noreturn_conflict);
-    break;
   case MatchKind::RethrowsConflict:
     // FIXME: Could emit a Fix-It here.
     tc.diagnose(match.Witness, diag::protocol_witness_rethrows_conflict);
@@ -2007,7 +1993,7 @@
     llvm_unreachable("Unknown adopter kind");
   }
 
-  // FIXME: Infer body indention from the source rather than hard-coding
+  // FIXME: Infer body indentation from the source rather than hard-coding
   // 4 spaces.
   std::string ExtraIndent = "    ";
   StringRef CurrentIndent = Lexer::getIndentationForLine(TC.Context.SourceMgr,
diff --git a/lib/Sema/TypeCheckType.cpp b/lib/Sema/TypeCheckType.cpp
index a720ad9..91589b9 100644
--- a/lib/Sema/TypeCheckType.cpp
+++ b/lib/Sema/TypeCheckType.cpp
@@ -519,8 +519,7 @@
     if (auto outerSig = TAD->getDeclContext()->getGenericSignatureOfContext()) {
       for (auto outerParam : outerSig->getGenericParams()) {
         subs[outerParam->getCanonicalType().getPointer()] =
-            ArchetypeBuilder::mapTypeIntoContext(TAD->getDeclContext(),
-                                                 outerParam);
+            resolver->resolveGenericTypeParamType(outerParam);
       }
     }
 
@@ -1816,9 +1815,7 @@
     }
 
     // Resolve the function type directly with these attributes.
-    SILFunctionType::ExtInfo extInfo(rep,
-                                     attrs.has(TAK_noreturn),
-                                     attrs.has(TAK_pseudogeneric));
+    SILFunctionType::ExtInfo extInfo(rep, attrs.has(TAK_pseudogeneric));
 
     ty = resolveSILFunctionType(fnRepr, options, extInfo, calleeConvention);
     if (!ty || ty->is<ErrorType>()) return ty;
@@ -1854,9 +1851,23 @@
       attrs.clearAttribute(TAK_autoclosure);
     }
 
+    // @noreturn has been replaced with a 'Never' return type.
+    if (fnRepr && attrs.has(TAK_noreturn)) {
+      auto &SM = TC.Context.SourceMgr;
+      auto loc = attrs.getLoc(TAK_noreturn);
+      auto attrRange = SourceRange(
+        loc.getAdvancedLoc(-1),
+        Lexer::getLocForEndOfToken(SM, loc));
+
+      auto resultRange = fnRepr->getResultTypeRepr()->getSourceRange();
+
+      TC.diagnose(loc, diag::noreturn_not_supported)
+          .fixItRemove(attrRange)
+          .fixItReplace(resultRange, "Never");
+    }
+
     // Resolve the function type directly with these attributes.
     FunctionType::ExtInfo extInfo(rep,
-                                  attrs.has(TAK_noreturn),
                                   attrs.has(TAK_autoclosure),
                                   attrs.has(TAK_noescape),
                                   attrs.has(TAK_escaping),
diff --git a/lib/Sema/TypeChecker.cpp b/lib/Sema/TypeChecker.cpp
index ed6bd62..3ca19c6 100644
--- a/lib/Sema/TypeChecker.cpp
+++ b/lib/Sema/TypeChecker.cpp
@@ -1317,7 +1317,7 @@
       if (CurrentInfo.isContainedIn(NewConstraint)) {
         DiagnosticEngine &Diags = TC.Diags;
         // Some availability checks will always pass because the minimum
-        // deployment target gurantees they will never be false. We don't
+        // deployment target guarantees they will never be false. We don't
         // diagnose these checks as useless because the source file may
         // be shared with other projects/targets having older deployment
         // targets. We don't currently have a mechanism for the user to
diff --git a/lib/Sema/TypeChecker.h b/lib/Sema/TypeChecker.h
index 846479d..36822f7 100644
--- a/lib/Sema/TypeChecker.h
+++ b/lib/Sema/TypeChecker.h
@@ -968,11 +968,6 @@
     handleExternalDecl(nominal);
   }
 
-  /// Determine attributes for the given function and curry level, with a level
-  /// of 0 indicating the innermost function.
-  AnyFunctionType::ExtInfo
-  applyFunctionTypeAttributes(AbstractFunctionDecl *func, unsigned i);
-
   /// Infer default value witnesses for all requirements in the given protocol.
   void inferDefaultWitnesses(ProtocolDecl *proto);
 
diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp
index c2af067..b733aea 100644
--- a/lib/Serialization/Deserialization.cpp
+++ b/lib/Serialization/Deserialization.cpp
@@ -3434,12 +3434,11 @@
     TypeID inputID;
     TypeID resultID;
     uint8_t rawRepresentation;
-    bool autoClosure, noreturn, noescape, explicitlyEscaping, throws;
+    bool autoClosure, noescape, explicitlyEscaping, throws;
 
     decls_block::FunctionTypeLayout::readRecord(scratch, inputID, resultID,
                                                 rawRepresentation,
                                                 autoClosure,
-                                                noreturn,
                                                 noescape,
                                                 explicitlyEscaping,
                                                 throws);
@@ -3450,7 +3449,7 @@
     }
     
     auto Info = FunctionType::ExtInfo(*representation,
-                               noreturn, autoClosure, noescape,
+                               autoClosure, noescape,
                                explicitlyEscaping, throws);
     
     typeOrOffset = FunctionType::get(getType(inputID), getType(resultID),
@@ -3799,16 +3798,13 @@
     TypeID resultID;
     DeclID genericContextID;
     uint8_t rawRep;
-    bool noreturn = false;
     bool throws = false;
 
-    // TODO: add noreturn serialization.
     decls_block::PolymorphicFunctionTypeLayout::readRecord(scratch,
                                                            inputID,
                                                            resultID,
                                                            genericContextID,
                                                            rawRep,
-                                                           noreturn,
                                                            throws);
     GenericParamList *paramList =
       maybeGetOrReadGenericParams(genericContextID, FileContext, DeclTypeCursor);
@@ -3821,7 +3817,6 @@
     }
     
     auto Info = PolymorphicFunctionType::ExtInfo(*rep,
-                                                 noreturn,
                                                  throws);
 
     typeOrOffset = PolymorphicFunctionType::get(getType(inputID),
@@ -3834,16 +3829,13 @@
     TypeID inputID;
     TypeID resultID;
     uint8_t rawRep;
-    bool noreturn = false;
     bool throws = false;
     ArrayRef<uint64_t> genericParamIDs;
 
-    // TODO: add noreturn serialization.
     decls_block::GenericFunctionTypeLayout::readRecord(scratch,
                                                        inputID,
                                                        resultID,
                                                        rawRep,
-                                                       noreturn,
                                                        throws,
                                                        genericParamIDs);
     auto rep = getActualFunctionTypeRepresentation(rawRep);
@@ -3868,7 +3860,7 @@
     // Read the generic requirements.
     SmallVector<Requirement, 4> requirements;
     readGenericRequirements(requirements);
-    auto info = GenericFunctionType::ExtInfo(*rep, noreturn, throws);
+    auto info = GenericFunctionType::ExtInfo(*rep, throws);
 
     auto sig = GenericSignature::get(genericParams, requirements);
     typeOrOffset = GenericFunctionType::get(sig,
@@ -3898,7 +3890,6 @@
   case decls_block::SIL_FUNCTION_TYPE: {
     uint8_t rawCalleeConvention;
     uint8_t rawRepresentation;
-    bool noreturn = false;
     bool pseudogeneric = false;
     bool hasErrorResult;
     unsigned numParams;
@@ -3908,7 +3899,6 @@
     decls_block::SILFunctionTypeLayout::readRecord(scratch,
                                              rawCalleeConvention,
                                              rawRepresentation,
-                                             noreturn,
                                              pseudogeneric,
                                              hasErrorResult,
                                              numParams,
@@ -3922,7 +3912,7 @@
       error();
       return nullptr;
     }
-    SILFunctionType::ExtInfo extInfo(*representation, noreturn, pseudogeneric);
+    SILFunctionType::ExtInfo extInfo(*representation, pseudogeneric);
 
     // Process the callee convention.
     auto calleeConvention = getActualParameterConvention(rawCalleeConvention);
diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp
index b09c090..b507f69 100644
--- a/lib/Serialization/Serialization.cpp
+++ b/lib/Serialization/Serialization.cpp
@@ -2949,7 +2949,6 @@
            addTypeRef(fnTy->getResult()),
            getRawStableFunctionTypeRepresentation(fnTy->getRepresentation()),
            fnTy->isAutoClosure(),
-           fnTy->isNoReturn(),
            fnTy->isNoEscape(),
            fnTy->isExplicitlyEscaping(),
            fnTy->throws());
@@ -2967,7 +2966,6 @@
             addTypeRef(fnTy->getResult()),
             dID,
             getRawStableFunctionTypeRepresentation(fnTy->getRepresentation()),
-            fnTy->isNoReturn(),
             fnTy->throws());
     if (!genericContext)
       writeGenericParams(&fnTy->getGenericParams(), DeclTypeAbbrCodes);
@@ -2984,7 +2982,6 @@
             addTypeRef(fnTy->getInput()),
             addTypeRef(fnTy->getResult()),
             getRawStableFunctionTypeRepresentation(fnTy->getRepresentation()),
-            fnTy->isNoReturn(),
             fnTy->throws(),
             genericParams);
 
@@ -3049,7 +3046,6 @@
     SILFunctionTypeLayout::emitRecord(Out, ScratchRecord, abbrCode,
           stableCalleeConvention,
           stableRepresentation,
-          fnTy->isNoReturn(),
           fnTy->isPseudogeneric(),
           fnTy->hasErrorResult(),
           fnTy->getParameters().size(),
diff --git a/stdlib/public/SDK/Foundation/Locale.swift b/stdlib/public/SDK/Foundation/Locale.swift
index c501b80..ca0c512 100644
--- a/stdlib/public/SDK/Foundation/Locale.swift
+++ b/stdlib/public/SDK/Foundation/Locale.swift
@@ -27,7 +27,7 @@
 /**
  `Locale` encapsulates information about linguistic, cultural, and technological conventions and standards. Examples of information encapsulated by a locale include the symbol used for the decimal separator in numbers and the way dates are formatted.
  
- Locales are typically used to provide, format, and interpret information about and according to the user’s customs and preferences. They are frequently used in conjunction with formatters. Although you can use many locales, you usually use the one associated with the current user.
+ Locales are typically used to provide, format, and interpret information about and according to the user's customs and preferences. They are frequently used in conjunction with formatters. Although you can use many locales, you usually use the one associated with the current user.
 */
 public struct Locale : CustomStringConvertible, CustomDebugStringConvertible, Hashable, Equatable, ReferenceConvertible {
     public typealias ReferenceType = NSLocale
diff --git a/stdlib/public/SDK/Foundation/NSError.swift b/stdlib/public/SDK/Foundation/NSError.swift
index 44aeeac..e2aeb2f 100644
--- a/stdlib/public/SDK/Foundation/NSError.swift
+++ b/stdlib/public/SDK/Foundation/NSError.swift
@@ -71,7 +71,7 @@
   }
 }
 
-/// Describes an error that may be recoverably by presenting several
+/// Describes an error that may be recoverable by presenting several
 /// potential recovery options to the user.
 public protocol RecoverableError : Error {
   /// Provides a set of possible recovery options to present to the user.
@@ -93,7 +93,7 @@
   ///
   /// This entry point is used for recovery of errors handled at
   /// the "application" granularity, where nothing else in the
-  /// application can proceed until the attmpted error recovery
+  /// application can proceed until the attempted error recovery
   /// completes.
   func attemptRecovery(optionIndex recoveryOptionIndex: Int) -> Bool
 }
diff --git a/stdlib/public/SDK/Foundation/TimeZone.swift b/stdlib/public/SDK/Foundation/TimeZone.swift
index b4793dc..2116079 100644
--- a/stdlib/public/SDK/Foundation/TimeZone.swift
+++ b/stdlib/public/SDK/Foundation/TimeZone.swift
@@ -26,7 +26,7 @@
  
  `TimeZone` provides two static functions to get time zone values: `current` and `autoupdatingCurrent`. The `autoupdatingCurrent` time zone automatically tracks updates made by the user.
  
- Note that time zone database entries such as “America/Los_Angeles” are IDs, not names. An example of a time zone name is “Pacific Daylight Time”. Although many `TimeZone` functions include the word “name”, they refer to IDs.
+ Note that time zone database entries such as "America/Los_Angeles" are IDs, not names. An example of a time zone name is "Pacific Daylight Time". Although many `TimeZone` functions include the word "name", they refer to IDs.
  
  Cocoa does not provide any API to change the time zone of the computer, or of other applications.
  */
@@ -87,10 +87,10 @@
     
     /// Returns a time zone identified by a given abbreviation.
     ///
-    /// In general, you are discouraged from using abbreviations except for unique instances such as “GMT”. Time Zone abbreviations are not standardized and so a given abbreviation may have multiple meanings—for example, “EST” refers to Eastern Time in both the United States and Australia
+    /// In general, you are discouraged from using abbreviations except for unique instances such as "GMT". Time Zone abbreviations are not standardized and so a given abbreviation may have multiple meanings—for example, "EST" refers to Eastern Time in both the United States and Australia
     ///
     /// - parameter abbreviation: The abbreviation for the time zone.
-    /// - returns: A time zone identified by abbreviation determined by resolving the abbreviation to a identifier using the abbreviation dictionary and then returning the time zone for that identifier. Returns `nil` if there is no match for abbreviation.
+    /// - returns: A time zone identified by abbreviation determined by resolving the abbreviation to an identifier using the abbreviation dictionary and then returning the time zone for that identifier. Returns `nil` if there is no match for abbreviation.
     public init?(abbreviation: String) {
         if let r = NSTimeZone(abbreviation: abbreviation) {
             _wrapped = r
@@ -141,7 +141,7 @@
     
     /// Returns the abbreviation for the time zone at a given date.
     ///
-    /// Note that the abbreviation may be different at different dates. For example, during daylight saving time the US/Eastern time zone has an abbreviation of “EDT.” At other times, its abbreviation is “EST.”
+    /// Note that the abbreviation may be different at different dates. For example, during daylight saving time the US/Eastern time zone has an abbreviation of "EDT." At other times, its abbreviation is "EST."
     /// - parameter date: The date to use for the calculation. The default value is the current date.
     public func abbreviation(for date: Date = Date()) -> String? {
         return _wrapped.abbreviation(for: date)
diff --git a/stdlib/public/SDK/Foundation/URL.swift b/stdlib/public/SDK/Foundation/URL.swift
index 1971ce0..f63995a 100644
--- a/stdlib/public/SDK/Foundation/URL.swift
+++ b/stdlib/public/SDK/Foundation/URL.swift
@@ -275,7 +275,7 @@
     
     /// The document identifier -- a value assigned by the kernel to a document (which can be either a file or directory) and is used to identify the document regardless of where it gets moved on a volume.
     ///
-    /// The document identifier survives "safe save” operations; i.e it is sticky to the path it was assigned to (`replaceItem(at:,withItemAt:,backupItemName:,options:,resultingItem:) throws` is the preferred safe-save API). The document identifier is persistent across system restarts. The document identifier is not transferred when the file is copied. Document identifiers are only unique within a single volume. This property is not supported by all volumes.
+    /// The document identifier survives "safe save" operations; i.e it is sticky to the path it was assigned to (`replaceItem(at:,withItemAt:,backupItemName:,options:,resultingItem:) throws` is the preferred safe-save API). The document identifier is persistent across system restarts. The document identifier is not transferred when the file is copied. Document identifiers are only unique within a single volume. This property is not supported by all volumes.
     @available(OSX 10.10, iOS 8.0, *)
     public var documentIdentifier: Int? { return _get(.documentIdentifierKey) }
     
@@ -561,7 +561,7 @@
         bookmarkDataIsStale = stale.boolValue
     }
     
-    /// Creates and initializes a NSURL that refers to the location specified by resolving the alias file at url. If the url argument does not refer to an alias file as defined by the NSURLIsAliasFileKey property, the NSURL returned is the same as url argument. This method fails and returns nil if the url argument is unreachable, or if the original file or directory could not be located or is not reachable, or if the original file or directory is on a volume that could not be located or mounted. The URLBookmarkResolutionWithSecurityScope option is not supported by this method.
+    /// Creates and initializes an NSURL that refers to the location specified by resolving the alias file at url. If the url argument does not refer to an alias file as defined by the NSURLIsAliasFileKey property, the NSURL returned is the same as url argument. This method fails and returns nil if the url argument is unreachable, or if the original file or directory could not be located or is not reachable, or if the original file or directory is on a volume that could not be located or mounted. The URLBookmarkResolutionWithSecurityScope option is not supported by this method.
     @available(OSX 10.10, iOS 8.0, *)
     public init(resolvingAliasFileAt url: URL, options: BookmarkResolutionOptions = []) throws {
         self.init(reference: try NSURL(resolvingAliasFileAt: url, options: options))
@@ -1085,7 +1085,7 @@
         return result as Data
     }
     
-    /// Given a NSURL created by resolving a bookmark data created with security scope, make the resource referenced by the url accessible to the process. When access to this resource is no longer needed the client must call stopAccessingSecurityScopedResource. Each call to startAccessingSecurityScopedResource must be balanced with a call to stopAccessingSecurityScopedResource (Note: this is not reference counted).
+    /// Given an NSURL created by resolving a bookmark data created with security scope, make the resource referenced by the url accessible to the process. When access to this resource is no longer needed the client must call stopAccessingSecurityScopedResource. Each call to startAccessingSecurityScopedResource must be balanced with a call to stopAccessingSecurityScopedResource (Note: this is not reference counted).
     @available(OSX 10.7, iOS 8.0, *)
     public func startAccessingSecurityScopedResource() -> Bool {
         return _url.startAccessingSecurityScopedResource()
diff --git a/stdlib/public/core/ExistentialCollection.swift.gyb b/stdlib/public/core/ExistentialCollection.swift.gyb
index 32441c1..0d90284 100644
--- a/stdlib/public/core/ExistentialCollection.swift.gyb
+++ b/stdlib/public/core/ExistentialCollection.swift.gyb
@@ -720,30 +720,11 @@
 //===--- Collections ------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
-/// A protocol for `AnyCollection<Element>`,
-/// `AnyBidirectionalCollection<Element>`, and
-/// `AnyRandomAccessCollection<Element>`.
-///
-/// This protocol can be considered an implementation detail of the
-/// `===` and `!==` implementations for these types.
-public protocol AnyCollectionProtocol : Collection {
+public // @testable
+protocol _AnyCollectionProtocol : Collection {
   /// Identifies the underlying collection stored by `self`. Instances
-  /// copied from one another have the same `_underlyingCollectionID`.
-  var _underlyingCollectionID: ObjectIdentifier { get }
-}
-
-/// Returns `true` iff `lhs` and `rhs` store the same underlying collection.
-public func === <
-  L : AnyCollectionProtocol, R : AnyCollectionProtocol
->(lhs: L, rhs: R) -> Bool {
-  return lhs._underlyingCollectionID == rhs._underlyingCollectionID
-}
-
-/// Returns `false` iff `lhs` and `rhs` store the same underlying collection.
-public func !== <
-  L : AnyCollectionProtocol, R : AnyCollectionProtocol
->(lhs: L, rhs: R) -> Bool {
-  return lhs._underlyingCollectionID != rhs._underlyingCollectionID
+  /// copied or upgraded/downgraded from one another have the same `_boxID`.
+  var _boxID: ObjectIdentifier { get }
 }
 
 % for (ti, Traversal) in enumerate(TRAVERSALS):
@@ -758,7 +739,7 @@
 ///
 /// - SeeAlso: ${', '.join('`Any%sCollection`' % t for t in (2 * TRAVERSALS)[ti + 1 : ti + 3]) }
 public struct ${Self}<Element>
-  : AnyCollectionProtocol, ${SelfProtocol} {
+  : _AnyCollectionProtocol, ${SelfProtocol} {
 
   internal init(_box: _${Self}Box<Element>) {
     self._box = _box
@@ -955,7 +936,7 @@
 
   /// Uniquely identifies the stored underlying collection.
   public // Due to language limitations only
-  var _underlyingCollectionID: ObjectIdentifier {
+  var _boxID: ObjectIdentifier {
     return ObjectIdentifier(_box)
   }
 
@@ -983,10 +964,13 @@
 }
 %end
 
-@available(*, unavailable, renamed: "AnyCollectionProtocol")
-public typealias AnyCollectionType = AnyCollectionProtocol
+@available(*, unavailable, renamed: "_AnyCollectionProtocol")
+public typealias AnyCollectionType = _AnyCollectionProtocol
 
-extension AnyCollectionProtocol {
+@available(*, unavailable, renamed: "_AnyCollectionProtocol")
+public typealias AnyCollectionProtocol = _AnyCollectionProtocol
+
+extension _AnyCollectionProtocol {
   @available(*, unavailable, renamed: "makeIterator()")
   public func generate() -> AnyIterator<Iterator.Element> {
     Builtin.unreachable()
@@ -1008,3 +992,17 @@
 public func anyGenerator<Element>(_ body: () -> Element?) -> AnyIterator<Element> {
   Builtin.unreachable()
 }
+
+@available(*, unavailable)
+public func === <
+  L : _AnyCollectionProtocol, R : _AnyCollectionProtocol
+>(lhs: L, rhs: R) -> Bool {
+  Builtin.unreachable()
+}
+
+@available(*, unavailable)
+public func !== <
+  L : _AnyCollectionProtocol, R : _AnyCollectionProtocol
+>(lhs: L, rhs: R) -> Bool {
+  Builtin.unreachable()
+}
diff --git a/stdlib/public/core/Optional.swift b/stdlib/public/core/Optional.swift
index 4fd9409..0d94cd1 100644
--- a/stdlib/public/core/Optional.swift
+++ b/stdlib/public/core/Optional.swift
@@ -380,44 +380,6 @@
   }
 }
 
-public func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
-  switch (lhs, rhs) {
-  case let (l?, r?):
-    return l < r
-  case (nil, _?):
-    return true
-  default:
-    return false
-  }
-}
-
-public func > <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
-  switch (lhs, rhs) {
-  case let (l?, r?):
-    return l > r
-  default:
-    return rhs < lhs
-  }
-}
-
-public func <= <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
-  switch (lhs, rhs) {
-  case let (l?, r?):
-    return l <= r
-  default:
-    return !(rhs < lhs)
-  }
-}
-
-public func >= <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
-  switch (lhs, rhs) {
-  case let (l?, r?):
-    return l >= r
-  default:
-    return !(lhs < rhs)
-  }
-}
-
 /// Performs a nil-coalescing operation, returning the wrapped value of an
 /// `Optional` instance or a default value.
 ///
diff --git a/stdlib/public/core/OutputStream.swift b/stdlib/public/core/OutputStream.swift
index 8bd4894..a820103 100644
--- a/stdlib/public/core/OutputStream.swift
+++ b/stdlib/public/core/OutputStream.swift
@@ -73,9 +73,6 @@
   mutating func write(_ string: String)
 }
 
-/// Temporary typealias
-public typealias OutputStream = TextOutputStream
-
 extension TextOutputStream {
   public mutating func _lock() {}
   public mutating func _unlock() {}
diff --git a/stdlib/public/core/Policy.swift b/stdlib/public/core/Policy.swift
index d266f3c..eccd9c8 100644
--- a/stdlib/public/core/Policy.swift
+++ b/stdlib/public/core/Policy.swift
@@ -18,7 +18,7 @@
 /// The return type of functions that do not return normally; a type with no
 /// values.
 ///
-/// Use `Never` as the return type when declarting a closure, function, or
+/// Use `Never` as the return type when declaring a closure, function, or
 /// method that unconditionally throws an error, traps, or otherwise does
 /// not terminate.
 ///
diff --git a/stdlib/public/core/UnsafeRawPointer.swift.gyb b/stdlib/public/core/UnsafeRawPointer.swift.gyb
index edd8951..5e186b9 100644
--- a/stdlib/public/core/UnsafeRawPointer.swift.gyb
+++ b/stdlib/public/core/UnsafeRawPointer.swift.gyb
@@ -383,7 +383,7 @@
   /// - Note: Storing a copy of a nontrivial value into memory
   ///   requires that the user know the type of value previously in
   ///   memory, and requires initialization or assignment of the
-  ///   memory. This can be acheived via a typed `UnsafeMutablePointer`
+  ///   memory. This can be achieved via a typed `UnsafeMutablePointer`
   ///   or via a raw pointer `self`, as follows, where `U` is the
   ///   previous type and `T` is the copied value's type:
   ///   `let typedPtr = self.bindMemory(to: U.self, capacity: 1)`
diff --git a/stdlib/public/stubs/Stubs.cpp b/stdlib/public/stubs/Stubs.cpp
index 3aa8888..7a803a3 100644
--- a/stdlib/public/stubs/Stubs.cpp
+++ b/stdlib/public/stubs/Stubs.cpp
@@ -387,7 +387,7 @@
 // FIXME: ideally we would have a slow path here for Windows which would be
 // lowered to instructions as though MSVC had generated.  There does not seem to
 // be a MSVC provided multiply with overflow detection that I can see, but this
-// avoids an unncessary dependency on compiler-rt for a single function.
+// avoids an unnecessary dependency on compiler-rt for a single function.
 #if (defined(__linux__) && defined(__arm__)) || defined(_MSC_VER)
 // Similar to above, but with mulodi4.  Perhaps this is
 // something that shouldn't be done, and is a bandaid over
diff --git a/test/1_stdlib/CollectionCasts.swift.gyb b/test/1_stdlib/CollectionCasts.swift.gyb
index da29961..f893ce3 100644
--- a/test/1_stdlib/CollectionCasts.swift.gyb
+++ b/test/1_stdlib/CollectionCasts.swift.gyb
@@ -108,7 +108,6 @@
 
 %       for vi0, Value0 in enumerate(values):
 %         DynamicValue = values[0] if Value0.startswith('Any') else Value0
-%         def makeValue(i): return '%s(%s) as %s' % (DynamicValue, i, Value0)
 %         for Value1 in values[vi0:]:
 
 %           for method in 'Direct', 'Indirect':
diff --git a/test/1_stdlib/Optional.swift b/test/1_stdlib/Optional.swift
index 79e8035..470d7cb 100644
--- a/test/1_stdlib/Optional.swift
+++ b/test/1_stdlib/Optional.swift
@@ -73,7 +73,6 @@
 OptionalTests.test("Equatable") {
   expectEqual([true, false, false, false, false, true], testRelation(==))
   expectEqual([false, true, true, true, true, false], testRelation(!=))
-  expectEqual([false, true, false, false, true, false], testRelation(<))
 }
 
 OptionalTests.test("CustomReflectable") {
diff --git a/test/1_stdlib/Renames.swift b/test/1_stdlib/Renames.swift
index 63eed29..dabc390 100644
--- a/test/1_stdlib/Renames.swift
+++ b/test/1_stdlib/Renames.swift
@@ -110,7 +110,7 @@
 
 func _ExistentialCollection<T>(i: AnyIterator<T>) {
   func fn1<T>(_: AnyGenerator<T>) {} // expected-error {{'AnyGenerator' has been renamed to 'AnyIterator'}} {{18-30=AnyIterator}} {{none}}
-  func fn2<T : AnyCollectionType>(_: T) {} // expected-error {{'AnyCollectionType' has been renamed to 'AnyCollectionProtocol'}} {{16-33=AnyCollectionProtocol}} {{none}}
+  func fn2<T : AnyCollectionType>(_: T) {} // expected-error {{'AnyCollectionType' has been renamed to '_AnyCollectionProtocol'}} {{16-33=_AnyCollectionProtocol}} {{none}}
   func fn3(_: AnyForwardIndex) {} // expected-error {{'AnyForwardIndex' has been renamed to 'AnyIndex'}} {{15-30=AnyIndex}} {{none}}
   func fn4(_: AnyBidirectionalIndex) {} // expected-error {{'AnyBidirectionalIndex' has been renamed to 'AnyIndex'}} {{15-36=AnyIndex}} {{none}}
   func fn5(_: AnyRandomAccessIndex) {} // expected-error {{'AnyRandomAccessIndex' has been renamed to 'AnyIndex'}} {{15-35=AnyIndex}} {{none}}
@@ -130,7 +130,7 @@
 func _ExistentialCollection<T>(c: AnyRandomAccessCollection<T>) {
   _ = c.underestimateCount() // expected-error {{'underestimateCount()' is unavailable: Please use underestimatedCount property instead.}} {{none}}
 }
-func _ExistentialCollection<C : AnyCollectionProtocol>(c: C) {
+func _ExistentialCollection<C : _AnyCollectionProtocol>(c: C) {
   _ = c.generate() // expected-error {{'generate()' has been renamed to 'makeIterator()'}} {{9-17=makeIterator}} {{none}}
 }
 
diff --git a/test/1_stdlib/TestCalendar.swift b/test/1_stdlib/TestCalendar.swift
index d4652bc..b9d8e96 100644
--- a/test/1_stdlib/TestCalendar.swift
+++ b/test/1_stdlib/TestCalendar.swift
@@ -219,7 +219,7 @@
             // Find the days numbered '31' after 'd', allowing the algorithm to move to the next day if required
             c.enumerateDates(startingAfter: d, matching: DateComponents(day: 31), matchingPolicy: .nextTime) { result, exact, stop in
                 // Just stop some arbitrary time in the future
-                if result > d + 86400*365 { stop = true }
+                if result! > d + 86400*365 { stop = true }
                 count += 1
                 if exact { exactCount += 1 }
             }
diff --git a/test/Constraints/diagnostics.swift b/test/Constraints/diagnostics.swift
index 7091315..61952c9 100644
--- a/test/Constraints/diagnostics.swift
+++ b/test/Constraints/diagnostics.swift
@@ -757,7 +757,7 @@
 
 func overloadSetResultType(_ a : Int, b : Int) -> Int {
   // https://twitter.com/_jlfischer/status/712337382175952896
-  // TODO: <rdar://problem/27391581> QoI: Nonsensitical "binary operator '&&' cannot be applied to two 'Bool' operands"
+  // TODO: <rdar://problem/27391581> QoI: Nonsensical "binary operator '&&' cannot be applied to two 'Bool' operands"
   return a == b && 1 == 2  // expected-error {{binary operator '&&' cannot be applied to two 'Bool' operands}}
   // expected-note @-1 {{expected an argument list of type '(Bool, @autoclosure () throws -> Bool)'}}
 }
@@ -787,15 +787,14 @@
   _ = i != nil // expected-warning {{comparing non-optional value of type 'Int' to nil always returns true}}
   _ = nil != i // expected-warning {{comparing non-optional value of type 'Int' to nil always returns true}}
   
-  // These should all be illegal when SE-0121 lands.
-  _ = i < nil
-  _ = nil < i
-  _ = i <= nil
-  _ = nil <= i
-  _ = i > nil
-  _ = nil > i
-  _ = i >= nil
-  _ = nil >= i
+  _ = i < nil  // expected-error {{type 'Int' is not optional, value can never be nil}}
+  _ = nil < i  // expected-error {{type 'Int' is not optional, value can never be nil}}
+  _ = i <= nil // expected-error {{type 'Int' is not optional, value can never be nil}}
+  _ = nil <= i // expected-error {{type 'Int' is not optional, value can never be nil}}
+  _ = i > nil  // expected-error {{type 'Int' is not optional, value can never be nil}}
+  _ = nil > i  // expected-error {{type 'Int' is not optional, value can never be nil}}
+  _ = i >= nil // expected-error {{type 'Int' is not optional, value can never be nil}}
+  _ = nil >= i // expected-error {{type 'Int' is not optional, value can never be nil}}
 
   _ = o === nil // expected-warning {{comparing non-optional value of type 'AnyObject' to nil always returns false}}
   _ = o !== nil // expected-warning {{comparing non-optional value of type 'AnyObject' to nil always returns true}}
@@ -821,7 +820,7 @@
 
 extension Foo23752537 {
   func isEquivalent(other: Foo23752537) {
-    // TODO: <rdar://problem/27391581> QoI: Nonsensitical "binary operator '&&' cannot be applied to two 'Bool' operands"
+    // TODO: <rdar://problem/27391581> QoI: Nonsensical "binary operator '&&' cannot be applied to two 'Bool' operands"
     // expected-error @+1 {{binary operator '&&' cannot be applied to two 'Bool' operands}}
     return (self.title != other.title && self.message != other.message)
     // expected-note @-1 {{expected an argument list of type '(Bool, @autoclosure () throws -> Bool)'}}
diff --git a/test/Parse/enum.swift b/test/Parse/enum.swift
index d983d55..bd69a76 100644
--- a/test/Parse/enum.swift
+++ b/test/Parse/enum.swift
@@ -459,40 +459,40 @@
     _ = SE0036.A
   }
 
-  func staticReferencInInstanceMethod() {
+  func staticReferenceInInstanceMethod() {
     _ = A // expected-error {{enum element 'A' cannot be referenced as an instance member}} {{9-9=SE0036.}}
     _ = SE0036.A
   }
 
-  static func staticReferencInSwitchInStaticMethod() {
+  static func staticReferenceInSwitchInStaticMethod() {
     switch SE0036.A {
     case A: break
     case B(_): break
     }
   }
 
-  func staticReferencInSwitchInInstanceMethod() {
+  func staticReferenceInSwitchInInstanceMethod() {
     switch self {
     case A: break // expected-error {{enum element 'A' cannot be referenced as an instance member}} {{10-10=.}}
     case B(_): break // expected-error {{enum element 'B' cannot be referenced as an instance member}} {{10-10=.}}
     }
   }
 
-  func explicitReferencInSwitch() {
+  func explicitReferenceInSwitch() {
     switch SE0036.A {
     case SE0036.A: break
     case SE0036.B(_): break
     }
   }
 
-  func dotReferencInSwitchInInstanceMethod() {
+  func dotReferenceInSwitchInInstanceMethod() {
     switch self {
     case .A: break
     case .B(_): break
     }
   }
 
-  static func dotReferencInSwitchInStaticMethod() {
+  static func dotReferenceInSwitchInStaticMethod() {
     switch SE0036.A {
     case .A: break
     case .B(_): break
diff --git a/test/Parse/try.swift b/test/Parse/try.swift
index 0bc1e45..1f3445c 100644
--- a/test/Parse/try.swift
+++ b/test/Parse/try.swift
@@ -42,10 +42,10 @@
 i ?+= try? foo() + bar()
 i ?+= try? foo() %%%% bar() // expected-error {{'try?' following assignment operator does not cover everything to its right}} // expected-error {{call can throw but is not marked with 'try'}} // expected-warning {{result of operator '%%%%' is unused}}
 i ?+= try? foo() %%% bar()
-_ = foo() < try? bar() // expected-error {{'try?' cannot appear to the right of a non-assignment operator}} // expected-error {{call can throw but is not marked with 'try'}}
-_ = (try? foo()) < bar() // expected-error {{call can throw but is not marked with 'try'}}
-_ = foo() < (try? bar()) // expected-error {{call can throw but is not marked with 'try'}}
-_ = (try? foo()) < (try? bar())
+_ = foo() == try? bar() // expected-error {{'try?' cannot appear to the right of a non-assignment operator}} // expected-error {{call can throw but is not marked with 'try'}}
+_ = (try? foo()) == bar() // expected-error {{call can throw but is not marked with 'try'}}
+_ = foo() == (try? bar()) // expected-error {{call can throw but is not marked with 'try'}}
+_ = (try? foo()) == (try? bar())
 
 let j = true ? try? foo() : try? bar() + 0
 let k = true ? try? foo() : try? bar() %%% 0 // expected-error {{'try?' following conditional operator does not cover everything to its right}}
diff --git a/test/SILOptimizer/swap_refcnt.swift b/test/SILOptimizer/swap_refcnt.swift
index 8c29be7..69c0dcf 100644
--- a/test/SILOptimizer/swap_refcnt.swift
+++ b/test/SILOptimizer/swap_refcnt.swift
@@ -1,5 +1,5 @@
 // RUN: %target-swift-frontend -O -emit-sil %s | FileCheck %s
-// REQUIRES: rdar:27506150> SILOptimizer/swap_refcnt.swift failes after noreturn -> Never changes
+// REQUIRES: rdar:27506150> SILOptimizer/swap_refcnt.swift fails after noreturn -> Never changes
 
 // Make sure we can swap two values in an array without retaining anything.
 
diff --git a/test/attr/attr_noreturn.swift b/test/attr/attr_noreturn.swift
index 3967bce..ee66606 100644
--- a/test/attr/attr_noreturn.swift
+++ b/test/attr/attr_noreturn.swift
@@ -1,136 +1,51 @@
 // RUN: %target-parse-verify-swift
 
-@noreturn
-func exit(_: Int) {}
+@noreturn func noReturn1(_: Int) {}
+// expected-error@-1 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-11=}}{{33-33= -> Never }}
 
-@noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{1-11=}}
-class InvalidOnClass {}
-
-@noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{1-11=}}
-struct InvalidOnStruct {}
-
-@noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{1-11=}}
-enum InvalidOnEnum {}
-
-@noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{1-11=}}
-protocol InvalidOnProtocol {}
-
-struct InvalidOnExtension {}
-
-@noreturn // expected-error {{@noreturn may only be used on 'func' declarations}} {{1-11=}}
-extension InvalidOnExtension {}
-
-@noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{1-11=}}
-var invalidOnVar = 0
-
-@noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{1-11=}}
-let invalidOnLet = 0
-
-class InvalidOnClassMembers {
-  @noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{3-13=}}
-  init() {}
-
-  @noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{3-13=}}
-  deinit {}
-
-  @noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{3-13=}}
-  subscript(i: Int) -> Int {
-    get {
-      return 0
-    }
-  }
-}
-
-protocol TestProtocol {
-  // expected-note@+1 {{protocol requires function 'neverReturns()' with type '@noreturn () -> ()'}}
-  @noreturn func neverReturns()
-  func doesReturn()
-
-  // expected-note@+1 {{protocol requires function 'neverReturnsStatic()' with type '@noreturn () -> ()'}}
-  @noreturn static func neverReturnsStatic()
-  static func doesReturnStatic()
-}
-// expected-error@+1 {{type 'ConformsToProtocolA' does not conform to protocol 'TestProtocol'}}
-struct ConformsToProtocolA : TestProtocol {
-  // expected-note@+1 {{candidate is not @noreturn, but protocol requires it}}
-  func neverReturns() {}
-
-  // OK: a @noreturn function conforms to a non-@noreturn protocol requirement.
-  @noreturn func doesReturn() { exit(0) }
-
-  // expected-note@+1 {{candidate is not @noreturn, but protocol requires it}}
-  static func neverReturnsStatic() {}
-
-  // OK: a @noreturn function conforms to a non-@noreturn protocol requirement.
-  @noreturn static func doesReturnStatic() {}
-}
-
-class BaseClass {
-  @noreturn func neverReturns() { exit(0) } // expected-note 3{{overridden declaration is here}}
-  func doesReturn() {} // expected-note {{overridden declaration is here}}
-
-  @noreturn class func neverReturnsClass() { exit(0) } // expected-note 3{{overridden declaration is here}}
-  class func doesReturn() {} // expected-note {{overridden declaration is here}}
-}
-class DerivedClassA : BaseClass {
-  // expected-error@+2 {{overriding declaration requires an 'override' keyword}} {{3-3=override }}
-  // expected-error@+1 {{an override of a @noreturn method should also be @noreturn}}
-  func neverReturns() {}
-
-  // expected-error@+1 {{overriding declaration requires an 'override' keyword}} {{13-13=override }}
-  @noreturn func doesReturn() { exit(0) }
-
-  // expected-error@+2 {{overriding declaration requires an 'override' keyword}} {{3-3=override }}
-  // expected-error@+1 {{an override of a @noreturn method should also be @noreturn}}
-  class func neverReturnsClass() { exit(0) }
-
-  // expected-error@+1 {{overriding declaration requires an 'override' keyword}} {{13-13=override }}
-  @noreturn class func doesReturn() {}
-}
-class DerivedClassB : BaseClass {
-  // expected-error@+1 {{an override of a @noreturn method should also be @noreturn}}
-  override func neverReturns() {}
-
-  // OK: a @noreturn method overrides a non-@noreturn base method.
-  @noreturn override func doesReturn() { exit(0) }
-
-  // expected-error@+1 {{an override of a @noreturn method should also be @noreturn}}
-  override class func neverReturnsClass() { exit(0) }
-
-  // OK: a @noreturn method overrides a non-@noreturn base method.
-  @noreturn override class func doesReturn() {}
-}
-
-struct MethodWithNoreturn {
-  @noreturn
-  func neverReturns() { exit(0) }
-}
-
-func printInt(_: Int) {}
-var maybeReturns: (Int) -> () = exit // no-error
-var neverReturns1 = exit
-neverReturns1 = printInt // expected-error {{cannot assign value of type '(Int) -> ()' to type '@noreturn (Int) -> ()'}}
-
-var neverReturns2: (MethodWithNoreturn) -> @noreturn () -> () = MethodWithNoreturn.neverReturns
-
-exit(5) // no-error
+@noreturn func noReturn2(_: Int)
+{}
+// expected-error@-2 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-11=}}{{33-33= -> Never}}
 
 @noreturn
-func exit() -> () {}
-@noreturn
-func testFunctionOverload() -> () {
-  exit()
-}
+func noReturn3(_: Int)
+{}
+// expected-error@-3 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-10=}}{{23-23= -> Never}}
 
-func testRvalue(_ lhs: (), rhs: @noreturn () -> ()) -> () {
-  return rhs()
-}
+@noreturn func noReturnInt1(_: Int) -> Int {}
+// expected-error@-1 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-11=}}{{40-43=Never}}
 
-var fnr: @noreturn (_: Int) -> () = exit
-// This might be a desirable syntax, but it does not get properly propagated to SIL, so reject it for now.
-@noreturn // expected-error {{@noreturn may only be used on 'func' declarations}}{{1-11=}}
-var fpr: (_: Int) -> () = exit
+@noreturn func noReturnInt2(_: Int) -> Int
+{}
+// expected-error@-2 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-11=}}{{40-43=Never}}
 
-func testWitnessMethod<T: TestProtocol>(_ t: T) {
-  _ = T.neverReturnsStatic
-}
+@noreturn func noReturnThrows1(_: Int) throws {}
+// expected-error@-1 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-11=}}{{46-46= -> Never }}
+
+@noreturn func noReturnThrows2(_: Int) throws
+{}
+// expected-error@-2 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-11=}}{{46-46= -> Never}}
+
+@noreturn func noReturnThrowsInt1(_: Int) throws -> Int {}
+// expected-error@-1 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-11=}}{{53-56=Never}}
+
+@noreturn func noReturnThrowsInt2(_: Int) throws -> Int
+{}
+// expected-error@-2 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{1-11=}}{{53-56=Never}}
+
+// Test that error recovery gives us the 'Never' return type
+let x: Never = noReturn1(0) // No error
+
+// @noreturn in function type declarations
+let valueNoReturn: @noreturn () -> ()
+// expected-error@-1 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{20-30=}}{{36-38=Never}}
+
+let valueNoReturnInt: @noreturn () -> Int
+// expected-error@-1 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{23-33=}}{{39-42=Never}}
+
+let valueNoReturnInt2: @noreturn
+() -> Int
+// expected-error@-2 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{24-1=}}{{7-10=Never}}
+
+let valueNoReturn2: @noreturn () -> () = {}
+// expected-error@-1 {{'@noreturn' has been removed; functions that never return should have a return type of 'Never' instead}}{{21-31=}}{{37-39=Never}}
diff --git a/test/decl/typealias/generic.swift b/test/decl/typealias/generic.swift
index 52275be..19608b6 100644
--- a/test/decl/typealias/generic.swift
+++ b/test/decl/typealias/generic.swift
@@ -164,6 +164,12 @@
   }
 }
 
+let gc = GenericClass<Double>()
+let fn: MyType<Double, Int> = gc.testCapture(s: 1, t: 1.0)
+
+func use<T>(_ t: T) {}
+use(fn)
+
 // Make sure we apply base substitutions to the interface type of the typealias
 class ConcreteClass : GenericClass<String> {
   func testSubstitutedCapture1<S>(s: S, t: String) -> TA<S> {
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp b/tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp
index 04fe46e..97b0064 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp
+++ b/tools/SourceKit/lib/SwiftLang/SwiftEditorInterfaceGen.cpp
@@ -79,7 +79,7 @@
   SourceTextInfo Info;
   // This is the non-typechecked AST for the generated interface source.
   CompilerInstance TextCI;
-  // Syncronize access to the embedded compiler instance (if we don't have an
+  // Synchronize access to the embedded compiler instance (if we don't have an
   // ASTUnit).
   WorkQueue Queue{WorkQueue::Dequeuing::Serial,
                   "sourcekit.swift.InterfaceGenContext"};
diff --git a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp
index 9e86fe9d..fe03793 100644
--- a/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp
+++ b/tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp
@@ -670,7 +670,7 @@
     llvm::raw_svector_ostream OS(SS);
     SwiftLangSupport::printTypeUSR(ContainerTy, OS);
   }
-  unsigned MangedContainerTypeEnd = SS.size();
+  unsigned MangledContainerTypeEnd = SS.size();
 
   unsigned DocCommentBegin = SS.size();
   {
@@ -791,7 +791,7 @@
                                 MangledTypeEnd - MangledTypeStart);
 
   StringRef ContainerTypeUsr = StringRef(SS.begin()+MangledContainerTypeStart,
-                            MangedContainerTypeEnd - MangledContainerTypeStart);
+                            MangledContainerTypeEnd - MangledContainerTypeStart);
   StringRef DocComment = StringRef(SS.begin()+DocCommentBegin,
                                    DocCommentEnd-DocCommentBegin);
   StringRef AnnotatedDecl = StringRef(SS.begin()+DeclBegin,
diff --git a/validation-test/stdlib/ExistentialCollection.swift.gyb b/validation-test/stdlib/ExistentialCollection.swift.gyb
index e267630..fb0c5d6 100644
--- a/validation-test/stdlib/ExistentialCollection.swift.gyb
+++ b/validation-test/stdlib/ExistentialCollection.swift.gyb
@@ -57,6 +57,12 @@
   }
 }
 
+func storesSameUnderlyingCollection<
+  L: _AnyCollectionProtocol, R: _AnyCollectionProtocol
+>(_ lhs: L, _ rhs: R) -> Bool {
+  return lhs._boxID == rhs._boxID
+}
+
 var tests = TestSuite("ExistentialCollection")
 
 tests.test("AnyIterator") {
@@ -357,13 +363,13 @@
   let bc0_ = AnyBidirectionalCollection(fc0)  // upgrade!
   expectNotEmpty(bc0_)
   let bc0 = bc0_!
-  expectTrue(fc0 === bc0)
+  expectTrue(storesSameUnderlyingCollection(fc0, bc0))
 
   let fc1 = AnyCollection(a0.lazy.reversed()) // new collection
-  expectFalse(fc1 === fc0)
+  expectFalse(storesSameUnderlyingCollection(fc1, fc0))
 
   let fc2 = AnyCollection(bc0)                // downgrade
-  expectTrue(fc2 === bc0)
+  expectTrue(storesSameUnderlyingCollection(fc2, bc0))
   
   let a1 = ContiguousArray(bc0.lazy.reversed())
   expectEqual(a0, a1)
@@ -381,7 +387,7 @@
   let s0 = "Hello, Woyld".characters
   let bc1 = AnyBidirectionalCollection(s0)
   let fc3 = AnyCollection(bc1)
-  expectTrue(fc3 === bc1)
+  expectTrue(storesSameUnderlyingCollection(fc3, bc1))
   expectEmpty(AnyRandomAccessCollection(bc1))
   expectEmpty(AnyRandomAccessCollection(fc3))
 }
@@ -392,13 +398,13 @@
   let rc0_ = AnyRandomAccessCollection(fc0)         // upgrade!
   expectNotEmpty(rc0_)
   let rc0 = rc0_!
-  expectTrue(rc0 === fc0)
+  expectTrue(storesSameUnderlyingCollection(rc0, fc0))
 
   let bc1 = AnyBidirectionalCollection(rc0)         // downgrade
-  expectTrue(bc1 === rc0)
+  expectTrue(storesSameUnderlyingCollection(bc1, rc0))
 
   let fc1 = AnyBidirectionalCollection(rc0)         // downgrade
-  expectTrue(fc1 === rc0)
+  expectTrue(storesSameUnderlyingCollection(fc1, rc0))
   
   let a1 = ContiguousArray(rc0.lazy.reversed())
   expectEqual(a0, a1)