Merge pull request #2379 from rudkx/unreachable
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 21b33e8..85c5fa5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,10 @@
 Swift 3.0
 ---------
 
+* [SE-0071](https://github.com/apple/swift-evolution/blob/master/proposals/0071-member-keywords.md):
+  "Allow (most) keywords in member references" is implemented.  This allows the
+  use of members after a dot without backticks, e.g. "foo.default".
+
 * [SE-0057](https://github.com/apple/swift-evolution/blob/master/proposals/0057-importing-objc-generics.md):
   Objective-C lightweight generic classes are now imported as generic types
   in Swift. Because Objective-C generics are not represented at runtime,
diff --git a/docs/ABI.rst b/docs/ABI.rst
index 0d60748..5d45518 100644
--- a/docs/ABI.rst
+++ b/docs/ABI.rst
@@ -935,6 +935,7 @@
   type ::= 'Xw' type                         // @weak type
   type ::= 'XF' impl-function-type           // function implementation type
   type ::= 'Xf' type type                    // @thin function type
+  type ::= 'Xb' type                         // SIL @box type
   nominal-type ::= known-nominal-type
   nominal-type ::= substitution
   nominal-type ::= nominal-type-kind declaration-name
diff --git a/include/swift/Parse/Parser.h b/include/swift/Parse/Parser.h
index 8e4f905..71b8852 100644
--- a/include/swift/Parse/Parser.h
+++ b/include/swift/Parse/Parser.h
@@ -1124,11 +1124,11 @@
   ///     identifier
   ///     identifier '(' ((identifier | '_') ':') + ')'
   ///
-  ///
-  /// \param allowInit Whether to allow 'init' for initializers.
+  /// \param afterDot Whether this identifier is coming after a period, which
+  /// enables '.init' and '.default' like expressions.
   /// \param loc Will be populated with the location of the name.
   /// \param diag The diagnostic to emit if this is not a name.
-  DeclName parseUnqualifiedDeclName(bool allowInit, DeclNameLoc &loc,
+  DeclName parseUnqualifiedDeclName(bool afterDot, DeclNameLoc &loc,
                                     const Diagnostic &diag);
 
   Expr *parseExprIdentifier();
diff --git a/include/swift/Reflection/TypeRef.h b/include/swift/Reflection/TypeRef.h
index 7eac923..8d676cf 100644
--- a/include/swift/Reflection/TypeRef.h
+++ b/include/swift/Reflection/TypeRef.h
@@ -703,6 +703,33 @@
   }
 };
 
+class SILBoxTypeRef final : public TypeRef {
+  const TypeRef *BoxedType;
+
+  static TypeRefID Profile(const TypeRef *BoxedType) {
+    TypeRefID ID;
+    ID.addPointer(BoxedType);
+    return ID;
+  }
+public:
+  SILBoxTypeRef(const TypeRef *BoxedType)
+    : TypeRef(TypeRefKind::SILBox), BoxedType(BoxedType) {}
+
+  template <typename Allocator>
+  static const SILBoxTypeRef *create(Allocator &A,
+                                     const TypeRef *BoxedType) {
+    FIND_OR_CREATE_TYPEREF(A, SILBoxTypeRef, BoxedType);
+  }
+
+  const TypeRef *getBoxedType() const {
+    return BoxedType;
+  }
+
+  static bool classof(const TypeRef *TR) {
+    return TR->getKind() == TypeRefKind::SILBox;
+  }
+};
+
 template <typename ImplClass, typename RetTy = void, typename... Args>
 class TypeRefVisitor {
 public:
diff --git a/include/swift/Reflection/TypeRefBuilder.h b/include/swift/Reflection/TypeRefBuilder.h
index 0758764..f90116c 100644
--- a/include/swift/Reflection/TypeRefBuilder.h
+++ b/include/swift/Reflection/TypeRefBuilder.h
@@ -229,6 +229,10 @@
     return WeakStorageTypeRef::create(*this, base);
   }
 
+  const SILBoxTypeRef *createSILBoxType(const TypeRef *base) {
+    return SILBoxTypeRef::create(*this, base);
+  }
+
   const ObjCClassTypeRef *
   createObjCClassType(const std::string &mangledName) {
     return ObjCClassTypeRef::create(*this, mangledName);
diff --git a/include/swift/Reflection/TypeRefs.def b/include/swift/Reflection/TypeRefs.def
index 404a173..340bfa1 100644
--- a/include/swift/Reflection/TypeRefs.def
+++ b/include/swift/Reflection/TypeRefs.def
@@ -33,5 +33,6 @@
 TYPEREF(UnownedStorage, TypeRef)
 TYPEREF(UnmanagedStorage, TypeRef)
 TYPEREF(WeakStorage, TypeRef)
+TYPEREF(SILBox, TypeRef)
 
 #undef TYPEREF
diff --git a/include/swift/Remote/MetadataReader.h b/include/swift/Remote/MetadataReader.h
index bcff873..f5d31ff 100644
--- a/include/swift/Remote/MetadataReader.h
+++ b/include/swift/Remote/MetadataReader.h
@@ -243,6 +243,12 @@
         return BuiltType();
       return Builder.createWeakStorageType(base);
     }
+    case NodeKind::SILBoxType: {
+      auto base = decodeMangledType(Node->getChild(0));
+      if (!base)
+        return BuiltType();
+      return Builder.createSILBoxType(base);
+    }
     default:
       return BuiltType();
     }
