Merge pull request #18349 from gottesmm/pr-44bd64d1e8d2c74b731326476199f407fb1d4bd7

diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 5d3ffa8..a201587 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -2,7 +2,7 @@
 //
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2018 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
@@ -3815,9 +3815,12 @@
     // Methods of non-final classes can only contain a covariant 'Self'
     // as a function result type.
     if (!allowCovariantParameters) {
-      auto inputType = type->castTo<AnyFunctionType>()->getInput();
-      auto inputKind = ::findProtocolSelfReferences(this, inputType,
-                                                    skipAssocTypes);
+      auto inputKind = SelfReferenceKind::None();
+      for (auto &elt : type->castTo<AnyFunctionType>()->getParams()) {
+        inputKind |= ::findProtocolSelfReferences(this, elt.getType(),
+                                                  skipAssocTypes);
+      }
+
       if (inputKind.parameter)
         return SelfReferenceKind::Other();
     }
diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp
index 154ca12..121d6ed 100644
--- a/lib/ClangImporter/ImportDecl.cpp
+++ b/lib/ClangImporter/ImportDecl.cpp
@@ -2,7 +2,7 @@
 //
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2018 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
@@ -6110,7 +6110,7 @@
 
   // Look for other imported constructors that occur in this context with
   // the same name.
-  Type allocParamType = oldFnType->getInput();
+  auto allocParams = oldFnType->getParams();
   bool ignoreNewExtensions = isa<ClassDecl>(dc);
   for (auto other : ownerNominal->lookupDirect(importedName.getDeclName(),
                                                ignoreNewExtensions)) {
@@ -6127,12 +6127,12 @@
     // If the types don't match, this is a different constructor with
     // the same selector. This can happen when an overlay overloads an
     // existing selector with a Swift-only signature.
-    Type ctorParamType = ctor->getInterfaceType()
-                             ->castTo<AnyFunctionType>()
-                             ->getResult()
-                             ->castTo<AnyFunctionType>()
-                             ->getInput();
-    if (!ctorParamType->isEqual(allocParamType)) {
+    auto ctorParams = ctor->getInterfaceType()
+                          ->castTo<AnyFunctionType>()
+                          ->getResult()
+                          ->castTo<AnyFunctionType>()
+                          ->getParams();
+    if (!AnyFunctionType::equalParams(ctorParams, allocParams)) {
       continue;
     }
 
diff --git a/lib/ClangImporter/ImportType.cpp b/lib/ClangImporter/ImportType.cpp
index 9674640..ad40911 100644
--- a/lib/ClangImporter/ImportType.cpp
+++ b/lib/ClangImporter/ImportType.cpp
@@ -2,7 +2,7 @@
 //
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2018 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
@@ -407,8 +407,9 @@
       FunctionType *fTy = pointeeType->castTo<FunctionType>();
       
       auto rep = FunctionType::Representation::Block;
-      auto funcTy = FunctionType::get(fTy->getInput(), fTy->getResult(),
-                                   fTy->getExtInfo().withRepresentation(rep));
+      auto funcTy =
+          FunctionType::get(fTy->getParams(), fTy->getResult(),
+                            fTy->getExtInfo().withRepresentation(rep));
       return { funcTy, ImportHint::Block };
     }
 
@@ -1537,7 +1538,7 @@
 
   // Apply @noescape to function types.
   if (auto funcType = type->getAs<FunctionType>()) {
-    return FunctionType::get(funcType->getInput(), funcType->getResult(),
+    return FunctionType::get(funcType->getParams(), funcType->getResult(),
                              funcType->getExtInfo().withNoEscape());
   }
 
diff --git a/lib/SILGen/RValue.h b/lib/SILGen/RValue.h
index 5ef6e05..99de3d1 100644
--- a/lib/SILGen/RValue.h
+++ b/lib/SILGen/RValue.h
@@ -2,7 +2,7 @@
 //
 // This source file is part of the Swift.org open source project
 //
-// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
+// Copyright (c) 2014 - 2018 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
@@ -315,10 +315,12 @@
       // Allow function types to disagree about 'noescape'.
       if (auto lf = dyn_cast<FunctionType>(l)) {
         if (auto rf = dyn_cast<FunctionType>(r)) {
-          return lf.getInput() == rf.getInput()
-              && lf.getResult() == rf.getResult()
-              && lf->getExtInfo().withNoEscape(false) ==
-                 lf->getExtInfo().withNoEscape(false);
+          auto lParams = lf.getParams();
+          auto rParams = rf.getParams();
+          return AnyFunctionType::equalParams(lParams, rParams) &&
+                 lf.getResult() == rf.getResult() &&
+                 lf->getExtInfo().withNoEscape(false) ==
+                     lf->getExtInfo().withNoEscape(false);
         }
       }
       return false;