Merge pull request #18564 from rintaro/ide-completion-contextanalysis

[CodeCompletion] Improve context type analysis
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d11afef..c929b26 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,11 @@
 Swift 5.0
 ---------
 
+* [SR-2608][]
+
+  Default arguments are now printed in SourceKit-generated interfaces for Swift
+  modules, instead of just using a placeholder `default`.
+
 * Notable bug fix: unowned and unowned(unsafe) variables now support optional
   types.
 
@@ -7151,3 +7156,4 @@
 [SR-2131]: <https://bugs.swift.org/browse/SR-2131>
 [SR-2388]: <https://bugs.swift.org/browse/SR-2388>
 [SR-2394]: <https://bugs.swift.org/browse/SR-2394>
+[SR-2608]: <https://bugs.swift.org/browse/SR-2608>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5064656..bae0bb5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -937,7 +937,11 @@
 if(SWIFT_INCLUDE_TOOLS)
   add_subdirectory(include)
   add_subdirectory(lib)
-  
+endif()
+
+include(SwiftExternal)
+
+if(SWIFT_INCLUDE_TOOLS)
   # Always include this after including stdlib/!
   # Refer to the large comment above the add_subdirectory(stdlib) call.
   # https://bugs.swift.org/browse/SR-5975
diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake
index 170c48e..f21a41d 100644
--- a/cmake/modules/AddSwift.cmake
+++ b/cmake/modules/AddSwift.cmake
@@ -2209,6 +2209,21 @@
           ${SWIFTEXE_TARGET_EXCLUDE_FROM_ALL_FLAG_CURRENT}
           ${SWIFTEXE_TARGET_DONT_STRIP_NON_MAIN_SYMBOLS_FLAG}
           ${SWIFTEXE_DISABLE_ASLR_FLAG})
+
+      is_darwin_based_sdk("${sdk}" IS_DARWIN)
+      if(IS_DARWIN)
+        add_custom_command_target(unused_var2
+         COMMAND "codesign" "-f" "-s" "-" "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}"
+         CUSTOM_TARGET_NAME "${VARIANT_NAME}_signed"
+         OUTPUT "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}_signed"
+         DEPENDS ${VARIANT_NAME})
+      else()
+        # No code signing on other platforms.
+        add_custom_command_target(unused_var2
+         CUSTOM_TARGET_NAME "${VARIANT_NAME}_signed"
+         OUTPUT "${SWIFT_RUNTIME_OUTPUT_INTDIR}/${VARIANT_NAME}_signed"
+         DEPENDS ${VARIANT_NAME})
+       endif()
     endforeach()
   endforeach()
 endfunction()
@@ -2299,13 +2314,28 @@
 endmacro()
 
 function(add_swift_host_tool executable)
+  set(ADDSWIFTHOSTTOOL_multiple_parameter_options
+        SWIFT_COMPONENT
+        COMPILE_FLAGS
+        DEPENDS
+        SWIFT_MODULE_DEPENDS)
+
   cmake_parse_arguments(
       ADDSWIFTHOSTTOOL # prefix
       "" # options
       "" # single-value args
-      "SWIFT_COMPONENT;COMPILE_FLAGS;DEPENDS" # multi-value args
+      "${ADDSWIFTHOSTTOOL_multiple_parameter_options}" # multi-value args
       ${ARGN})
 
+  # Configure variables for this subdirectory.
+  set(VARIANT_SUFFIX "-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}")
+  set(MODULE_VARIANT_SUFFIX "-swiftmodule${VARIANT_SUFFIX}")
+
+  foreach(mod ${ADDSWIFTHOSTTOOL_SWIFT_MODULE_DEPENDS})
+    list(APPEND ADDSWIFTHOSTTOOL_DEPENDS "swift${mod}${MODULE_VARIANT_SUFFIX}")
+    list(APPEND ADDSWIFTHOSTTOOL_DEPENDS "swift${mod}${VARIANT_SUFFIX}")
+  endforeach()
+
   # Create the executable rule.
   add_swift_executable(
     ${executable} 
diff --git a/cmake/modules/SwiftExternal.cmake b/cmake/modules/SwiftExternal.cmake
new file mode 100644
index 0000000..f3dd9b1
--- /dev/null
+++ b/cmake/modules/SwiftExternal.cmake
@@ -0,0 +1,65 @@
+
+if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+  include(ExternalProject)
+
+  if(SWIFT_BUILD_SOURCEKIT)
+    ExternalProject_Add(libdispatch
+                        SOURCE_DIR
+                          "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}"
+                        BINARY_DIR
+                          "${SWIFT_PATH_TO_LIBDISPATCH_BUILD}"
+                        CMAKE_ARGS
+                          -DCMAKE_C_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang
+                          -DCMAKE_CXX_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang++
+                          -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
+                          -DCMAKE_SWIFT_COMPILER=$<TARGET_FILE:swift>c
+                          -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+                          -DENABLE_SWIFT=YES
+                        BUILD_BYPRODUCTS
+                          ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/${CMAKE_SHARED_LIBRARY_PREFIX}dispatch${CMAKE_SHARED_LIBRARY_SUFFIX}
+                          ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/${CMAKE_STATIC_LIBRARY_PREFIX}BlocksRuntime${CMAKE_STATIC_LIBRARY_SUFFIX}
+                        STEP_TARGETS
+                          configure
+                        BUILD_ALWAYS
+                          1)
+
+    # CMake does not like the addition of INTERFACE_INCLUDE_DIRECTORIES without
+    # the directory existing.  Just create the location which will be populated
+    # during the installation.
+    ExternalProject_Get_Property(libdispatch install_dir)
+    file(MAKE_DIRECTORY ${install_dir}/include)
+
+    # TODO(compnerd) this should be taken care of by the
+    # INTERFACE_INCLUDE_DIRECTORIES below
+    include_directories(AFTER
+                          ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/src/BlocksRuntime
+                          ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
+    add_dependencies(libdispatch
+                       swift
+                       copy_shim_headers
+                       swiftCore-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}
+                       swiftSwiftOnoneSupport-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}
+                       swiftCore-swiftmodule-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}
+                       swiftSwiftOnoneSupport-swiftmodule-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH})
+  endif()
+
+  ExternalProject_Get_Property(libdispatch install_dir)
+  add_library(dispatch SHARED IMPORTED)
+  set_target_properties(dispatch
+                        PROPERTIES
+                          IMPORTED_LOCATION
+                            ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/${CMAKE_SHARED_LIBRARY_PREFIX}dispatch${CMAKE_SHARED_LIBRARY_SUFFIX}
+                          INTERFACE_INCLUDE_DIRECTORIES
+                            ${install_dir}/include
+                          IMPORTED_LINK_INTERFACE_LIBRARIES
+                            swiftCore-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH})
+
+  add_library(BlocksRuntime STATIC IMPORTED)
+  set_target_properties(BlocksRuntime
+                        PROPERTIES
+                          IMPORTED_LOCATION
+                            ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/${CMAKE_STATIC_LIBRARY_PREFIX}BlocksRuntime${CMAKE_STATIC_LIBRARY_SUFFIX}
+                          INTERFACE_INCLUDE_DIRECTORIES
+                            ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/src/BlocksRuntime)
+endif()
+
diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h
index 1b9c326..591855f 100644
--- a/include/swift/AST/Decl.h
+++ b/include/swift/AST/Decl.h
@@ -2696,8 +2696,6 @@
     return UnderlyingTy;
   }
 
-  /// Set the underlying type, for deserialization and synthesized
-  /// aliases.
   void setUnderlyingType(Type type);
 
   /// For generic typealiases, return the unbound generic type.
@@ -4704,6 +4702,7 @@
   struct StoredDefaultArgument {
     Expr *DefaultArg = nullptr;
     Initializer *InitContext = nullptr;
+    StringRef StringRepresentation;
   };
 
   /// The default value, if any, along with whether this is varargs.
@@ -4767,6 +4766,17 @@
 
   void setDefaultArgumentInitContext(Initializer *initContext);
 
+  /// Returns a saved string representation of the parameter's default value.
+  ///
+  /// This should only be called if the default value expression is absent or
+  /// doesn't have a valid source range; otherwise, clients should extract the
+  /// source text from that range.
+  ///
+  /// \sa getDefaultValue
+  StringRef getDefaultValueStringRepresentation() const;
+
+  void setDefaultValueStringRepresentation(StringRef stringRepresentation);
+
   /// Whether or not this parameter is varargs.
   bool isVariadic() const { return DefaultValueAndIsVariadic.getInt(); }
   void setVariadic(bool value = true) {DefaultValueAndIsVariadic.setInt(value);}
diff --git a/include/swift/AST/DefaultArgumentKind.h b/include/swift/AST/DefaultArgumentKind.h
index 67ccc95..ad1ba79 100644
--- a/include/swift/AST/DefaultArgumentKind.h
+++ b/include/swift/AST/DefaultArgumentKind.h
@@ -55,10 +55,6 @@
 };
 enum { NumDefaultArgumentKindBits = 4 };
 
-/// Retrieve the spelling of this default argument in source code, or
-/// an empty string if it has none.
-llvm::StringRef getDefaultArgumentSpelling(DefaultArgumentKind kind);
-
 } // end namespace swift
 
 #endif // LLVM_SWIFT_DEFAULTARGUMENTKIND_H
diff --git a/include/swift/AST/DiagnosticsParse.def b/include/swift/AST/DiagnosticsParse.def
index 9051c0a..6c64cca 100644
--- a/include/swift/AST/DiagnosticsParse.def
+++ b/include/swift/AST/DiagnosticsParse.def
@@ -951,8 +951,10 @@
       "missing condition in an 'if' statement", ())
 ERROR(expected_lbrace_after_if,PointsToFirstBadToken,
       "expected '{' after 'if' condition", ())
-ERROR(expected_lbrace_after_else,PointsToFirstBadToken,
-      "expected '{' after 'else'", ())
+ERROR(expected_lbrace_or_if_after_else,PointsToFirstBadToken,
+      "expected '{' or 'if' after 'else'", ())
+ERROR(expected_lbrace_or_if_after_else_fixit,PointsToFirstBadToken,
+      "expected '{' or 'if' after 'else'; did you mean to write 'if'?", ())
 ERROR(unexpected_else_after_if,none,
       "unexpected 'else' immediately following 'if' condition", ())
 NOTE(suggest_removing_else,none,
diff --git a/include/swift/Parse/Parser.h b/include/swift/Parse/Parser.h
index fe390cd..fd560f5 100644
--- a/include/swift/Parse/Parser.h
+++ b/include/swift/Parse/Parser.h
@@ -192,7 +192,10 @@
   bool isInputIncomplete() const { return IsInputIncomplete; }
 
   void checkForInputIncomplete() {
-    IsInputIncomplete = IsInputIncomplete || Tok.is(tok::eof);
+    IsInputIncomplete = IsInputIncomplete ||
+      // Check whether parser reached EOF but the real EOF, not the end of a
+      // string interpolation segment.
+      (Tok.is(tok::eof) && Tok.getText() != ")");
   }
 
   /// \brief This is the current token being considered by the parser.
@@ -536,6 +539,18 @@
   /// \brief Skip until the next '#else', '#endif' or until eof.
   void skipUntilConditionalBlockClose();
 
+  /// \brief Skip until either finding \c T1 or reaching the end of the line.
+  ///
+  /// This uses \c skipSingle and so matches parens etc. After calling, one or
+  /// more of the following will be true: Tok.is(T1), Tok.isStartOfLine(),
+  /// Tok.is(tok::eof). The "or more" case is the first two: if the next line
+  /// starts with T1.
+  ///
+  /// \returns true if there is an instance of \c T1 on the current line (this
+  /// avoids the foot-gun of not considering T1 starting the next line for a
+  /// plain Tok.is(T1) check).
+  bool skipUntilTokenOrEndOfLine(tok T1);
+
   /// If the parser is generating only a syntax tree, try loading the current
   /// node from a previously generated syntax tree.
   /// Returns \c true if the node has been loaded and inserted into the current
@@ -1341,7 +1356,8 @@
   ParserStatus parseStmtCondition(StmtCondition &Result, Diag<> ID,
                                   StmtKind ParentKind);
   ParserResult<PoundAvailableInfo> parseStmtConditionPoundAvailable();
-  ParserResult<Stmt> parseStmtIf(LabeledStmtInfo LabelInfo);
+  ParserResult<Stmt> parseStmtIf(LabeledStmtInfo LabelInfo,
+                                 bool IfWasImplicitlyInserted = false);
   ParserResult<Stmt> parseStmtGuard();
   ParserResult<Stmt> parseStmtWhile(LabeledStmtInfo LabelInfo);
   ParserResult<Stmt> parseStmtRepeat(LabeledStmtInfo LabelInfo);
diff --git a/include/swift/SILOptimizer/Analysis/Analysis.h b/include/swift/SILOptimizer/Analysis/Analysis.h
index 38ad9f0..fd1b427 100644
--- a/include/swift/SILOptimizer/Analysis/Analysis.h
+++ b/include/swift/SILOptimizer/Analysis/Analysis.h
@@ -174,14 +174,16 @@
 /// ```
 template <typename FunctionInfoTy>
 class FunctionAnalysisBase : public SILAnalysis {
-protected:
-  using StorageTy = llvm::DenseMap<SILFunction *, FunctionInfoTy *>;
+  using StorageTy = llvm::DenseMap<SILFunction *,
+                                   std::unique_ptr<FunctionInfoTy>>;
 
   /// Maps functions to their analysis provider.
   StorageTy storage;
 
+protected:
   /// Construct a new empty function info for a specific function \p F.
-  virtual FunctionInfoTy *newFunctionAnalysis(SILFunction *f) = 0;
+  virtual std::unique_ptr<FunctionInfoTy>
+  newFunctionAnalysis(SILFunction *f) = 0;
 
   /// Return True if the analysis should be invalidated given trait \K is
   /// preserved.
@@ -192,8 +194,6 @@
   virtual void verify(FunctionInfoTy *funcInfo) const {}
 
   void deleteAllAnalysisProviders() {
-    for (auto iter : storage)
-      delete iter.second;
     storage.clear();
   }
 
@@ -208,7 +208,7 @@
     auto iter = storage.find(f);
     if (iter == storage.end())
       return nullptr;
-    return iter->second;
+    return iter->second.get();
   }
 
   /// Returns a function info structure for a specific function \p F.
@@ -219,7 +219,7 @@
     auto &it = storage.FindAndConstruct(f);
     if (!it.second)
       it.second = newFunctionAnalysis(f);
-    return it.second;
+    return it.second.get();
   }
 
   /// Invalidate all information in this analysis.