diff --git a/lib/IRGen/GenClangType.cpp b/lib/IRGen/GenClangType.cpp
index 5f8bba0..9a43383 100644
--- a/lib/IRGen/GenClangType.cpp
+++ b/lib/IRGen/GenClangType.cpp
@@ -225,6 +225,30 @@
   return Converter.reverseBuiltinTypeMapping(IGM, type);
 }
 
+static clang::CanQualType getClangBuiltinTypeFromTypedef(
+                      const clang::ASTContext &context, StringRef typedefName) {
+  auto identifier = &context.Idents.get(typedefName);
+  auto lookup = context.getTranslationUnitDecl()->lookup(identifier);
+  
+  clang::TypedefDecl *typedefDecl = nullptr;
+  for (auto found : lookup) {
+    auto foundTypedef = dyn_cast<clang::TypedefDecl>(found);
+    if (!foundTypedef)
+      continue;
+    typedefDecl = foundTypedef;
+    break;
+  }
+  if (!typedefDecl)
+    return {};
+  
+  auto underlyingTy =
+    context.getCanonicalType(typedefDecl->getUnderlyingType());
+  
+  if (underlyingTy->getAs<clang::BuiltinType>())
+    return underlyingTy;
+  return {};
+}
+
 clang::CanQualType
 ClangTypeConverter::reverseBuiltinTypeMapping(IRGenModule &IGM,
                                               CanStructType type) {
@@ -260,6 +284,22 @@
                              clang::BuiltinType::Kind builtinKind) {
     CanType swiftType = getNamedSwiftType(stdlib, swiftName);
     if (!swiftType) return;
+    
+    // Handle Int and UInt specially. On Apple platforms, these correspond to
+    // the NSInteger and NSUInteger typedefs, so map them back to those typedefs
+    // if they're available, to ensure we get consistent ObjC @encode strings.
+    if (swiftType->getAnyNominal() == IGM.Context.getIntDecl()) {
+      if (auto NSIntegerTy = getClangBuiltinTypeFromTypedef(ctx, "NSInteger")) {
+        Cache.insert({swiftType, NSIntegerTy});
+        return;
+      }
+    } else if (swiftType->getAnyNominal() == IGM.Context.getUIntDecl()) {
+      if (auto NSUIntegerTy =
+            getClangBuiltinTypeFromTypedef(ctx, "NSUInteger")) {
+        Cache.insert({swiftType, NSUIntegerTy});
+        return;
+      }
+    }
 
     Cache.insert({swiftType, getClangBuiltinTypeFromKind(ctx, builtinKind)});
   };
diff --git a/lib/Parse/ParseExpr.cpp b/lib/Parse/ParseExpr.cpp
index 1011d94..d4bba55 100644
--- a/lib/Parse/ParseExpr.cpp
+++ b/lib/Parse/ParseExpr.cpp
@@ -685,9 +685,7 @@
     }
 
     DeclNameLoc nameLoc;