@@ -229,11 +229,7 @@
 
   /// Helper function to remove the function info for a specific function.
   void invalidateFunction(SILFunction *f) {
-    auto &it = storage.FindAndConstruct(f);
-    if (!it.second)
-      return;
-    delete it.second;
-    it.second = nullptr;
+    storage.erase(f);
   }
 
   /// Invalidate all of the information for a specific function.
@@ -269,10 +265,10 @@
   /// This is not meant to be overridden by subclasses. Instead please override
   /// void FunctionAnalysisBase::verify(FunctionInfoTy *fInfo).
   virtual void verify() const override final {
-    for (auto iter : storage) {
-      if (!iter.second)
+    for (auto &entry : storage) {
+      if (!entry.second)
         continue;
-      verify(iter.second);
+      verify(entry.second.get());
     }
   }
 
@@ -287,7 +283,7 @@
       return;
     if (!iter->second)
       return;
-    verify(iter->second);
+    verify(iter->second.get());
   }
 };
 
diff --git a/include/swift/SILOptimizer/Analysis/DominanceAnalysis.h b/include/swift/SILOptimizer/Analysis/DominanceAnalysis.h
index 2ff3da7..dc76189 100644
--- a/include/swift/SILOptimizer/Analysis/DominanceAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/DominanceAnalysis.h
@@ -41,8 +41,8 @@
     return S->getKind() == SILAnalysisKind::Dominance;
   }
 
-  DominanceInfo *newFunctionAnalysis(SILFunction *F) override {
-    return new DominanceInfo(F);
+  std::unique_ptr<DominanceInfo> newFunctionAnalysis(SILFunction *F) override {
+    return llvm::make_unique<DominanceInfo>(F);
   }
 
   virtual bool shouldInvalidate(SILAnalysis::InvalidationKind K) override {
@@ -70,8 +70,9 @@
     return S->getKind() == SILAnalysisKind::PostDominance;
   }
 
-  PostDominanceInfo *newFunctionAnalysis(SILFunction *F) override {
-    return new PostDominanceInfo(F);
+  std::unique_ptr<PostDominanceInfo>
+  newFunctionAnalysis(SILFunction *F) override {
+    return llvm::make_unique<PostDominanceInfo>(F);
   }
 
   virtual bool shouldInvalidate(SILAnalysis::InvalidationKind K) override {
diff --git a/include/swift/SILOptimizer/Analysis/EpilogueARCAnalysis.h b/include/swift/SILOptimizer/Analysis/EpilogueARCAnalysis.h
index a716211..329a71c 100644
--- a/include/swift/SILOptimizer/Analysis/EpilogueARCAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/EpilogueARCAnalysis.h
@@ -300,8 +300,9 @@
 
   virtual void initialize(SILPassManager *PM) override;
   
-  virtual EpilogueARCFunctionInfo *newFunctionAnalysis(SILFunction *F) override {
-    return new EpilogueARCFunctionInfo(F, PO, AA, RC);
+  virtual std::unique_ptr<EpilogueARCFunctionInfo>
+  newFunctionAnalysis(SILFunction *F) override {
+    return llvm::make_unique<EpilogueARCFunctionInfo>(F, PO, AA, RC);
   }
 
   virtual bool shouldInvalidate(SILAnalysis::InvalidationKind K) override {
diff --git a/include/swift/SILOptimizer/Analysis/IVAnalysis.h b/include/swift/SILOptimizer/Analysis/IVAnalysis.h
index 994bb21..45a35a1 100644
--- a/include/swift/SILOptimizer/Analysis/IVAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/IVAnalysis.h
@@ -90,8 +90,8 @@
     return S->getKind() == SILAnalysisKind::InductionVariable;
   }
 
-  IVInfo *newFunctionAnalysis(SILFunction *F) override {
-    return new IVInfo(*F);
+  std::unique_ptr<IVInfo> newFunctionAnalysis(SILFunction *F) override {
+    return llvm::make_unique<IVInfo>(*F);
   }
 
   /// For now we always invalidate.
diff --git a/include/swift/SILOptimizer/Analysis/LoopAnalysis.h b/include/swift/SILOptimizer/Analysis/LoopAnalysis.h
index f092b02..2e7bc60 100644
--- a/include/swift/SILOptimizer/Analysis/LoopAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/LoopAnalysis.h
@@ -44,7 +44,8 @@
 
   // Computes loop information for the given function using dominance
   // information.
-  virtual SILLoopInfo *newFunctionAnalysis(SILFunction *F) override;
+  virtual std::unique_ptr<SILLoopInfo>
+  newFunctionAnalysis(SILFunction *F) override;
 
   virtual void initialize(SILPassManager *PM) override;
 };
diff --git a/include/swift/SILOptimizer/Analysis/LoopRegionAnalysis.h b/include/swift/SILOptimizer/Analysis/LoopRegionAnalysis.h
index 33ca9de..7c24e6b 100644
--- a/include/swift/SILOptimizer/Analysis/LoopRegionAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/LoopRegionAnalysis.h
@@ -1080,8 +1080,10 @@
     return S->getKind() == SILAnalysisKind::LoopRegion;
   }
 
-  virtual LoopRegionFunctionInfo *newFunctionAnalysis(SILFunction *F) override {
-    return new LoopRegionFunctionInfo(F, POA->get(F), SLA->get(F));
+  virtual std::unique_ptr<LoopRegionFunctionInfo>
+  newFunctionAnalysis(SILFunction *F) override {
+    return llvm::make_unique<LoopRegionFunctionInfo>(F, POA->get(F),
+                                                     SLA->get(F));
   }
 
   virtual bool shouldInvalidate(SILAnalysis::InvalidationKind K) override {
diff --git a/include/swift/SILOptimizer/Analysis/PostOrderAnalysis.h b/include/swift/SILOptimizer/Analysis/PostOrderAnalysis.h
index 321143e..f131988 100644
--- a/include/swift/SILOptimizer/Analysis/PostOrderAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/PostOrderAnalysis.h
@@ -34,8 +34,9 @@
 /// reform the post order over and over again (it can be expensive).
 class PostOrderAnalysis : public FunctionAnalysisBase<PostOrderFunctionInfo> {
 protected:
-  virtual PostOrderFunctionInfo *newFunctionAnalysis(SILFunction *F) override {
-    return new PostOrderFunctionInfo(F);
+  virtual std::unique_ptr<PostOrderFunctionInfo>
+  newFunctionAnalysis(SILFunction *F) override {
+    return llvm::make_unique<PostOrderFunctionInfo>(F);
   }
 
   virtual bool shouldInvalidate(SILAnalysis::InvalidationKind K) override {
diff --git a/include/swift/SILOptimizer/Analysis/RCIdentityAnalysis.h b/include/swift/SILOptimizer/Analysis/RCIdentityAnalysis.h
index e2cb463..abb5093 100644
--- a/include/swift/SILOptimizer/Analysis/RCIdentityAnalysis.h
+++ b/include/swift/SILOptimizer/Analysis/RCIdentityAnalysis.h
@@ -118,8 +118,9 @@
 
   virtual void initialize(SILPassManager *PM) override;
   
-  virtual RCIdentityFunctionInfo *newFunctionAnalysis(SILFunction *F) override {
-    return new RCIdentityFunctionInfo(DA);
+  virtual std::unique_ptr<RCIdentityFunctionInfo>
+  newFunctionAnalysis(SILFunction *F) override {
+    return llvm::make_unique<RCIdentityFunctionInfo>(DA);
   }
 
   virtual bool shouldInvalidate(SILAnalysis::InvalidationKind K) override {
diff --git a/include/swift/Serialization/ModuleFormat.h b/include/swift/Serialization/ModuleFormat.h
index 8d6d717..5e6755f 100644
--- a/include/swift/Serialization/ModuleFormat.h
+++ b/include/swift/Serialization/ModuleFormat.h
@@ -55,7 +55,7 @@
 /// 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.
 /// Don't worry about adhering to the 80-column limit for this line.
-const uint16_t VERSION_MINOR = 431; // Last change: eliminate PARAMETERLIST_ELT
+const uint16_t VERSION_MINOR = 432; // Last change: default argument text
 
 using DeclIDField = BCFixed<31>;
 
@@ -1003,13 +1003,14 @@
 
   using ParamLayout = BCRecordLayout<
     PARAM_DECL,
-    IdentifierIDField,   // argument name
-    IdentifierIDField,   // parameter name
-    DeclContextIDField,  // context decl
+    IdentifierIDField,     // argument name
+    IdentifierIDField,     // parameter name
+    DeclContextIDField,    // context decl
     VarDeclSpecifierField, // specifier
-    TypeIDField,         // interface type
-    BCFixed<1>,          // isVariadic?
-    DefaultArgumentField // default argument
+    TypeIDField,           // interface type
+    BCFixed<1>,            // isVariadic?
+    DefaultArgumentField,  // default argument kind
+    BCBlob                 // default argument text
   >;
 
   using FuncLayout = BCRecordLayout<
diff --git a/include/swift/TBDGen/TBDGen.h b/include/swift/TBDGen/TBDGen.h
index eca9386..ef41900 100644
--- a/include/swift/TBDGen/TBDGen.h
+++ b/include/swift/TBDGen/TBDGen.h
@@ -23,6 +23,9 @@
 class FileUnit;
 class ModuleDecl;
 
+/// \brief The current ABI version of Swift, as tapi labels it.
+const uint8_t TAPI_SWIFT_ABI_VERSION = 5;
+
 /// \brief Options for controlling the exact set of symbols included in the TBD
 /// output.
 struct TBDGenOptions {
diff --git a/lib/AST/ASTPrinter.cpp b/lib/AST/ASTPrinter.cpp
index 65d9747..738b379 100644
--- a/lib/AST/ASTPrinter.cpp
+++ b/lib/AST/ASTPrinter.cpp
@@ -2327,8 +2327,8 @@
     Printer << "...";
 
   if (param->isDefaultArgument()) {
-    auto defaultArgStr
-      = getDefaultArgumentSpelling(param->getDefaultArgumentKind());
+    StringRef defaultArgStr = param->getDefaultValueStringRepresentation();
+
     if (defaultArgStr.empty()) {
       if (Options.PrintDefaultParameterPlaceholder)
         Printer << " = " << tok::kw_default;
@@ -2341,6 +2341,7 @@
       case DefaultArgumentKind::Column:
       case DefaultArgumentKind::Function:
       case DefaultArgumentKind::DSOHandle:
+      case DefaultArgumentKind::NilLiteral:
         Printer.printKeyword(defaultArgStr);
         break;
       default:
diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt
index 72885b8..a961cd8 100644
--- a/lib/AST/CMakeLists.txt
+++ b/lib/AST/CMakeLists.txt
@@ -24,7 +24,6 @@
   Decl.cpp
   DeclContext.cpp
   DeclNameLoc.cpp
-  DefaultArgumentKind.cpp
   DiagnosticConsumer.cpp
   DiagnosticEngine.cpp
   DiagnosticList.cpp
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index ffd1d72..4739c4e 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -4880,6 +4880,43 @@
   DefaultValueAndIsVariadic.getPointer()->InitContext = initContext;
 }
 
+StringRef ParamDecl::getDefaultValueStringRepresentation() const {
+  switch (getDefaultArgumentKind()) {
+  case DefaultArgumentKind::None:
+    llvm_unreachable("called on a ParamDecl with no default value");
+  case DefaultArgumentKind::Normal:
+    assert(DefaultValueAndIsVariadic.getPointer() &&
+           "default value not provided yet");
+    return DefaultValueAndIsVariadic.getPointer()->StringRepresentation;
+  case DefaultArgumentKind::Inherited:
+    // FIXME: This needs /some/ kind of textual representation, but this isn't
+    // a great one.
+    return "super";
+  case DefaultArgumentKind::File: return "#file";
+  case DefaultArgumentKind::Line: return "#line";
+  case DefaultArgumentKind::Column: return "#column";
+  case DefaultArgumentKind::Function: return "#function";
+  case DefaultArgumentKind::DSOHandle: return "#dsohandle";
+  case DefaultArgumentKind::NilLiteral: return "nil";
+  case DefaultArgumentKind::EmptyArray: return "[]";
+  case DefaultArgumentKind::EmptyDictionary: return "[:]";
+  }
+}
+
+void
+ParamDecl::setDefaultValueStringRepresentation(StringRef stringRepresentation) {
+  assert(getDefaultArgumentKind() == DefaultArgumentKind::Normal);
+  assert(!stringRepresentation.empty());
+
+  if (!DefaultValueAndIsVariadic.getPointer()) {
+    DefaultValueAndIsVariadic.setPointer(
+      getASTContext().Allocate<StoredDefaultArgument>());
+  }
+
+  DefaultValueAndIsVariadic.getPointer()->StringRepresentation =
+      stringRepresentation;
+}
+
 void DefaultArgumentInitializer::changeFunction(
     DeclContext *parent, ParameterList *paramList) {
   if (parent->isLocalContext()) {
diff --git a/lib/AST/DefaultArgumentKind.cpp b/lib/AST/DefaultArgumentKind.cpp
deleted file mode 100644
index 6f65b91..0000000
--- a/lib/AST/DefaultArgumentKind.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-//===--- DefaultArgumentKind.cpp - Default Argument Implementation --------===//
-//
-// This source file is part of the Swift.org open source project
-//
-// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
-// Licensed under Apache License v2.0 with Runtime Library Exception
-//
-// See https://swift.org/LICENSE.txt for license information
-// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
-//
-//===----------------------------------------------------------------------===//
-//
-//  This file implements utilities associated with default arguments.
-//
-//===----------------------------------------------------------------------===//
-#include "swift/AST/DefaultArgumentKind.h"
-#include "swift/AST/ASTContext.h"
-#include "swift/AST/Decl.h"
-#include "swift/AST/Expr.h"
-using namespace swift;
-
-StringRef swift::getDefaultArgumentSpelling(DefaultArgumentKind kind) {
-  switch (kind) {
-  case DefaultArgumentKind::None:
-  case DefaultArgumentKind::Normal:
-  case DefaultArgumentKind::Inherited:
-    return StringRef();
-  case DefaultArgumentKind::File:      return "#file";
-  case DefaultArgumentKind::Line:      return "#line";
-  case DefaultArgumentKind::Column:    return "#column";
-  case DefaultArgumentKind::Function:  return "#function";
-  case DefaultArgumentKind::DSOHandle: return "#dsohandle";
-  case DefaultArgumentKind::NilLiteral: return "nil";
-  case DefaultArgumentKind::EmptyArray: return "[]";
-  case DefaultArgumentKind::EmptyDictionary: return "[:]";
-  }
-
-  llvm_unreachable("Unhandled DefaultArgumentKind in switch.");
-}
diff --git a/lib/IDE/CodeCompletion.cpp b/lib/IDE/CodeCompletion.cpp
index 27dc2ca..fdc945a 100644
--- a/lib/IDE/CodeCompletion.cpp
+++ b/lib/IDE/CodeCompletion.cpp
@@ -961,7 +961,7 @@
                              bool UseFuncResultType = true) {
   auto VD = dyn_cast<ValueDecl>(D);
   auto DC = D->getDeclContext();
-  if (!VD)
+  if (!VD || !VD->hasInterfaceType())
     return CodeCompletionResult::ExpectedTypeRelation::Unrelated;
 
   if (auto FD = dyn_cast<AbstractFunctionDecl>(VD)) {
diff --git a/lib/LLVMPasses/LLVMMergeFunctions.cpp b/lib/LLVMPasses/LLVMMergeFunctions.cpp
index 14afcba..31d4709 100644
--- a/lib/LLVMPasses/LLVMMergeFunctions.cpp
+++ b/lib/LLVMPasses/LLVMMergeFunctions.cpp
@@ -402,6 +402,8 @@
 
   bool deriveParams(ParamInfos &Params, FunctionInfos &FInfos);
 
+  bool numOperandsDiffer(FunctionInfos &FInfos);
+
   bool constsDiffer(const FunctionInfos &FInfos, unsigned OpIdx);
 
   bool tryMapToParameter(FunctionInfos &FInfos, unsigned OpIdx,
@@ -763,6 +765,20 @@
   // Iterate over all instructions synchronously in all functions.
   do {
     if (isEligibleForConstantSharing(FirstFI.CurrentInst)) {
+
+      // Here we handle a rare corner case which needs to be explained:
+      // Usually the number of operands match, because otherwise the functions
+      // in FInfos would not be in the same equivalence class. There is only one
+      // exception to that: If the current instruction is a call to a function,
+      // which was merged in the previous iteration (in tryMergeEquivalenceClass)
+      // then the call could be replaced and has more arguments than the
+      // original call.
+      if (numOperandsDiffer(FInfos)) {
+        assert(isa<CallInst>(FirstFI.CurrentInst) &&
+               "only calls are expected to differ in number of operands");
+        return false;
+      }
+
       for (unsigned OpIdx = 0, NumOps = FirstFI.CurrentInst->getNumOperands();
            OpIdx != NumOps; ++OpIdx) {
 
@@ -784,6 +800,16 @@
   return true;
 }
 
+/// Returns true if the number of operands of the current instruction differs.
+bool SwiftMergeFunctions::numOperandsDiffer(FunctionInfos &FInfos) {
+  unsigned numOps = FInfos[0].CurrentInst->getNumOperands();
+  for (const FunctionInfo &FI : ArrayRef<FunctionInfo>(FInfos).drop_front(1)) {
+    if (FI.CurrentInst->getNumOperands() != numOps)
+      return true;
+  }
+  return false;
+}
+
 /// Returns true if the \p OpIdx's constant operand in the current instruction
 /// does differ in any of the functions in \p FInfos.
 bool SwiftMergeFunctions::constsDiffer(const FunctionInfos &FInfos,
diff --git a/lib/Parse/ParseDecl.cpp b/lib/Parse/ParseDecl.cpp
index 410dd81..221c781 100644
--- a/lib/Parse/ParseDecl.cpp
+++ b/lib/Parse/ParseDecl.cpp
@@ -3281,9 +3281,7 @@
     // Catch #warning(oops, forgot the quotes)
     SourceLoc wordsStartLoc = Tok.getLoc();
 
-    while (!Tok.isAtStartOfLine() && !Tok.isAny(tok::r_paren, tok::eof)) {
-      skipSingle();
-    }
+    skipUntilTokenOrEndOfLine(tok::r_paren);
 
     SourceLoc wordsEndLoc = getEndOfPreviousLoc();
 
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index d23f314..3252d7d 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -1762,6 +1762,10 @@
   // Eat an invalid token in an expression context.  Error tokens are diagnosed
   // by the lexer, so there is no reason to emit another diagnostic.
   case tok::unknown:
+    if (Tok.getText().startswith("\"\"\"")) {
+      // This was due to unterminated multi-line string.
+      IsInputIncomplete = true;
+    }
     consumeToken(tok::unknown);
     return nullptr;
 
diff --git a/lib/Parse/ParsePattern.cpp b/lib/Parse/ParsePattern.cpp
index 8e8f5f5..325d198 100644
--- a/lib/Parse/ParsePattern.cpp
+++ b/lib/Parse/ParsePattern.cpp
@@ -63,11 +63,9 @@
   }
 }
 
-static ParserStatus parseDefaultArgument(Parser &P,
-                                   Parser::DefaultArgumentInfo *defaultArgs,
-                                   unsigned argIndex,
-                                   Expr *&init,
-                                 Parser::ParameterContextKind paramContext) {
+static ParserStatus parseDefaultArgument(
+    Parser &P, Parser::DefaultArgumentInfo *defaultArgs, unsigned argIndex,
+    Expr *&init, Parser::ParameterContextKind paramContext) {
   SyntaxParsingContext DefaultArgContext(P.SyntaxContext,
                                          SyntaxKind::InitializerClause);
   SourceLoc equalLoc = P.consumeToken(tok::equal);
@@ -576,8 +574,17 @@
               paramContext == Parser::ParameterContextKind::Initializer ||
               paramContext == Parser::ParameterContextKind::EnumElement) &&
              "Default arguments are only permitted on the first param clause");
-      result->setDefaultArgumentKind(getDefaultArgKind(param.DefaultArg));
+      DefaultArgumentKind kind = getDefaultArgKind(param.DefaultArg);
+      result->setDefaultArgumentKind(kind);
       result->setDefaultValue(param.DefaultArg);
+      if (kind == DefaultArgumentKind::Normal) {
+        SourceRange defaultArgRange = param.DefaultArg->getSourceRange();
+        CharSourceRange charRange =
+            Lexer::getCharSourceRangeFromSourceRange(parser.SourceMgr,
+                                                     defaultArgRange);
+        StringRef defaultArgText = parser.SourceMgr.extractText(charRange);
+        result->setDefaultValueStringRepresentation(defaultArgText);
+      }
     }
 
     elements.push_back(result);
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index d9cf6a6..b7b6dfe 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -182,8 +182,9 @@
       // for 'case's.
       do {
         consumeToken();
-        while (!Tok.isAtStartOfLine() && Tok.isNot(tok::eof))
-          skipSingle();
+
+        // just find the end of the line
+        skipUntilTokenOrEndOfLine(tok::NUM_TOKENS);
       } while (Tok.isAny(tok::pound_if, tok::pound_elseif, tok::pound_else));
       return isAtStartOfSwitchCase(*this, /*needsToBacktrack*/false);
     }
@@ -318,6 +319,10 @@
     // Eat invalid tokens instead of allowing them to produce downstream errors.
     if (Tok.is(tok::unknown)) {
       SyntaxParsingContext ErrContext(SyntaxContext, SyntaxContextKind::Stmt);
+      if (Tok.getText().startswith("\"\"\"")) {
+        // This was due to unterminated multi-line string.
+        IsInputIncomplete = true;
+      }
       consumeToken();
       continue;
     }
@@ -640,9 +645,7 @@
     diagnose(Tok, ID);
 
     // Attempt to recover by looking for a left brace on the same line
-    while (Tok.isNot(tok::eof, tok::l_brace) && !Tok.isAtStartOfLine())
-      skipSingle();
-    if (Tok.isNot(tok::l_brace))
+    if (!skipUntilTokenOrEndOfLine(tok::l_brace))
       return nullptr;
   }
   SyntaxParsingContext LocalContext(SyntaxContext, SyntaxKind::CodeBlock);
@@ -1573,9 +1576,17 @@
 ///   stmt-if-else:
 ///    'else' stmt-brace
 ///    'else' stmt-if
-ParserResult<Stmt> Parser::parseStmtIf(LabeledStmtInfo LabelInfo) {
+ParserResult<Stmt> Parser::parseStmtIf(LabeledStmtInfo LabelInfo,
+                                       bool IfWasImplicitlyInserted) {
   SyntaxContext->setCreateSyntax(SyntaxKind::IfStmt);
-  SourceLoc IfLoc = consumeToken(tok::kw_if);
+  SourceLoc IfLoc;
+  if (IfWasImplicitlyInserted) {
+    // The code was invalid due to a missing 'if' (e.g. 'else x < y {') and a
+    // fixit implicitly inserted it.
+    IfLoc = Tok.getLoc();
+  } else {
+    IfLoc = consumeToken(tok::kw_if);
+  }
 
   ParserStatus Status;
   StmtCondition Condition;
@@ -1635,16 +1646,30 @@
   ParserResult<Stmt> ElseBody;
   if (Tok.is(tok::kw_else)) {
     ElseLoc = consumeToken(tok::kw_else);
-    if (Tok.is(tok::kw_if)) {
+
+    bool implicitlyInsertIf = false;
+    if (Tok.isNot(tok::kw_if, tok::l_brace, tok::code_complete)) {
+      // The code looks like 'if ... { ... } else not_if_or_lbrace', so we've
+      // got a problem. If the last bit is 'else ... {' on one line, let's
+      // assume they've forgotten the 'if'.
+      BacktrackingScope backtrack(*this);
+      implicitlyInsertIf = skipUntilTokenOrEndOfLine(tok::l_brace);
+    }
+
+    if (Tok.is(tok::kw_if) || implicitlyInsertIf) {
+      if (implicitlyInsertIf) {
+        diagnose(ElseLoc, diag::expected_lbrace_or_if_after_else_fixit)
+            .fixItInsertAfter(ElseLoc, " if");
+      }
       SyntaxParsingContext ElseIfCtxt(SyntaxContext, SyntaxKind::IfStmt);
-      ElseBody = parseStmtIf(LabeledStmtInfo());
+      ElseBody = parseStmtIf(LabeledStmtInfo(), implicitlyInsertIf);
     } else if (Tok.is(tok::code_complete)) {
       if (CodeCompletion)
         CodeCompletion->completeAfterIfStmt(/*hasElse*/true);
       Status.setHasCodeCompletion();
       consumeToken(tok::code_complete);
     } else {
-      ElseBody = parseBraceItemList(diag::expected_lbrace_after_else);
+      ElseBody = parseBraceItemList(diag::expected_lbrace_or_if_after_else);
     }
     Status |= ElseBody;
   } else if (Tok.is(tok::code_complete)) {
diff --git a/lib/Parse/Parser.cpp b/lib/Parse/Parser.cpp
index 75c1caa..dfdd6e0 100644
--- a/lib/Parse/Parser.cpp
+++ b/lib/Parse/Parser.cpp
@@ -714,6 +714,13 @@
   }
 }
 
+bool Parser::skipUntilTokenOrEndOfLine(tok T1) {
+  while (Tok.isNot(tok::eof, T1) && !Tok.isAtStartOfLine())
+    skipSingle();
+
+  return Tok.is(T1) && !Tok.isAtStartOfLine();
+}
+
 bool Parser::loadCurrentSyntaxNodeFromCache() {
   // Don't do a cache lookup when not building a syntax tree since otherwise
   // the corresponding AST nodes do not get created
diff --git a/lib/SILOptimizer/Analysis/LoopAnalysis.cpp b/lib/SILOptimizer/Analysis/LoopAnalysis.cpp
index f6ed93f..59ca2b4 100644
--- a/lib/SILOptimizer/Analysis/LoopAnalysis.cpp
+++ b/lib/SILOptimizer/Analysis/LoopAnalysis.cpp
@@ -18,11 +18,12 @@
 
 using namespace swift;
 
-SILLoopInfo *SILLoopAnalysis::newFunctionAnalysis(SILFunction *F) {
+std::unique_ptr<SILLoopInfo>
+SILLoopAnalysis::newFunctionAnalysis(SILFunction *F) {
   assert(DA != nullptr && "Expect a valid dominance analysis");
   DominanceInfo *DT = DA->get(F);
   assert(DT != nullptr && "Expect a valid dominance information");
-  return new SILLoopInfo(F, DT);
+  return llvm::make_unique<SILLoopInfo>(F, DT);
 }
 
 void SILLoopAnalysis::initialize(SILPassManager *PM) {
diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp
index 3c5e2d0..3d75606 100644
--- a/lib/Serialization/Deserialization.cpp
+++ b/lib/Serialization/Deserialization.cpp
@@ -3040,8 +3040,11 @@
 
     // Decode the default argument kind.
     // FIXME: Default argument expression, if available.
-    if (auto defaultArg = getActualDefaultArgKind(rawDefaultArg))
+    if (auto defaultArg = getActualDefaultArgKind(rawDefaultArg)) {
       param->setDefaultArgumentKind(*defaultArg);
+      if (!blobData.empty())
+        param->setDefaultValueStringRepresentation(blobData);
+    }
     break;
   }
 
diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp
index 50b33a7..1ac8785 100644
--- a/lib/Serialization/Serialization.cpp
+++ b/lib/Serialization/Serialization.cpp
@@ -3168,6 +3168,12 @@
     auto contextID = addDeclContextRef(param->getDeclContext());
     Type interfaceType = param->getInterfaceType();
 
+    // Only save the text for normal default arguments, not any of the special
+    // ones.
+    StringRef defaultArgumentText;
+    if (param->getDefaultArgumentKind() == swift::DefaultArgumentKind::Normal)
+      defaultArgumentText = param->getDefaultValueStringRepresentation();
+
     unsigned abbrCode = DeclTypeAbbrCodes[ParamLayout::Code];
     ParamLayout::emitRecord(Out, ScratchRecord, abbrCode,
         addDeclBaseNameRef(param->getArgumentName()),
@@ -3176,7 +3182,8 @@
         getRawStableVarDeclSpecifier(param->getSpecifier()),
         addTypeRef(interfaceType),
         param->isVariadic(),
-        getRawStableDefaultArgumentKind(param->getDefaultArgumentKind()));
+        getRawStableDefaultArgumentKind(param->getDefaultArgumentKind()),
+        defaultArgumentText);
 
     if (interfaceType->hasError()) {
       param->getDeclContext()->dumpContext();
diff --git a/lib/TBDGen/TBDGen.cpp b/lib/TBDGen/TBDGen.cpp
index 1098bca..645e9a8 100644
--- a/lib/TBDGen/TBDGen.cpp
+++ b/lib/TBDGen/TBDGen.cpp
@@ -418,8 +418,7 @@
   file.setInstallName(opts.InstallName);
   // FIXME: proper version
   file.setCurrentVersion(tapi::internal::PackedVersion(1, 0, 0));
-  // FIXME: pull this out of moduleformat?
-  file.setSwiftABIVersion(5);
+  file.setSwiftABIVersion(TAPI_SWIFT_ABI_VERSION);
   file.setPlatform(tapi::internal::mapToSinglePlatform(target));
   auto arch = tapi::internal::getArchType(target.getArchName());
   file.setArch(arch);
diff --git a/stdlib/public/SDK/Foundation/JSONEncoder.swift b/stdlib/public/SDK/Foundation/JSONEncoder.swift
index 917259b..0862809 100644
--- a/stdlib/public/SDK/Foundation/JSONEncoder.swift
+++ b/stdlib/public/SDK/Foundation/JSONEncoder.swift
@@ -10,6 +10,42 @@
 //
 //===----------------------------------------------------------------------===//
 
+/// A marker protocol used to determine whether a value is a `String`-keyed `Dictionary`
+/// containing `Encodable` values (in which case it should be exempt from key conversion strategies).
+///
+/// NOTE: The architecture and environment check is due to a bug in the current (2018-08-08) Swift 4.2
+/// runtime when running on i386 simulator. The issue is tracked in https://bugs.swift.org/browse/SR-8276
+/// Making the protocol `internal` instead of `fileprivate` works around this issue.
+/// Once SR-8276 is fixed, this check can be removed and the protocol always be made fileprivate.
+#if arch(i386) && targetEnvironment(simulator)
+internal protocol _JSONStringDictionaryEncodableMarker { }
+#else
+fileprivate protocol _JSONStringDictionaryEncodableMarker { }
+#endif
+
+extension Dictionary : _JSONStringDictionaryEncodableMarker where Key == String, Value: Encodable { }
+
+/// A marker protocol used to determine whether a value is a `String`-keyed `Dictionary`
+/// containing `Decodable` values (in which case it should be exempt from key conversion strategies).
+///
+/// The marker protocol also provides access to the type of the `Decodable` values,
+/// which is needed for the implementation of the key conversion strategy exemption.
+///
+/// NOTE: Please see comment above regarding SR-8276
+#if arch(i386) && targetEnvironment(simulator)
+internal protocol _JSONStringDictionaryDecodableMarker {
+    static var elementType: Decodable.Type { get }
+}
+#else
+fileprivate protocol _JSONStringDictionaryDecodableMarker {
+    static var elementType: Decodable.Type { get }
+}
+#endif
+
+extension Dictionary : _JSONStringDictionaryDecodableMarker where Key == String, Value: Decodable {
+    static var elementType: Decodable.Type { return Value.self }
+}
+
 //===----------------------------------------------------------------------===//
 // JSON Encoder
 //===----------------------------------------------------------------------===//
@@ -815,24 +851,55 @@
         }
     }
 
-    fileprivate func box<T : Encodable>(_ value: T) throws -> NSObject {
+    fileprivate func box(_ dict: [String : Encodable]) throws -> NSObject? {
+        let depth = self.storage.count
+        let result = self.storage.pushKeyedContainer()
+        do {
+            for (key, value) in dict {
+                self.codingPath.append(_JSONKey(stringValue: key, intValue: nil))
+                defer { self.codingPath.removeLast() }
+                result[key] = try box(value)
+            }
+        } catch {
+            // If the value pushed a container before throwing, pop it back off to restore state.
+            if self.storage.count > depth {
+                let _ = self.storage.popContainer()
+            }
+
+            throw error
+        }
+
+        // The top container should be a new container.
+        guard self.storage.count > depth else {
+            return nil
+        }
+
+        return self.storage.popContainer()
+    }
+
+    fileprivate func box(_ value: Encodable) throws -> NSObject {
         return try self.box_(value) ?? NSDictionary()
     }
 
     // This method is called "box_" instead of "box" to disambiguate it from the overloads. Because the return type here is different from all of the "box" overloads (and is more general), any "box" calls in here would call back into "box" recursively instead of calling the appropriate overload, which is not what we want.
-    fileprivate func box_<T : Encodable>(_ value: T) throws -> NSObject? {
-        if T.self == Date.self || T.self == NSDate.self {
+    fileprivate func box_(_ value: Encodable) throws -> NSObject? {
+        // Disambiguation between variable and function is required due to
+        // issue tracked at: https://bugs.swift.org/browse/SR-1846
+        let type = Swift.type(of: value)
+        if type == Date.self || type == NSDate.self {
             // Respect Date encoding strategy
             return try self.box((value as! Date))
-        } else if T.self == Data.self || T.self == NSData.self {
+        } else if type == Data.self || type == NSData.self {
             // Respect Data encoding strategy
             return try self.box((value as! Data))
-        } else if T.self == URL.self || T.self == NSURL.self {
+        } else if type == URL.self || type == NSURL.self {
             // Encode URLs as single strings.
             return self.box((value as! URL).absoluteString)
-        } else if T.self == Decimal.self || T.self == NSDecimalNumber.self {
+        } else if type == Decimal.self || type == NSDecimalNumber.self {
             // JSONSerialization can natively handle NSDecimalNumber.
             return (value as! NSDecimalNumber)
+        } else if value is _JSONStringDictionaryEncodableMarker {
+            return try self.box(value as! [String : Encodable])
         }
 
         // The value should request a container from the _JSONEncoder.
@@ -2359,11 +2426,34 @@
         }
     }
 
+    fileprivate func unbox<T>(_ value: Any, as type: _JSONStringDictionaryDecodableMarker.Type) throws -> T? {
+        guard !(value is NSNull) else { return nil }
+
+        var result = [String : Any]()
+        guard let dict = value as? NSDictionary else {
+            throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
+        }
+        let elementType = type.elementType
+        for (key, value) in dict {
+            let key = key as! String
+            self.codingPath.append(_JSONKey(stringValue: key, intValue: nil))
+            defer { self.codingPath.removeLast() }
+
+            result[key] = try unbox_(value, as: elementType)
+        }
+
+        return result as? T
+    }
+
     fileprivate func unbox<T : Decodable>(_ value: Any, as type: T.Type) throws -> T? {
+        return try unbox_(value, as: type) as? T
+    }
+
+    fileprivate func unbox_(_ value: Any, as type: Decodable.Type) throws -> Any? {
         if type == Date.self || type == NSDate.self {
-            return try self.unbox(value, as: Date.self) as? T
+            return try self.unbox(value, as: Date.self)
         } else if type == Data.self || type == NSData.self {
-            return try self.unbox(value, as: Data.self) as? T
+            return try self.unbox(value, as: Data.self)
         } else if type == URL.self || type == NSURL.self {
             guard let urlString = try self.unbox(value, as: String.self) else {
                 return nil
@@ -2373,10 +2463,11 @@
                 throw DecodingError.dataCorrupted(DecodingError.Context(codingPath: self.codingPath,
                                                                         debugDescription: "Invalid URL string."))
             }
-
-            return (url as! T)
+            return url
         } else if type == Decimal.self || type == NSDecimalNumber.self {
-            return try self.unbox(value, as: Decimal.self) as? T
+            return try self.unbox(value, as: Decimal.self)
+        } else if let stringKeyedDictType = type as? _JSONStringDictionaryDecodableMarker.Type {
+            return try self.unbox(value, as: stringKeyedDictType)
         } else {
             self.storage.push(container: value)
             defer { self.storage.popContainer() }
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f1362e9..a7e2c74 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -196,7 +196,7 @@
 
     if(SWIFT_BUILD_STDLIB AND SWIFT_INCLUDE_TESTS)
       list(APPEND test_dependencies
-          "swift-reflection-test${VARIANT_SUFFIX}")
+          "swift-reflection-test${VARIANT_SUFFIX}_signed")
     endif()
 
     if(NOT "${COVERAGE_DB}" STREQUAL "")
diff --git a/test/FixCode/fixits-if-else.swift b/test/FixCode/fixits-if-else.swift
new file mode 100644
index 0000000..6861c13
--- /dev/null
+++ b/test/FixCode/fixits-if-else.swift
@@ -0,0 +1,34 @@
+// RUN: not %swift -emit-sil -target %target-triple %s -emit-fixits-path %t.remap -I %S/Inputs -diagnostics-editor-mode
+// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
+
+func something() -> Bool { return true }
+
+func foo1() {
+    if something() {
+    } else
+}
+
+func foo2() {
+    if something() {
+    } else
+    foo1()
+}
+
+func foo3() {
+    if something() {
+    } else something() { // all on one line, 'if' inserted
+    }
+}
+
+func foo4() {
+    if something() {
+    } else something()
+    {
+    }
+}
+
+func foo5() {
+    if something() {
+    } else something()
+    foo1()
+}
diff --git a/test/FixCode/fixits-if-else.swift.result b/test/FixCode/fixits-if-else.swift.result
new file mode 100644
index 0000000..b282f34
--- /dev/null
+++ b/test/FixCode/fixits-if-else.swift.result
@@ -0,0 +1,34 @@
+// RUN: not %swift -emit-sil -target %target-triple %s -emit-fixits-path %t.remap -I %S/Inputs -diagnostics-editor-mode
+// RUN: c-arcmt-test %t.remap | arcmt-test -verify-transformed-files %s.result
+
+func something() -> Bool { return true }
+
+func foo1() {
+    if something() {
+    } else
+}
+
+func foo2() {
+    if something() {
+    } else
+    foo1()
+}
+
+func foo3() {
+    if something() {
+    } else if something() { // all on one line, 'if' inserted
+    }
+}
+
+func foo4() {
+    if something() {
+    } else something()
+    {
+    }
+}
+
+func foo5() {
+    if something() {
+    } else something()
+    foo1()
+}
diff --git a/test/IDE/complete_call_arg.swift b/test/IDE/complete_call_arg.swift
index fddcca6..c9945ae 100644
--- a/test/IDE/complete_call_arg.swift
+++ b/test/IDE/complete_call_arg.swift
@@ -46,6 +46,7 @@
 // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=FORCED_IUO | %FileCheck %s -check-prefix=MEMBEROF_IUO
 
 // RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=GENERIC_TO_GENERIC | %FileCheck %s -check-prefix=GENERIC_TO_GENERIC
+// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=NESTED_CLOSURE | %FileCheck %s -check-prefix=NESTED_CLOSURE
 
 var i1 = 1
 var i2 = 2
@@ -416,3 +417,11 @@
   // MEMBEROF_IUO: Decl[InstanceVar]/CurrNominal: x[#Int#]; name=x
   // MEMBEROF_IUO: End completions
 }
+
+func curry<T1, T2, R>(_ f: @escaping (T1, T2) -> R) -> (T1) -> (T2) -> R {
+  return { t1 in { t2 in f(#^NESTED_CLOSURE^#, t2) } }
+  // NESTED_CLOSURE: Begin completions
+  // FIXME: Should be '/TypeRelation[Invalid]: t2[#T2#]'
+  // NESTED_CLOSURE: Decl[LocalVar]/Local:               t2; name=t2
+  // NESTED_CLOSURE: Decl[LocalVar]/Local:               t1[#T1#]; name=t1
+}
diff --git a/test/IDE/print_ast_tc_decls.swift b/test/IDE/print_ast_tc_decls.swift
index 2dac63f..6e1b939 100644
--- a/test/IDE/print_ast_tc_decls.swift
+++ b/test/IDE/print_ast_tc_decls.swift
@@ -130,10 +130,10 @@
 // PASS_COMMON-NEXT: {{^}}  func instanceFunc3(a: Int, b: Double){{$}}
 
   func instanceFuncWithDefaultArg1(a: Int = 0) {}
-// PASS_COMMON-NEXT: {{^}}  func instanceFuncWithDefaultArg1(a: Int = default){{$}}
+// PASS_COMMON-NEXT: {{^}}  func instanceFuncWithDefaultArg1(a: Int = 0){{$}}
 
   func instanceFuncWithDefaultArg2(a: Int = 0, b: Double = 0) {}
-// PASS_COMMON-NEXT: {{^}}  func instanceFuncWithDefaultArg2(a: Int = default, b: Double = default){{$}}
+// PASS_COMMON-NEXT: {{^}}  func instanceFuncWithDefaultArg2(a: Int = 0, b: Double = 0){{$}}
 
   func varargInstanceFunc0(v: Int...) {}
 // PASS_COMMON-NEXT: {{^}}  func varargInstanceFunc0(v: Int...){{$}}
diff --git a/test/IDE/print_type_interface.swift b/test/IDE/print_type_interface.swift
index a43f207..d61f4af 100644
--- a/test/IDE/print_type_interface.swift
+++ b/test/IDE/print_type_interface.swift
@@ -79,7 +79,7 @@
 // RUN: %target-swift-ide-test -print-type-interface -usr=_TtGSaSS_ -module-name print_type_interface -source-filename %s | %FileCheck %s -check-prefix=TYPE5
 // TYPE5-DAG: public func prefix(_ maxLength: Int) -> ArraySlice<String>
 // TYPE5-DAG: public func suffix(_ maxLength: Int) -> ArraySlice<String>
-// TYPE5-DAG: public func split(separator: String, maxSplits: Int = default, omittingEmptySubsequences: Bool = default) -> [ArraySlice<String>]
+// TYPE5-DAG: public func split(separator: String, maxSplits: Int = Int.max, omittingEmptySubsequences: Bool = true) -> [ArraySlice<String>]
 // TYPE5-DAG: public func formIndex(_ i: inout Int, offsetBy distance: Int)
 // TYPE5-DAG: public func distance(from start: Int, to end: Int) -> Int
-// TYPE5-DAG: public func joined(separator: String = default) -> String
+// TYPE5-DAG: public func joined(separator: String = "") -> String
diff --git a/test/IDE/test-input-complete/Inputs/invalid_interpolation1.swift b/test/IDE/test-input-complete/Inputs/invalid_interpolation1.swift
new file mode 100644
index 0000000..e33eae5
--- /dev/null
+++ b/test/IDE/test-input-complete/Inputs/invalid_interpolation1.swift
@@ -0,0 +1 @@
+foo("\()")
\ No newline at end of file
diff --git a/test/IDE/test-input-complete/Inputs/multi_line_string1.swift b/test/IDE/test-input-complete/Inputs/multi_line_string1.swift
new file mode 100644
index 0000000..d4835f1
--- /dev/null
+++ b/test/IDE/test-input-complete/Inputs/multi_line_string1.swift
@@ -0,0 +1,4 @@
+"""
+some
+multiline
+string
\ No newline at end of file
diff --git a/test/IDE/test-input-complete/Inputs/multi_line_string2.swift b/test/IDE/test-input-complete/Inputs/multi_line_string2.swift
new file mode 100644
index 0000000..19736f2
--- /dev/null
+++ b/test/IDE/test-input-complete/Inputs/multi_line_string2.swift
@@ -0,0 +1,5 @@
+a +
+"""
+some
+multiline
+string
\ No newline at end of file
diff --git a/test/IDE/test-input-complete/Inputs/multi_line_string3.swift b/test/IDE/test-input-complete/Inputs/multi_line_string3.swift
new file mode 100644
index 0000000..c1e560b
--- /dev/null
+++ b/test/IDE/test-input-complete/Inputs/multi_line_string3.swift
@@ -0,0 +1,5 @@
+"""
+some
+multiline
+string
+\(
\ No newline at end of file
diff --git a/test/IDE/test-input-complete/test_input.swift b/test/IDE/test-input-complete/test_input.swift
index b14afca..df2fcad 100644
--- a/test/IDE/test-input-complete/test_input.swift
+++ b/test/IDE/test-input-complete/test_input.swift
@@ -30,6 +30,10 @@
 // RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/type_incomplete2.swift | %FileCheck %s -check-prefix=INCOMPLETE
 // RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/type_incomplete3.swift | %FileCheck %s -check-prefix=INCOMPLETE
 // RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/type_incomplete4.swift | %FileCheck %s -check-prefix=INCOMPLETE
+// RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/invalid_interpolation1.swift | %FileCheck %s -check-prefix=COMPLETE
+// RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/multi_line_string1.swift | %FileCheck %s -check-prefix=INCOMPLETE
+// RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/multi_line_string2.swift | %FileCheck %s -check-prefix=INCOMPLETE
+// RUN: %swift-ide-test -test-input-complete -source-filename %S/Inputs/multi_line_string3.swift | %FileCheck %s -check-prefix=INCOMPLETE
 
 // INCOMPLETE: IS_INCOMPLETE
 // COMPLETE: IS_COMPLETE
diff --git a/test/LLVMPasses/merge_func.ll b/test/LLVMPasses/merge_func.ll
index 7a9be33..0e3c021 100644
--- a/test/LLVMPasses/merge_func.ll
+++ b/test/LLVMPasses/merge_func.ll
@@ -200,6 +200,100 @@
 }
 
 
+; The same example as above, but we cannot merge func2 with func4, because
+; func4 calls func1 (which is merged with func2 in the first iteration).
+
+declare i32 @get_int(i32 %x)
+
+; CHECK-LABEL: define i32 @Function1_merged_with_3(i32 %x)
+; CHECK: %1 = tail call i32 @Function1_merged_with_3Tm(i32 %x, i32* @g1)
+; CHECK: ret i32 %1
+define i32 @Function1_merged_with_3(i32 %x) {
+  %l1 = load i32, i32* @g1, align 4
+  %sum = add i32 %x, %l1
+  %l2 = load i32, i32* @g2, align 4
+  %sum2 = add i32 %sum, %l2
+  %l3 = load i32, i32* @g3, align 4
+  %sum3 = add i32 %sum2, %l2
+  %l4 = load i32, i32* @g4, align 4
+  %sum4 = add i32 %sum3, %l2
+  %l5 = load i32, i32* @g5, align 4
+  %sum5 = add i32 %sum4, %l2
+  %c = call fastcc i32 @get_int(i32 %sum5)
+  ret i32 %c
+}
+
+; CHECK-LABEL: define i32 @Function2_not_merged(i32 %x)
+; CHECK: load
+; CHECK: load
+; CHECK: load
+; CHECK: load
+; CHECK: %c = call fastcc i32 @get_int
+; CHECK: ret i32 %c
+define i32 @Function2_not_merged(i32 %x) {
+  %l1 = load i32, i32* @g2, align 4
+  %sum = add i32 %x, %l1
+  %l2 = load i32, i32* @g3, align 4
+  %sum2 = add i32 %sum, %l2
+  %l3 = load i32, i32* @g4, align 4
+  %sum3 = add i32 %sum2, %l2
+  %l4 = load i32, i32* @g5, align 4
+  %sum4 = add i32 %sum3, %l2
+  %l5 = load i32, i32* @g1, align 4
+  %sum5 = add i32 %sum4, %l2
+  %c = call fastcc i32 @get_int(i32 %sum5)
+  ret i32 %c
+}
+
+; CHECK-LABEL: define i32 @Function3_merged_with_1(i32 %x)
+; CHECK: %1 = tail call i32 @Function1_merged_with_3Tm(i32 %x, i32* @g2)
+; CHECK: ret i32 %1
+define i32 @Function3_merged_with_1(i32 %x) {
+  %l1 = load i32, i32* @g2, align 4
+  %sum = add i32 %x, %l1
+  %l2 = load i32, i32* @g2, align 4
+  %sum2 = add i32 %sum, %l2
+  %l3 = load i32, i32* @g3, align 4
+  %sum3 = add i32 %sum2, %l2
+  %l4 = load i32, i32* @g4, align 4
+  %sum4 = add i32 %sum3, %l2
+  %l5 = load i32, i32* @g5, align 4
+  %sum5 = add i32 %sum4, %l2
+  %c = call fastcc i32 @get_int(i32 %sum5)
+  ret i32 %c
+}
+
+; CHECK-LABEL: define internal i32 @Function1_merged_with_3Tm(i32, i32*)
+; CHECK: load
+; CHECK: load
+; CHECK: load
+; CHECK: load
+; CHECK: %c = call fastcc i32 @get_int
+; CHECK: ret i32 %c
+
+; CHECK-LABEL: define i32 @Function4_not_merged(i32 %x) {
+; CHECK: load
+; CHECK: load
+; CHECK: load
+; CHECK: load
+; CHECK: %1 = call fastcc i32 @Function1_merged_with_3Tm(i32 %sum5, i32* @g1)
+; CHECK: ret i32 %1
+define i32 @Function4_not_merged(i32 %x) {
+  %l1 = load i32, i32* @g1, align 4
+  %sum = add i32 %x, %l1
+  %l2 = load i32, i32* @g3, align 4
+  %sum2 = add i32 %sum, %l2
+  %l3 = load i32, i32* @g4, align 4
+  %sum3 = add i32 %sum2, %l2
+  %l4 = load i32, i32* @g5, align 4
+  %sum4 = add i32 %sum3, %l2
+  %l5 = load i32, i32* @g1, align 4
+  %sum5 = add i32 %sum4, %l2
+  %c = call fastcc i32 @Function1_merged_with_3(i32 %sum5)
+  ret i32 %c
+}
+
+
 ; Test a call chain: caller -> callee1 -> callee2.
 ; Functions should be merged in bottom-up order: callee2, callee1, caller.
 ; Also check that the calling convention is preserved.
diff --git a/test/Serialization/function-default-args.swift b/test/Serialization/function-default-args.swift
new file mode 100644
index 0000000..a59e4a5
--- /dev/null
+++ b/test/Serialization/function-default-args.swift
@@ -0,0 +1,15 @@
+// RUN: %empty-directory(%t)
+// RUN: %target-swift-frontend -emit-module -o %t/Test~partial.swiftmodule -module-name Test -primary-file %s
+// RUN: %target-swift-frontend -merge-modules -emit-module -o %t/Test.swiftmodule %t/Test~partial.swiftmodule
+// RUN: %target-swift-ide-test -print-module -module-to-print=Test -source-filename=x -I %t | %FileCheck %s
+
+// CHECK-LABEL: func testDefaultArguments(
+public func testDefaultArguments(
+  // CHECK-SAME: normal: Int = 0
+  normal: Int = 0,
+  // CHECK-SAME: multiToken: Int = Int.max
+  multiToken: Int = Int.max,
+  // CHECK-SAME: special: Int = #line
+  special: Int = #line
+) {}
+// CHECK-SAME: )
\ No newline at end of file
diff --git a/test/SourceKit/CursorInfo/cursor_info.swift b/test/SourceKit/CursorInfo/cursor_info.swift
index 0079f77..1fac1a2 100644
--- a/test/SourceKit/CursorInfo/cursor_info.swift
+++ b/test/SourceKit/CursorInfo/cursor_info.swift
@@ -328,8 +328,8 @@
 
 // RUN: %sourcekitd-test -req=cursor -pos=31:7 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK13 %s
 // CHECK13: source.lang.swift.decl.function.free (31:6-31:37)
-// CHECK13: <Declaration>func testDefaultParam(arg1: <Type usr="s:Si">Int</Type> = default)</Declaration>
-// CHECK13: <decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>testDefaultParam</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>arg1</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr="s:Si">Int</ref.struct></decl.var.parameter.type> = <syntaxtype.keyword>default</syntaxtype.keyword></decl.var.parameter>)</decl.function.free>
+// CHECK13: <Declaration>func testDefaultParam(arg1: <Type usr="s:Si">Int</Type> = 0)</Declaration>
+// CHECK13: <decl.function.free><syntaxtype.keyword>func</syntaxtype.keyword> <decl.name>testDefaultParam</decl.name>(<decl.var.parameter><decl.var.parameter.argument_label>arg1</decl.var.parameter.argument_label>: <decl.var.parameter.type><ref.struct usr="s:Si">Int</ref.struct></decl.var.parameter.type> = 0</decl.var.parameter>)</decl.function.free>
 
 // RUN: %sourcekitd-test -req=cursor -pos=34:4 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck -check-prefix=CHECK14 %s
 // CHECK14: source.lang.swift.ref.function.free ({{.*}}Foo.framework/Frameworks/FooSub.framework/Headers/FooSub.h:4:5-4:16)
@@ -652,13 +652,11 @@
 // CHECK73-SAME: = <syntaxtype.keyword>#file</syntaxtype.keyword>
 // CHECK73-SAME: = <syntaxtype.keyword>#line</syntaxtype.keyword>
 // CHECK73-SAME: = <syntaxtype.keyword>#column</syntaxtype.keyword>
-// FIXME: []
-// CHECK73-SAME: = <syntaxtype.keyword>default</syntaxtype.keyword>
-// FIXME: [:]
-// CHECK73-SAME: = <syntaxtype.keyword>default</syntaxtype.keyword>
-// FIXME: keyword nil
-// CHECK73-SAME: = <syntaxtype.keyword>default</syntaxtype.keyword>
-// CHECK73-SAME: = <syntaxtype.keyword>default</syntaxtype.keyword>
+// CHECK73-SAME: = []
+// CHECK73-SAME: = [:]
+// FIXME: should be <syntaxtype.keyword>nil</syntaxtype.keyword>
+// CHECK73-SAME: = nil
+// CHECK73-SAME: = 1
 
 // RUN: %sourcekitd-test -req=cursor -pos=162:8 %s -- -F %S/../Inputs/libIDE-mock-sdk -I %t.tmp %mcp_opt %s | %FileCheck %s -check-prefix=CHECK74
 // CHECK74: source.lang.swift.decl.function.method.instance (162:8-162:20)
diff --git a/test/stdlib/TestJSONEncoder.swift b/test/stdlib/TestJSONEncoder.swift
index 8fe6a54..c01802e 100644
--- a/test/stdlib/TestJSONEncoder.swift
+++ b/test/stdlib/TestJSONEncoder.swift
@@ -479,7 +479,61 @@
     
     expectEqual(expected, resultString)
   }
-  
+
+  func testEncodingDictionaryStringKeyConversionUntouched() {
+    let expected = "{\"leaveMeAlone\":\"test\"}"
+    let toEncode: [String: String] = ["leaveMeAlone": "test"]
+
+    let encoder = JSONEncoder()
+    encoder.keyEncodingStrategy = .convertToSnakeCase
+    let resultData = try! encoder.encode(toEncode)
+    let resultString = String(bytes: resultData, encoding: .utf8)
+
+    expectEqual(expected, resultString)
+  }
+
+  private struct EncodeFailure : Encodable {
+    var someValue: Double
+  }
+
+  private struct EncodeFailureNested : Encodable {
+    var nestedValue: EncodeFailure
+  }
+
+  func testEncodingDictionaryFailureKeyPath() {
+    let toEncode: [String: EncodeFailure] = ["key": EncodeFailure(someValue: Double.nan)]
+
+    let encoder = JSONEncoder()
+    encoder.keyEncodingStrategy = .convertToSnakeCase
+    do {
+      _ = try encoder.encode(toEncode)
+    } catch EncodingError.invalidValue(let (_, context)) {
+      expectEqual(2, context.codingPath.count)
+      expectEqual("key", context.codingPath[0].stringValue)
+      expectEqual("someValue", context.codingPath[1].stringValue)
+    } catch {
+      expectUnreachable("Unexpected error: \(String(describing: error))")
+    }
+  }
+
+  func testEncodingDictionaryFailureKeyPathNested() {
+    let toEncode: [String: [String: EncodeFailureNested]] = ["key": ["sub_key": EncodeFailureNested(nestedValue: EncodeFailure(someValue: Double.nan))]]
+
+    let encoder = JSONEncoder()
+    encoder.keyEncodingStrategy = .convertToSnakeCase
+    do {
+      _ = try encoder.encode(toEncode)
+    } catch EncodingError.invalidValue(let (_, context)) {
+      expectEqual(4, context.codingPath.count)
+      expectEqual("key", context.codingPath[0].stringValue)
+      expectEqual("sub_key", context.codingPath[1].stringValue)
+      expectEqual("nestedValue", context.codingPath[2].stringValue)
+      expectEqual("someValue", context.codingPath[3].stringValue)
+    } catch {
+      expectUnreachable("Unexpected error: \(String(describing: error))")
+    }
+  }
+
   private struct EncodeNested : Encodable {
     let nestedValue: EncodeMe
   }
@@ -606,6 +660,54 @@
     
     expectEqual("test", result.hello)
   }
+
+  func testDecodingDictionaryStringKeyConversionUntouched() {
+    let input = "{\"leave_me_alone\":\"test\"}".data(using: .utf8)!
+    let decoder = JSONDecoder()
+    decoder.keyDecodingStrategy = .convertFromSnakeCase
+    let result = try! decoder.decode([String: String].self, from: input)
+
+    expectEqual(["leave_me_alone": "test"], result)
+  }
+
+  func testDecodingDictionaryFailureKeyPath() {
+    let input = "{\"leave_me_alone\":\"test\"}".data(using: .utf8)!
+    let decoder = JSONDecoder()
+    decoder.keyDecodingStrategy = .convertFromSnakeCase
+    do {
+      _ = try decoder.decode([String: Int].self, from: input)
+    } catch DecodingError.typeMismatch(let (_, context)) {
+      expectEqual(1, context.codingPath.count)
+      expectEqual("leave_me_alone", context.codingPath[0].stringValue)
+    } catch {
+      expectUnreachable("Unexpected error: \(String(describing: error))")
+    }
+  }
+
+  private struct DecodeFailure : Decodable {
+    var intValue: Int
+  }
+
+  private struct DecodeFailureNested : Decodable {
+    var nestedValue: DecodeFailure
+  }
+
+  func testDecodingDictionaryFailureKeyPathNested() {
+    let input = "{\"top_level\": {\"sub_level\": {\"nested_value\": {\"int_value\": \"not_an_int\"}}}}".data(using: .utf8)!
+    let decoder = JSONDecoder()
+    decoder.keyDecodingStrategy = .convertFromSnakeCase
+    do {
+      _ = try decoder.decode([String: [String : DecodeFailureNested]].self, from: input)
+    } catch DecodingError.typeMismatch(let (_, context)) {
+      expectEqual(4, context.codingPath.count)
+      expectEqual("top_level", context.codingPath[0].stringValue)
+      expectEqual("sub_level", context.codingPath[1].stringValue)
+      expectEqual("nestedValue", context.codingPath[2].stringValue)
+      expectEqual("intValue", context.codingPath[3].stringValue)
+    } catch {
+      expectUnreachable("Unexpected error: \(String(describing: error))")
+    }
+  }
   
   private struct DecodeMe3 : Codable {
       var thisIsCamelCase : String
@@ -1553,9 +1655,11 @@
 JSONEncoderTests.test("testEncodingNonConformingFloatStrings") { TestJSONEncoder().testEncodingNonConformingFloatStrings() }
 JSONEncoderTests.test("testEncodingKeyStrategySnake") { TestJSONEncoder().testEncodingKeyStrategySnake() }
 JSONEncoderTests.test("testEncodingKeyStrategyCustom") { TestJSONEncoder().testEncodingKeyStrategyCustom() }
+JSONEncoderTests.test("testEncodingDictionaryStringKeyConversionUntouched") { TestJSONEncoder().testEncodingDictionaryStringKeyConversionUntouched() }
 JSONEncoderTests.test("testEncodingKeyStrategyPath") { TestJSONEncoder().testEncodingKeyStrategyPath() }
 JSONEncoderTests.test("testDecodingKeyStrategyCamel") { TestJSONEncoder().testDecodingKeyStrategyCamel() }
 JSONEncoderTests.test("testDecodingKeyStrategyCustom") { TestJSONEncoder().testDecodingKeyStrategyCustom() }
+JSONEncoderTests.test("testDecodingDictionaryStringKeyConversionUntouched") { TestJSONEncoder().testDecodingDictionaryStringKeyConversionUntouched() }
 JSONEncoderTests.test("testEncodingKeyStrategySnakeGenerated") { TestJSONEncoder().testEncodingKeyStrategySnakeGenerated() }
 JSONEncoderTests.test("testDecodingKeyStrategyCamelGenerated") { TestJSONEncoder().testDecodingKeyStrategyCamelGenerated() }
 JSONEncoderTests.test("testKeyStrategySnakeGeneratedAndCustom") { TestJSONEncoder().testKeyStrategySnakeGeneratedAndCustom() }
@@ -1572,5 +1676,9 @@
 JSONEncoderTests.test("testDecoderStateThrowOnDecode") { TestJSONEncoder().testDecoderStateThrowOnDecode() }
 JSONEncoderTests.test("testDecoderStateThrowOnDecodeCustomDate") { TestJSONEncoder().testDecoderStateThrowOnDecodeCustomDate() }
 JSONEncoderTests.test("testDecoderStateThrowOnDecodeCustomData") { TestJSONEncoder().testDecoderStateThrowOnDecodeCustomData() }
+JSONEncoderTests.test("testEncodingDictionaryFailureKeyPath") { TestJSONEncoder().testEncodingDictionaryFailureKeyPath() }
+JSONEncoderTests.test("testEncodingDictionaryFailureKeyPathNested") { TestJSONEncoder().testEncodingDictionaryFailureKeyPathNested() }
+JSONEncoderTests.test("testDecodingDictionaryFailureKeyPath") { TestJSONEncoder().testDecodingDictionaryFailureKeyPath() }
+JSONEncoderTests.test("testDecodingDictionaryFailureKeyPathNested") { TestJSONEncoder().testDecodingDictionaryFailureKeyPathNested() }
 runAllTests()
 #endif
diff --git a/test/stmt/statements.swift b/test/stmt/statements.swift
index 5e593a9..fd0ae6f 100644
--- a/test/stmt/statements.swift
+++ b/test/stmt/statements.swift
@@ -207,9 +207,16 @@
 
 func IfStmt2() {
   if 1 > 0 {
-  } else // expected-error {{expected '{' after 'else'}}
+  } else // expected-error {{expected '{' or 'if' after 'else'}}
   _ = 42
 }
+func IfStmt3() {
+  if 1 > 0 {
+  } else 1 < 0 { // expected-error {{expected '{' or 'if' after 'else'; did you mean to write 'if'?}} {{9-9= if}}
+    _ = 42
+  } else {
+  }
+}
 
 //===--- While statement.
 
diff --git a/tools/SourceKit/CMakeLists.txt b/tools/SourceKit/CMakeLists.txt
index bf6cade..57d546c 100644
--- a/tools/SourceKit/CMakeLists.txt
+++ b/tools/SourceKit/CMakeLists.txt
@@ -92,67 +92,6 @@
 
 if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
   set(SOURCEKIT_DEFAULT_TARGET_SDK "LINUX")
-  if(SWIFT_BUILD_SOURCEKIT)
-    include(ExternalProject)
-    ExternalProject_Add(libdispatch
-                        SOURCE_DIR
-                          "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}"
-                        BINARY_DIR
-                          "${SWIFT_PATH_TO_LIBDISPATCH_BUILD}"
-                        CMAKE_ARGS
-                          -DCMAKE_C_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang
-                          -DCMAKE_CXX_COMPILER=${PATH_TO_CLANG_BUILD}/bin/clang++
-                          -DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-                          -DCMAKE_SWIFT_COMPILER=$<TARGET_FILE:swift>c
-                          -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-                          -DENABLE_SWIFT=YES
-                        BUILD_BYPRODUCTS
-                          ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/${CMAKE_SHARED_LIBRARY_PREFIX}dispatch${CMAKE_SHARED_LIBRARY_SUFFIX}
-                          ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/${CMAKE_STATIC_LIBRARY_PREFIX}BlocksRuntime${CMAKE_STATIC_LIBRARY_SUFFIX}
-                        STEP_TARGETS
-                          configure
-                        BUILD_ALWAYS
-                          1)
-
-    # CMake does not like the addition of INTERFACE_INCLUDE_DIRECTORIES without
-    # the directory existing.  Just create the location which will be populated
-    # during the installation.
-    ExternalProject_Get_Property(libdispatch install_dir)
-    file(MAKE_DIRECTORY ${install_dir}/include)
-
-    # TODO(compnerd) this should be taken care of by the
-    # INTERFACE_INCLUDE_DIRECTORIES below
-    include_directories(AFTER
-                          ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/src/BlocksRuntime
-                          ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE})
-    add_dependencies(libdispatch
-                       swift
-                       copy_shim_headers
-                       swiftCore-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}
-                       swiftSwiftOnoneSupport-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}
-                       swiftCore-swiftmodule-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH}
-                       swiftSwiftOnoneSupport-swiftmodule-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH})
-  endif()
-
-  ExternalProject_Get_Property(libdispatch install_dir)
-  add_library(dispatch SHARED IMPORTED)
-  set_target_properties(dispatch
-                        PROPERTIES
-                          IMPORTED_LOCATION
-                            ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/src/${CMAKE_SHARED_LIBRARY_PREFIX}dispatch${CMAKE_SHARED_LIBRARY_SUFFIX}
-                          INTERFACE_INCLUDE_DIRECTORIES
-                            ${install_dir}/include
-                          IMPORTED_LINK_INTERFACE_LIBRARIES
-                            swiftCore-${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_LIB_SUBDIR}-${SWIFT_HOST_VARIANT_ARCH})
-
-  add_library(BlocksRuntime STATIC IMPORTED)
-  set_target_properties(BlocksRuntime
-                        PROPERTIES
-                          IMPORTED_LOCATION
-                            ${SWIFT_PATH_TO_LIBDISPATCH_BUILD}/${CMAKE_STATIC_LIBRARY_PREFIX}BlocksRuntime${CMAKE_STATIC_LIBRARY_SUFFIX}
-                          INTERFACE_INCLUDE_DIRECTORIES
-                            ${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}/src/BlocksRuntime)
-
   set(SOURCEKIT_NEED_EXPLICIT_LIBDISPATCH TRUE)
 endif()
 
diff --git a/tools/SwiftSyntax/SyntaxClassifier.swift.gyb b/tools/SwiftSyntax/SyntaxClassifier.swift.gyb
index 006ed3f..42487fa 100644
--- a/tools/SwiftSyntax/SyntaxClassifier.swift.gyb
+++ b/tools/SwiftSyntax/SyntaxClassifier.swift.gyb
@@ -28,7 +28,7 @@
 % end
 }
 
-class _SyntaxClassifier: SyntaxVisitor {
+fileprivate class _SyntaxClassifier: SyntaxVisitor {
 
   /// Don't classify nodes with these IDs or any of their children
   var skipNodeIds: Set<SyntaxNodeId> = []
@@ -71,6 +71,9 @@
   }
 
   override func visit(_ token: TokenSyntax) {
+    // FIXME: We need to come up with some way in which the SyntaxClassifier can
+    // classify trivia (i.e. comments). In particular we need to be able to
+    // look into the comments to find things like URLs or keywords like MARK.
     var classification = contextStack.last!.classification
     if !contextStack.last!.force {
       if let contextFreeClassification = 
@@ -84,7 +87,8 @@
         classification = .editorPlaceholder
       }
     }
-    assert(classifications[token] == nil)
+    assert(classifications[token] == nil,
+           "\(token) has already been classified")
     classifications[token] = classification
   }
 
diff --git a/tools/swift-swiftsyntax-test/CMakeLists.txt b/tools/swift-swiftsyntax-test/CMakeLists.txt
index 7268ede..16f7c22 100644
--- a/tools/swift-swiftsyntax-test/CMakeLists.txt
+++ b/tools/swift-swiftsyntax-test/CMakeLists.txt
@@ -1,16 +1,7 @@
-macro(add_swift_module_depends results target)
-  list(APPEND ${results} "${target}-macosx")
-  list(APPEND ${results} "${target}-macosx-x86_64")
-  list(APPEND ${results} "${target}-swiftmodule-macosx-x86_64")
-endmacro()
-
-add_swift_module_depends(all_depends swiftTestUtils)
-add_swift_module_depends(all_depends swiftSwiftSyntax)
-
 add_swift_host_tool(swift-swiftsyntax-test
   main.swift
   ClassifiedSyntaxTreePrinter.swift
   empty.c # FIXME: If there is no C file in the target Xcode skips the linking phase and doesn't create the executable
   COMPILE_FLAGS "-module-name" "main"
-  DEPENDS ${all_depends}
+  SWIFT_MODULE_DEPENDS TestUtils SwiftSyntax
 )
diff --git a/tools/swift-swiftsyntax-test/ClassifiedSyntaxTreePrinter.swift b/tools/swift-swiftsyntax-test/ClassifiedSyntaxTreePrinter.swift
index cc2382c..9fa3bdb 100644
--- a/tools/swift-swiftsyntax-test/ClassifiedSyntaxTreePrinter.swift
+++ b/tools/swift-swiftsyntax-test/ClassifiedSyntaxTreePrinter.swift
@@ -1,85 +1,9 @@
 import SwiftSyntax
 import Foundation
 
-class ClassifiedSyntaxTreePrinter: SyntaxVisitor {
-  private let classifications: [TokenSyntax: SyntaxClassification]
-  private var currentTag = ""
-  private var skipNextNewline = false
-  private var result = ""
-
-  // MARK: Public interface
-
-  init(classifications: [TokenSyntax: SyntaxClassification]) {
-    self.classifications = classifications
-  }
-
-  func print(tree: SourceFileSyntax) -> String {
-    result = ""
-    visit(tree)
-    // Emit the last closing tag
-    recordCurrentTag("")
-    return result
-  }
-
-  // MARK: Implementation
-
-  /// Closes the current tag if it is different from the previous one and opens
-  /// a tag with the specified ID.
-  private func recordCurrentTag(_ tag: String) {
-    if currentTag != tag {
-      if !currentTag.isEmpty {
-        result += "</" + currentTag + ">"
-      }
-      if !tag.isEmpty {
-        result += "<" + tag + ">"
-      }
-    }
-    currentTag = tag
-  }
-
-  private func visit(_ piece: TriviaPiece) {
-    let tag: String
-    switch piece {
-    case .spaces, .tabs, .verticalTabs, .formfeeds:
-      tag = ""
-    case .newlines, .carriageReturns, .carriageReturnLineFeeds:
-      if skipNextNewline {
-        skipNextNewline = false
-        return
-      }
-      tag = ""
-    case .backticks:
-      tag = ""
-    case .lineComment(let text):
-      // Don't print CHECK lines
-      if text.hasPrefix("// CHECK") {
-        skipNextNewline = true
-        return
-      }
-      tag = "comment-line"
-    case .blockComment:
-      tag = "comment-block"
-    case .docLineComment:
-      tag = "doc-comment-line"
-    case .docBlockComment:
-      tag = "doc-comment-block"
-    case .garbageText:
-      tag = ""
-    }
-    recordCurrentTag(tag)
-    piece.write(to: &result)
-  }
-
-  private func visit(_ trivia: Trivia) {
-    for piece in trivia {
-      visit(piece)
-    }
-  }
-
-  private func getTagForSyntaxClassification(
-    _ classification: SyntaxClassification
-  ) -> String {
-    switch (classification) {
+extension SyntaxClassification {
+  var tag: String {
+    switch self {
     case .none: return ""
     case .keyword: return "kw"
     case .identifier: return ""
@@ -94,13 +18,95 @@
     case .attribute: return "attr-builtin"
     case .objectLiteral: return "object-literal"
     case .editorPlaceholder: return "placeholder"
+    case .lineComment: return "comment-line"
+    case .blockComment: return "comment-block"
+    case .docLineComment: return "doc-comment-line"
+    case .docBlockComment: return "doc-comment-block"
+    }
+  }
+}
+
+class ClassifiedSyntaxTreePrinter: SyntaxVisitor {
+  private let classifications: [TokenSyntax: SyntaxClassification]
+  private var currentClassification = SyntaxClassification.none
+  private var skipNextNewline = false
+  private var result = ""
+
+  // MARK: Public interface
+
+  init(classifications: [TokenSyntax: SyntaxClassification]) {
+    self.classifications = classifications
+  }
+
+  func print(tree: SourceFileSyntax) -> String {
+    result = ""
+    visit(tree)
+    // Emit the last closing tag
+    recordCurrentClassification(.none)
+    return result
+  }
+
+  // MARK: Implementation
+
+  /// Closes the current tag if it is different from the previous one and opens
+  /// a tag with the specified ID.
+  private func recordCurrentClassification(
+    _ classification: SyntaxClassification
+  ) {
+    if currentClassification != classification {
+      if currentClassification != .none {
+        result += "</" + currentClassification.tag + ">"
+      }
+      if classification != .none {
+        result += "<" + classification.tag + ">"
+      }
+    }
+    currentClassification = classification
+  }
+
+  private func visit(_ piece: TriviaPiece) {
+    let classification: SyntaxClassification
+    switch piece {
+    case .spaces, .tabs, .verticalTabs, .formfeeds:
+      classification = .none
+    case .newlines, .carriageReturns, .carriageReturnLineFeeds:
+      if skipNextNewline {
+        skipNextNewline = false
+        return
+      }
+      classification = .none
+    case .backticks:
+      classification = .none
+    case .lineComment(let text):
+      // Don't print CHECK lines
+      if text.hasPrefix("// CHECK") {
+        skipNextNewline = true
+        return
+      }
+      classification = .lineComment
+    case .blockComment:
+      classification = .blockComment
+    case .docLineComment:
+      classification = .docLineComment
+    case .docBlockComment:
+      classification = .docBlockComment
+    case .garbageText:
+      classification = .none
+    }
+    recordCurrentClassification(classification)
+    piece.write(to: &result)
+  }
+
+  private func visit(_ trivia: Trivia) {
+    for piece in trivia {
+      visit(piece)
     }
   }
 
   override func visit(_ node: TokenSyntax) {
     visit(node.leadingTrivia)
     let classification = classifications[node] ?? SyntaxClassification.none
-    recordCurrentTag(getTagForSyntaxClassification(classification))
+    recordCurrentClassification(classification)
     result += node.text
     visit(node.trailingTrivia)
   }
diff --git a/utils/build-script-impl b/utils/build-script-impl
index 43433aa..ac1f644 100755
--- a/utils/build-script-impl
+++ b/utils/build-script-impl
@@ -1762,6 +1762,7 @@
         OBJROOT="${lldb_build_dir}"
         -UseNewBuildSystem=NO
         ${LLDB_EXTRA_XCODEBUILD_ARGS}
+        MACOSX_DEPLOYMENT_TARGET=10.13
     )
     if [[ "${LLDB_NO_DEBUGSERVER}" ]] ; then
         lldb_xcodebuild_options=(
diff --git a/utils/gyb_syntax_support/Classification.py b/utils/gyb_syntax_support/Classification.py
index 03b1b63..17593ab 100644
--- a/utils/gyb_syntax_support/Classification.py
+++ b/utils/gyb_syntax_support/Classification.py
@@ -56,6 +56,18 @@
     SyntaxClassification('EditorPlaceholder', description='''
     An editor placeholder of the form `<#content#>`
     '''),
+    SyntaxClassification('LineComment', description='''
+    A line comment starting with `//`.
+    '''),
+    SyntaxClassification('DocLineComment', description='''
+    A doc line comment starting with `///`.
+    '''),
+    SyntaxClassification('BlockComment', description='''
+    A block comment starting with `/**` and ending with `*/.
+    '''),
+    SyntaxClassification('DocBlockComment', description='''
+    A doc block comment starting with `/**` and ending with `*/.
+    '''),
 ]
 
 
diff --git a/validation-test/Reflection/existentials.swift b/validation-test/Reflection/existentials.swift
index 3d65ef7..a08dbd5 100644
--- a/validation-test/Reflection/existentials.swift
+++ b/validation-test/Reflection/existentials.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/existentials
+// RUN: %target-codesign %t/existentials
 // RUN: %target-run %target-swift-reflection-test %t/existentials | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/functions.swift b/validation-test/Reflection/functions.swift
index e349438..91eb256 100644
--- a/validation-test/Reflection/functions.swift
+++ b/validation-test/Reflection/functions.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/functions
+// RUN: %target-codesign %t/functions
 // RUN: %target-run %target-swift-reflection-test %t/functions | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
 
 // FIXME: Should not require objc_interop -- please put Objective-C-specific
diff --git a/validation-test/Reflection/functions_objc.swift b/validation-test/Reflection/functions_objc.swift
index 8e05508..63cdc1d 100644
--- a/validation-test/Reflection/functions_objc.swift
+++ b/validation-test/Reflection/functions_objc.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/functions
+// RUN: %target-codesign %t/functions
 // RUN: %target-run %target-swift-reflection-test %t/functions | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/inherits_NSObject.swift b/validation-test/Reflection/inherits_NSObject.swift
index 208d301..0e2b21a 100644
--- a/validation-test/Reflection/inherits_NSObject.swift
+++ b/validation-test/Reflection/inherits_NSObject.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/inherits_NSObject
+// RUN: %target-codesign %t/inherits_NSObject
 // RUN: %target-run %target-swift-reflection-test %t/inherits_NSObject | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
 
 // REQUIRES: objc_interop
diff --git a/validation-test/Reflection/inherits_ObjCClasses.swift b/validation-test/Reflection/inherits_ObjCClasses.swift
index 8b569c9..f67b0ec 100644
--- a/validation-test/Reflection/inherits_ObjCClasses.swift
+++ b/validation-test/Reflection/inherits_ObjCClasses.swift
@@ -2,6 +2,7 @@
 
 // RUN: %clang %target-cc-options -isysroot %sdk -fobjc-arc %S/Inputs/ObjCClasses/ObjCClasses.m -c -o %t/ObjCClasses.o
 // RUN: %target-build-swift -I %S/Inputs/ObjCClasses/ -lswiftSwiftReflectionTest %t/ObjCClasses.o %s -o %t/inherits_ObjCClasses
+// RUN: %target-codesign %t/inherits_ObjCClasses
 // RUN: %target-run %target-swift-reflection-test %t/inherits_ObjCClasses | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
 
 // REQUIRES: objc_interop
diff --git a/validation-test/Reflection/inherits_Swift.swift b/validation-test/Reflection/inherits_Swift.swift
index 7b0aa77..70b058f 100644
--- a/validation-test/Reflection/inherits_Swift.swift
+++ b/validation-test/Reflection/inherits_Swift.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/inherits_Swift
+// RUN: %target-codesign %t/inherits_Swift
 // RUN: %target-run %target-swift-reflection-test %t/inherits_Swift | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
 
 // REQUIRES: objc_interop
diff --git a/validation-test/Reflection/reflect_Array.swift b/validation-test/Reflection/reflect_Array.swift
index 01996e3..164ba6f 100644
--- a/validation-test/Reflection/reflect_Array.swift
+++ b/validation-test/Reflection/reflect_Array.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Array
+// RUN: %target-codesign %t/reflect_Array
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Array 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Bool.swift b/validation-test/Reflection/reflect_Bool.swift
index 7f0fe57..333d576 100644
--- a/validation-test/Reflection/reflect_Bool.swift
+++ b/validation-test/Reflection/reflect_Bool.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Bool
+// RUN: %target-codesign %t/reflect_Bool
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Bool 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Character.swift b/validation-test/Reflection/reflect_Character.swift
index 8e47cf0..97f8286 100644
--- a/validation-test/Reflection/reflect_Character.swift
+++ b/validation-test/Reflection/reflect_Character.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Character
+// RUN: %target-codesign %t/reflect_Character
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Character 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Dictionary.swift b/validation-test/Reflection/reflect_Dictionary.swift
index 5a33cdf..cadbd3c 100644
--- a/validation-test/Reflection/reflect_Dictionary.swift
+++ b/validation-test/Reflection/reflect_Dictionary.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Dictionary
+// RUN: %target-codesign %t/reflect_Dictionary
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Dictionary 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Double.swift b/validation-test/Reflection/reflect_Double.swift
index f95deee..2d311ad 100644
--- a/validation-test/Reflection/reflect_Double.swift
+++ b/validation-test/Reflection/reflect_Double.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Double
+// RUN: %target-codesign %t/reflect_Double
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Double 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Float.swift b/validation-test/Reflection/reflect_Float.swift
index fec3513..9b520f9 100644
--- a/validation-test/Reflection/reflect_Float.swift
+++ b/validation-test/Reflection/reflect_Float.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Float
+// RUN: %target-codesign %t/reflect_Float
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Float 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Int.swift b/validation-test/Reflection/reflect_Int.swift
index 056943b..d7227b8 100644
--- a/validation-test/Reflection/reflect_Int.swift
+++ b/validation-test/Reflection/reflect_Int.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Int
+// RUN: %target-codesign %t/reflect_Int
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Int 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Int16.swift b/validation-test/Reflection/reflect_Int16.swift
index 3818d73..ed5bdd8 100644
--- a/validation-test/Reflection/reflect_Int16.swift
+++ b/validation-test/Reflection/reflect_Int16.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Int16
+// RUN: %target-codesign %t/reflect_Int16
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Int16 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Int32.swift b/validation-test/Reflection/reflect_Int32.swift
index 26da3ae..3723c0a 100644
--- a/validation-test/Reflection/reflect_Int32.swift
+++ b/validation-test/Reflection/reflect_Int32.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Int32
+// RUN: %target-codesign %t/reflect_Int32
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Int32 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Int64.swift b/validation-test/Reflection/reflect_Int64.swift
index 9ef651c..7bc2ab8 100644
--- a/validation-test/Reflection/reflect_Int64.swift
+++ b/validation-test/Reflection/reflect_Int64.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Int64
+// RUN: %target-codesign %t/reflect_Int64
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Int64 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Int8.swift b/validation-test/Reflection/reflect_Int8.swift
index fd8db13..a31e802 100644
--- a/validation-test/Reflection/reflect_Int8.swift
+++ b/validation-test/Reflection/reflect_Int8.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Int8
+// RUN: %target-codesign %t/reflect_Int8
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Int8 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_NSArray.swift b/validation-test/Reflection/reflect_NSArray.swift
index f0d735a..d500823 100644
--- a/validation-test/Reflection/reflect_NSArray.swift
+++ b/validation-test/Reflection/reflect_NSArray.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_NSArray
+// RUN: %target-codesign %t/reflect_NSArray
 // RUN: %target-run %target-swift-reflection-test %t/reflect_NSArray 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_NSNumber.swift b/validation-test/Reflection/reflect_NSNumber.swift
index e80fd09..17885db 100644
--- a/validation-test/Reflection/reflect_NSNumber.swift
+++ b/validation-test/Reflection/reflect_NSNumber.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_NSNumber
+// RUN: %target-codesign %t/reflect_NSNumber
 // RUN: %target-run %target-swift-reflection-test %t/reflect_NSNumber 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_NSSet.swift b/validation-test/Reflection/reflect_NSSet.swift
index 5704edb..52cafe1 100644
--- a/validation-test/Reflection/reflect_NSSet.swift
+++ b/validation-test/Reflection/reflect_NSSet.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_NSSet
+// RUN: %target-codesign %t/reflect_NSSet
 // RUN: %target-run %target-swift-reflection-test %t/reflect_NSSet 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_NSString.swift b/validation-test/Reflection/reflect_NSString.swift
index ab8fa0c..d2a884b 100644
--- a/validation-test/Reflection/reflect_NSString.swift
+++ b/validation-test/Reflection/reflect_NSString.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_NSString
+// RUN: %target-codesign %t/reflect_NSString
 // RUN: %target-run %target-swift-reflection-test %t/reflect_NSString 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_Set.swift b/validation-test/Reflection/reflect_Set.swift
index 267bd21..4f665f6 100644
--- a/validation-test/Reflection/reflect_Set.swift
+++ b/validation-test/Reflection/reflect_Set.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_Set
+// RUN: %target-codesign %t/reflect_Set
 // RUN: %target-run %target-swift-reflection-test %t/reflect_Set 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_String.swift b/validation-test/Reflection/reflect_String.swift
index 5193fc0..eee3890 100644
--- a/validation-test/Reflection/reflect_String.swift
+++ b/validation-test/Reflection/reflect_String.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_String
+// RUN: %target-codesign %t/reflect_String
 // RUN: %target-run %target-swift-reflection-test %t/reflect_String 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_UInt.swift b/validation-test/Reflection/reflect_UInt.swift
index 94309fb..9ad6197 100644
--- a/validation-test/Reflection/reflect_UInt.swift
+++ b/validation-test/Reflection/reflect_UInt.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_UInt
+// RUN: %target-codesign %t/reflect_UInt
 // RUN: %target-run %target-swift-reflection-test %t/reflect_UInt 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_UInt16.swift b/validation-test/Reflection/reflect_UInt16.swift
index d7ec13b..00ce71b 100644
--- a/validation-test/Reflection/reflect_UInt16.swift
+++ b/validation-test/Reflection/reflect_UInt16.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_UInt16
+// RUN: %target-codesign %t/reflect_UInt16
 // RUN: %target-run %target-swift-reflection-test %t/reflect_UInt16 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_UInt32.swift b/validation-test/Reflection/reflect_UInt32.swift
index 5123abd..0de29a0 100644
--- a/validation-test/Reflection/reflect_UInt32.swift
+++ b/validation-test/Reflection/reflect_UInt32.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_UInt32
+// RUN: %target-codesign %t/reflect_UInt32
 // RUN: %target-run %target-swift-reflection-test %t/reflect_UInt32 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_UInt64.swift b/validation-test/Reflection/reflect_UInt64.swift
index 6e672df..801b6d7 100644
--- a/validation-test/Reflection/reflect_UInt64.swift
+++ b/validation-test/Reflection/reflect_UInt64.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_UInt64
+// RUN: %target-codesign %t/reflect_UInt64
 // RUN: %target-run %target-swift-reflection-test %t/reflect_UInt64 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_UInt8.swift b/validation-test/Reflection/reflect_UInt8.swift
index 4f94618..530d539 100644
--- a/validation-test/Reflection/reflect_UInt8.swift
+++ b/validation-test/Reflection/reflect_UInt8.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_UInt8
+// RUN: %target-codesign %t/reflect_UInt8
 // RUN: %target-run %target-swift-reflection-test %t/reflect_UInt8 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_empty_class.swift b/validation-test/Reflection/reflect_empty_class.swift
index 6c54d94..973851b 100644
--- a/validation-test/Reflection/reflect_empty_class.swift
+++ b/validation-test/Reflection/reflect_empty_class.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_empty_class
+// RUN: %target-codesign %t/reflect_empty_class
 // RUN: %target-run %target-swift-reflection-test %t/reflect_empty_class 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_existential.swift b/validation-test/Reflection/reflect_existential.swift
index a871580..d9b0b05 100644
--- a/validation-test/Reflection/reflect_existential.swift
+++ b/validation-test/Reflection/reflect_existential.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_existential
+// RUN: %target-codesign %t/reflect_existential
 // RUN: %target-run %target-swift-reflection-test %t/reflect_existential 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test
diff --git a/validation-test/Reflection/reflect_multiple_types.swift b/validation-test/Reflection/reflect_multiple_types.swift
index ecd7fd5..22da6ee 100644
--- a/validation-test/Reflection/reflect_multiple_types.swift
+++ b/validation-test/Reflection/reflect_multiple_types.swift
@@ -1,5 +1,6 @@
 // RUN: %empty-directory(%t)
 // RUN: %target-build-swift -lswiftSwiftReflectionTest %s -o %t/reflect_multiple_types
+// RUN: %target-codesign %t/reflect_multiple_types
 // RUN: %target-run %target-swift-reflection-test %t/reflect_multiple_types 2>&1 | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
 // REQUIRES: objc_interop
 // REQUIRES: executable_test