-    DeclName name = parseUnqualifiedDeclName(
-                      /*allowInit=*/true,
-                      nameLoc,
+    DeclName name = parseUnqualifiedDeclName(/*afterDot=*/true, nameLoc,
                       diag::expected_identifier_after_super_dot_expr);
     if (!name)
       return nullptr;
@@ -894,7 +892,7 @@
 ///
 ///   expr-dot:
 ///     expr-postfix '.' 'type'
-///     expr-postfix '.' identifier generic-args? expr-call-suffix?
+///     expr-postfix '.' (identifier|keyword) generic-args? expr-call-suffix?
 ///     expr-postfix '.' integer_literal
 ///
 ///   expr-subscript:
@@ -1109,7 +1107,7 @@
       return Result;
     }
 
-    Name = parseUnqualifiedDeclName(/*allowInit=*/true, NameLoc, 
+    Name = parseUnqualifiedDeclName(/*afterDot=*/true, NameLoc,
                                     diag::expected_identifier_after_dot_expr);
     if (!Name) return nullptr;
 
@@ -1250,95 +1248,88 @@
     // Check for a .foo suffix.
     SourceLoc TokLoc = Tok.getLoc();
     if (consumeIf(tok::period) || consumeIf(tok::period_prefix)) {
-      // Non-identifier cases.
-      if (Tok.isNot(tok::identifier) && Tok.isNot(tok::integer_literal) &&
-          Tok.isNot(tok::kw_init)) {
-        // A metatype expr.
-        if (Tok.is(tok::kw_dynamicType)) {
-          Result = makeParserResult(
-            new (Context) DynamicTypeExpr(Result.get(), consumeToken(),
-                                       Type()));
-          continue;
-        }
-        
-        // A '.self' expr.
-        if (Tok.is(tok::kw_self)) {
-          Result = makeParserResult(
-            new (Context) DotSelfExpr(Result.get(), TokLoc, consumeToken()));
-          continue;
-        }
-        
-        // If we have '.<keyword><code_complete>', try to recover by creating
-        // an identifier with the same spelling as the keyword.
-        if (Tok.isKeyword() && peekToken().is(tok::code_complete)) {
-          Identifier Name = Context.getIdentifier(Tok.getText());
-          Result = makeParserResult(
-              new (Context) UnresolvedDotExpr(Result.get(), TokLoc,
-                                              Name, DeclNameLoc(Tok.getLoc()),
-                                              /*Implicit=*/false));
-          consumeToken();
-        }
 
-        if (Tok.is(tok::code_complete)) {
-          if (CodeCompletion && Result.isNonNull())
-            CodeCompletion->completeDotExpr(Result.get(), /*DotLoc=*/TokLoc);
-          // Eat the code completion token because we handled it.
-          consumeToken(tok::code_complete);
-          Result.setHasCodeCompletion();
-          return Result;
-        }
-        checkForInputIncomplete();
-        diagnose(Tok, diag::expected_member_name);
-        return nullptr;
-      }
-
-      // Don't allow '.<integer literal>' following a numeric literal
-      // expression.
-      if (Tok.is(tok::integer_literal) && Result.isNonNull() &&
-          (isa<FloatLiteralExpr>(Result.get()) ||
-           isa<IntegerLiteralExpr>(Result.get()))) {
-        diagnose(Tok, diag::numeric_literal_numeric_member)
-          .highlight(Result.get()->getSourceRange());
-        consumeToken();
-        continue;
-      }
-
-      if (Result.isParseError())
-        continue;
-
-      if (Tok.isAny(tok::identifier, tok::kw_init)) {
-        DeclNameLoc NameLoc;
-        DeclName Name = parseUnqualifiedDeclName(/*allowInit=*/true,
-                                                 NameLoc,
-                                                 diag::expected_member_name);
-        if (!Name) return nullptr;
-      
-        Result = makeParserResult(
-                   new (Context) UnresolvedDotExpr(Result.get(), TokLoc, Name,
-                                                   NameLoc,
-                                                   /*Implicit=*/false));
-          
-        if (canParseAsGenericArgumentList()) {
-          SmallVector<TypeRepr*, 8> args;
-          SourceLoc LAngleLoc, RAngleLoc;
-          if (parseGenericArguments(args, LAngleLoc, RAngleLoc)) {
-            diagnose(LAngleLoc, diag::while_parsing_as_left_angle_bracket);
-          }
-
-          SmallVector<TypeLoc, 8> locArgs;
-          for (auto ty : args)
-            locArgs.push_back(ty);
-          Result = makeParserResult(new (Context) UnresolvedSpecializeExpr(
-                     Result.get(), LAngleLoc, Context.AllocateCopy(locArgs),
-                     RAngleLoc));
-        }
-      } else {
+      // Handle "x.42" - a tuple index.
+      if (Tok.is(tok::integer_literal)) {
         DeclName name = Context.getIdentifier(Tok.getText());
         SourceLoc nameLoc = consumeToken(tok::integer_literal);
+        
+        // Don't allow '.<integer literal>' following a numeric literal
+        // expression.
+        if (Result.isNonNull() && isa<NumberLiteralExpr>(Result.get())) {
+          diagnose(nameLoc, diag::numeric_literal_numeric_member)
+            .highlight(Result.get()->getSourceRange());
+          continue;
+        }
+        
         Result = makeParserResult(
             new (Context) UnresolvedDotExpr(Result.get(), TokLoc, name,
                                             DeclNameLoc(nameLoc),
                                             /*Implicit=*/false));
+        continue;
+      }
+
+      // Handle "x.dynamicType" - A metatype expr.
+      if (Tok.is(tok::kw_dynamicType)) {
+        Result = makeParserResult(
+          new (Context) DynamicTypeExpr(Result.get(), consumeToken(), Type()));
+        continue;
+      }
+
+      // Handle "x.self" expr.
+      if (Tok.is(tok::kw_self)) {
+        Result = makeParserResult(
+          new (Context) DotSelfExpr(Result.get(), TokLoc, consumeToken()));
+        continue;
+      }
+      
+           
+      // If we have '.<keyword><code_complete>', try to recover by creating
+      // an identifier with the same spelling as the keyword.
+      if (Tok.isKeyword() && peekToken().is(tok::code_complete)) {
+        Identifier Name = Context.getIdentifier(Tok.getText());
+        Result = makeParserResult(
+            new (Context) UnresolvedDotExpr(Result.get(), TokLoc,
+                                            Name, DeclNameLoc(Tok.getLoc()),
+                                            /*Implicit=*/false));
+        consumeToken();
+        // Fall into the next code completion handler.
+      }
+
+      // Handle "x.<tab>" for code completion.
+      if (Tok.is(tok::code_complete)) {
+        if (CodeCompletion && Result.isNonNull())
+          CodeCompletion->completeDotExpr(Result.get(), /*DotLoc=*/TokLoc);
+        // Eat the code completion token because we handled it.
+        consumeToken(tok::code_complete);
+        Result.setHasCodeCompletion();
+        return Result;
+      }
+
+      DeclNameLoc NameLoc;
+      DeclName Name = parseUnqualifiedDeclName(/*allowDot=*/true,
+                                               NameLoc,
+                                               diag::expected_member_name);
+      if (!Name) return nullptr;
+    
+      Result = makeParserResult(
+                 new (Context) UnresolvedDotExpr(Result.get(), TokLoc, Name,
+                                                 NameLoc,
+                                                 /*Implicit=*/false));
+        
+      if (canParseAsGenericArgumentList()) {
+        SmallVector<TypeRepr*, 8> args;
+        SourceLoc LAngleLoc, RAngleLoc;
+        if (parseGenericArguments(args, LAngleLoc, RAngleLoc)) {
+          diagnose(LAngleLoc, diag::while_parsing_as_left_angle_bracket);
+        }
+
+        SmallVector<TypeLoc, 8> locArgs;
+        for (auto ty : args)
+          locArgs.push_back(ty);
+        Result = makeParserResult(new (Context) UnresolvedSpecializeExpr(
+                   Result.get(), LAngleLoc, Context.AllocateCopy(locArgs),
+                   RAngleLoc));
       }
 
       // If there is an expr-call-suffix, parse it and form a call.
@@ -1599,18 +1590,17 @@
     .fixItRemoveChars(end.getAdvancedLoc(-1), end);
 }
 
-DeclName Parser::parseUnqualifiedDeclName(bool allowInit,
+DeclName Parser::parseUnqualifiedDeclName(bool afterDot,
                                           DeclNameLoc &loc,
                                           const Diagnostic &diag) {
   // Consume the base name.
-  Identifier baseName;
+  Identifier baseName = Context.getIdentifier(Tok.getText());
   SourceLoc baseNameLoc;
-  if (Tok.is(tok::kw_init) && allowInit) {
-    baseName = Context.Id_init;
-    baseNameLoc = consumeToken(tok::kw_init);
-  } else if (Tok.is(tok::identifier) || Tok.is(tok::kw_Self) ||
-             Tok.is(tok::kw_self)) {
+  if (Tok.is(tok::identifier) || Tok.is(tok::kw_Self) ||
+      Tok.is(tok::kw_self)) {
     baseNameLoc = consumeIdentifier(&baseName);
+  } else if (afterDot && Tok.isKeyword()) {
+    baseNameLoc = consumeToken();
   } else {
     checkForInputIncomplete();
     diagnose(Tok, diag);
@@ -1712,7 +1702,7 @@
 
   // Parse the unqualified-decl-name.
   DeclNameLoc loc;
-  DeclName name = parseUnqualifiedDeclName(/*allowInit=*/false, loc,
+  DeclName name = parseUnqualifiedDeclName(/*afterDot=*/false, loc,
                                            diag::expected_expr);
 
   SmallVector<TypeRepr*, 8> args;
diff --git a/lib/RemoteAST/RemoteAST.cpp b/lib/RemoteAST/RemoteAST.cpp
index 6e9473d..989571d 100644
--- a/lib/RemoteAST/RemoteAST.cpp
+++ b/lib/RemoteAST/RemoteAST.cpp
@@ -362,6 +362,10 @@
     return WeakStorageType::get(base, Ctx);
   }
 
+  Type createSILBoxType(Type base) {
+    return SILBoxType::get(base->getCanonicalType());
+  }
+
   Type createObjCClassType(StringRef name) {
     Identifier ident = Ctx.getIdentifier(name);
     auto typeDecl =
diff --git a/stdlib/public/Reflection/TypeLowering.cpp b/stdlib/public/Reflection/TypeLowering.cpp
index d4d15e4..88db4ac 100644
--- a/stdlib/public/Reflection/TypeLowering.cpp
+++ b/stdlib/public/Reflection/TypeLowering.cpp
@@ -553,6 +553,11 @@
   }
 
   MetatypeRepresentation
+  visitSILBoxTypeRef(const SILBoxTypeRef *SB) {
+    return MetatypeRepresentation::Thin;
+  }
+
+  MetatypeRepresentation
   visitGenericTypeParameterTypeRef(const GenericTypeParameterTypeRef *GTP) {
     assert(false && "Must have concrete TypeRef");
     return MetatypeRepresentation::Unknown;
@@ -844,6 +849,11 @@
     return visitAnyStorageTypeRef(US->getType(), ReferenceKind::Unmanaged);
   }
 
+  const TypeInfo *visitSILBoxTypeRef(const SILBoxTypeRef *SB) {
+    return TC.getReferenceTypeInfo(ReferenceKind::Strong,
+                                   ReferenceCounting::Native);
+  }
+
   const TypeInfo *visitOpaqueTypeRef(const OpaqueTypeRef *O) {
     assert(false && "Can't lower opaque TypeRef");
     return nullptr;
diff --git a/stdlib/public/Reflection/TypeRef.cpp b/stdlib/public/Reflection/TypeRef.cpp
index 3d46797..fa864f6 100644
--- a/stdlib/public/Reflection/TypeRef.cpp
+++ b/stdlib/public/Reflection/TypeRef.cpp
@@ -204,6 +204,12 @@
     OS << ')';
   }
 
+  void visitSILBoxTypeRef(const SILBoxTypeRef *SB) {
+    printHeader("sil_box");
+    printRec(SB->getBoxedType());
+    OS << ')';
+  }
+
   void visitOpaqueTypeRef(const OpaqueTypeRef *O) {
     printHeader("opaque");
     OS << ')';
@@ -298,6 +304,10 @@
   bool visitUnmanagedStorageTypeRef(const UnmanagedStorageTypeRef *US) {
     return visit(US->getType());
   }
+
+  bool visitSILBoxTypeRef(const SILBoxTypeRef *SB) {
+    return visit(SB->getBoxedType());
+  }
 };
 
 const OpaqueTypeRef *
@@ -508,6 +518,10 @@
     return US;
   }
 
+  const TypeRef *visitSILBoxTypeRef(const SILBoxTypeRef *SB) {
+    return SILBoxTypeRef::create(Builder, visit(SB->getBoxedType()));
+  }
+
   const TypeRef *visitOpaqueTypeRef(const OpaqueTypeRef *O) {
     return O;
   }
@@ -660,6 +674,10 @@
     return UnmanagedStorageTypeRef::create(Builder, visit(US->getType()));
   }
 
+  const TypeRef *visitSILBoxTypeRef(const SILBoxTypeRef *SB) {
+    return SILBoxTypeRef::create(Builder, visit(SB->getBoxedType()));
+  }
+
   const TypeRef *visitOpaqueTypeRef(const OpaqueTypeRef *O) {
     return O;
   }
diff --git a/stdlib/public/Reflection/TypeRefBuilder.cpp b/stdlib/public/Reflection/TypeRefBuilder.cpp
index b6ca335..a889828 100644
--- a/stdlib/public/Reflection/TypeRefBuilder.cpp
+++ b/stdlib/public/Reflection/TypeRefBuilder.cpp
@@ -284,6 +284,7 @@
     else
       MS.second->dump(OS);
   }
+  OS << "\n";
 }
 
 void TypeRefBuilder::dumpCaptureSection(std::ostream &OS) {
diff --git a/test/DebugInfo/closure-multivalue.swift b/test/DebugInfo/closure-multivalue.swift
index b53f07e..fdb3937 100644
--- a/test/DebugInfo/closure-multivalue.swift
+++ b/test/DebugInfo/closure-multivalue.swift
@@ -20,8 +20,8 @@
 }
 
 public func demo() {
-    var names = ["Sean", "Barry", "Kate"]
-    var sortedNames = names.sorted(isOrderedBefore: sort)
+    let names = ["Sean", "Barry", "Kate"]
+    let sortedNames = names.sorted(isOrderedBefore: sort)
     var sortedNamesAsString : String = String()
     for name in sortedNames {
         sortedNamesAsString += ("\(name), ")
diff --git a/test/IDE/complete_unresolved_members.swift b/test/IDE/complete_unresolved_members.swift
index 8aff6ed..1fed710 100644
--- a/test/IDE/complete_unresolved_members.swift
+++ b/test/IDE/complete_unresolved_members.swift
@@ -217,6 +217,12 @@
 var cInst1 = C7()
 cInst1.extendedf1(.#^UNRESOLVED_26^#
 
+      
+// This #if works around:
+// <rdar://problem/26057202> Crash in code completion on invalid input
+#if false
+#endif
+      
 func f() -> SomeEnum1 {
   return .#^UNRESOLVED_27^#
 }
diff --git a/test/IRGen/objc_int_encoding.sil b/test/IRGen/objc_int_encoding.sil
new file mode 100644
index 0000000..4ac19ee
--- /dev/null
+++ b/test/IRGen/objc_int_encoding.sil
@@ -0,0 +1,32 @@
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -emit-ir | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
+// REQUIRES: objc_interop
+
+// CHECK: [[SELECTOR:@.*]] = private global {{.*}} c"fooWithX:\00"
+
+// CHECK-64: [[INT_UINT_METHOD_ENCODING:@.*]] = private unnamed_addr constant {{.*}} c"Q24@0:8q16\00"
+// CHECK-32: [[INT_UINT_METHOD_ENCODING:@.*]] = private unnamed_addr constant {{.*}} c"I12@0:4i8\00"
+
+// CHECK: @_INSTANCE_METHODS__TtC17objc_int_encoding3Foo = private constant {{.*}} [[SELECTOR]], {{.*}} [[INT_UINT_METHOD_ENCODING]], {{.*}} @_TToFC17objc_int_encoding3Foo3foofT1xSi_Su
+
+sil_stage canonical
+
+import Builtin
+import Swift
+import Foundation
+
+class Foo: NSObject {
+  @objc override init() {}
+
+  @objc func foo(x: Int) -> UInt
+}
+
+sil hidden @_TToFC17objc_int_encoding3Foo3foofT1xSi_Su : $@convention(objc_method) (Int, @guaranteed Foo) -> UInt {
+entry(%0 : $Int, %1 : $Foo):
+  unreachable
+}
+sil @_TToFC17objc_int_encoding3FoocfT_S0_ : $@convention(objc_method) (@owned Foo) -> @owned Foo {
+entry(%1 : $Foo):
+  unreachable
+}
+
+sil_vtable Foo {}
diff --git a/test/Inputs/clang-importer-sdk/usr/include/objc/objc.h b/test/Inputs/clang-importer-sdk/usr/include/objc/objc.h
index 66b1256..e8fc47b 100644
--- a/test/Inputs/clang-importer-sdk/usr/include/objc/objc.h
+++ b/test/Inputs/clang-importer-sdk/usr/include/objc/objc.h
@@ -4,8 +4,14 @@
 #define OBJC_ARC_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
 #define NS_AUTOMATED_REFCOUNT_UNAVAILABLE OBJC_ARC_UNAVAILABLE
 
+#ifdef __LP64__
 typedef unsigned long NSUInteger;
 typedef long NSInteger;
+#else
+typedef unsigned int NSUInteger;
+typedef int NSInteger;
+#endif
+
 typedef __typeof__(__objc_yes) BOOL;
 
 typedef struct objc_selector    *SEL;
diff --git a/test/Reflection/typeref_decoding.result.txt b/test/Reflection/typeref_decoding.result.txt
index 10c890b..61a1db9 100644
--- a/test/Reflection/typeref_decoding.result.txt
+++ b/test/Reflection/typeref_decoding.result.txt
@@ -660,15 +660,18 @@
 CAPTURE DESCRIPTORS:
 ====================
 - Capture types:
-!!! Invalid typeref
+(sil_box
+  (generic_type_parameter depth=0 index=0))
 - Metadata sources:
 (generic_type_parameter depth=0 index=0)
 (closure_binding index=0)
+
 - Capture types:
 (struct Swift.Int)
 - Metadata sources:
 (generic_type_parameter depth=0 index=0)
 !!! Invalid matadata source
+
 - Capture types:
 (bound_generic_class TypesToReflect.C1
   (generic_type_parameter depth=0 index=1))
@@ -679,3 +682,4 @@
 (generic_argument index=0
   (reference_capture index=1))
 
+
diff --git a/test/Reflection/typeref_decoding_objc.result.txt b/test/Reflection/typeref_decoding_objc.result.txt
index f406b28..c7ffa0c 100644
--- a/test/Reflection/typeref_decoding_objc.result.txt
+++ b/test/Reflection/typeref_decoding_objc.result.txt
@@ -54,10 +54,12 @@
 (struct Swift.UInt)
 (struct Swift.UInt)
 - Metadata sources:
+
 - Capture types:
 - Metadata sources:
 !!! Invalid typeref
 !!! Invalid matadata source
+
 - Capture types:
 (struct Swift.StaticString)
 (bound_generic_struct Swift.UnsafeBufferPointer
@@ -65,10 +67,12 @@
 (struct Swift.UInt)
 (struct Swift.UInt)
 - Metadata sources:
+
 - Capture types:
 - Metadata sources:
 !!! Invalid typeref
 !!! Invalid matadata source
+
 - Capture types:
 (bound_generic_struct Swift.UnsafeBufferPointer
   (struct Swift.UInt8))
@@ -77,8 +81,10 @@
 (struct Swift.UInt)
 (struct Swift.UInt)
 - Metadata sources:
+
 - Capture types:
 - Metadata sources:
 !!! Invalid typeref
 !!! Invalid matadata source
 
+
diff --git a/test/Reflection/typeref_decoding_objc.swift b/test/Reflection/typeref_decoding_objc.swift
index 6425cad..1b3d23e 100644
--- a/test/Reflection/typeref_decoding_objc.swift
+++ b/test/Reflection/typeref_decoding_objc.swift
@@ -3,3 +3,5 @@
 // RUN: %target-swift-reflection-dump -binary-filename %t/libTypesToReflect.%target-dylib-extension > %t/typeref_decoding.txt
 // RUN: diff -u %S/typeref_decoding_objc.result.txt %t/typeref_decoding.txt
 // REQUIRES: objc_interop
+
+// REQUIRES: OS=macosx
diff --git a/test/expr/delayed-ident/enum.swift b/test/expr/delayed-ident/enum.swift
index f228e7a..5817abe 100644
--- a/test/expr/delayed-ident/enum.swift
+++ b/test/expr/delayed-ident/enum.swift
@@ -5,12 +5,15 @@
   case First
   case Second(Int)
   case Third(Int, Double)
+  case `default`
 }
 
 var e1: E1 = .First
 e1 = .Second(5)
 e1 = .Third(5, 3.14159)
 
+e1 = .default  // SE-0071
+
 // Generic enumeration type
 enum E2<T> {
   case First
diff --git a/test/expr/postfix/dot/dot_keywords.swift b/test/expr/postfix/dot/dot_keywords.swift
new file mode 100644
index 0000000..c867564
--- /dev/null
+++ b/test/expr/postfix/dot/dot_keywords.swift
@@ -0,0 +1,40 @@
+// RUN: %target-parse-verify-swift
+
+let x: Int = 1
+let y: Int = x.self
+let int: Int.Type = Int.self
+
+
+// SE-0071 - Allow (most) keywords in member references
+// https://github.com/apple/swift-evolution/blob/master/proposals/0071-member-keywords.md
+
+struct SE0071Struct {
+  var `default` : Int
+}
+
+func f1(a : SE0071Struct) -> Int {
+  return a.default
+}
+
+func f2(a : SE0071Struct) -> Int {
+  return a.`default`
+}
+
+  
+enum SE0071Enum {
+  case `case`
+}
+
+func f2() -> SE0071Enum {
+  return .case
+}
+
+class SE0071Base {
+  func `default`() {}
+}
+
+class SE0071Derived : SE0071Base {
+  func zonk() {
+    super.default()
+  }
+}
\ No newline at end of file
diff --git a/test/expr/postfix/dot/self.swift b/test/expr/postfix/dot/self.swift
deleted file mode 100644
index ca7dcac..0000000
--- a/test/expr/postfix/dot/self.swift
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %target-parse-verify-swift
-
-let x: Int = 1
-let y: Int = x.self
-let int: Int.Type = Int.self
diff --git a/test/expr/unary/selector/selector.swift b/test/expr/unary/selector/selector.swift
index 0128a0f..5e423c3 100644
--- a/test/expr/unary/selector/selector.swift
+++ b/test/expr/unary/selector/selector.swift
@@ -116,7 +116,5 @@
 
 func testParseErrors4() {
   // Subscripts
-  _ = #selector(C1.subscript) // expected-error{{expected member name following '.'}}
-  // expected-error@-1{{consecutive statements on a line must be separated by ';'}}
-  // expected-error@-2{{expected '(' for subscript parameters}}
+  _ = #selector(C1.subscript) // expected-error{{type 'C1.Type' has no subscript members}}
 }
diff --git a/validation-test/compiler_crashers/28289-swift-type-transform.swift b/validation-test/compiler_crashers/28289-swift-type-transform.swift
new file mode 100644
index 0000000..4cc4e02
--- /dev/null
+++ b/validation-test/compiler_crashers/28289-swift-type-transform.swift
@@ -0,0 +1,11 @@
+// This source file is part of the Swift.org open source project
+// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
+// Licensed under Apache License v2.0 with Runtime Library Exception
+//
+// See http://swift.org/LICENSE.txt for license information
+// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
+
+// RUN: not --crash %target-swift-frontend %s -parse
+// REQUIRES: asserts
+{class B<t{typealias d<a>:S<a>class a:d
+class S<o