Merge pull request #9454 from slavapestov/se-0110-strikes-again

Sema: Fix another SE-0110 issue
diff --git a/lib/SILGen/SILGenFunction.cpp b/lib/SILGen/SILGenFunction.cpp
index 28fe7fa..9a8cdf6 100644
--- a/lib/SILGen/SILGenFunction.cpp
+++ b/lib/SILGen/SILGenFunction.cpp
@@ -196,7 +196,9 @@
 
     case CaptureKind::Constant: {
       // let declarations.
-      auto Entry = VarLocs[vd];
+      auto found = VarLocs.find(vd);
+      assert(found != VarLocs.end());
+      auto Entry = found->second;
 
       auto *var = cast<VarDecl>(vd);
       auto &tl = getTypeLowering(var->getType()->getReferenceStorageReferent());
diff --git a/lib/Sema/TypeCheckGeneric.cpp b/lib/Sema/TypeCheckGeneric.cpp
index bbfd50c..dd867d8 100644
--- a/lib/Sema/TypeCheckGeneric.cpp
+++ b/lib/Sema/TypeCheckGeneric.cpp
@@ -899,7 +899,8 @@
 
     Type selfTy;
     if (i == e-1 && hasSelf) {
-      selfTy = func->computeInterfaceSelfType();
+      selfTy = ParenType::get(Context, func->computeInterfaceSelfType());
+
       // Substitute in our own 'self' parameter.
 
       argTy = selfTy;
diff --git a/test/Constraints/function_conversion.swift b/test/Constraints/function_conversion.swift
index 58375e5..695a062 100644
--- a/test/Constraints/function_conversion.swift
+++ b/test/Constraints/function_conversion.swift
@@ -21,3 +21,18 @@
   let _: (Base) -> () = fn
   let _: (Derived) -> () = fn
 }
+
+// rdar://problem/31725325
+
+func a<b>(_: [(String, (b) -> () -> Void)]) {}
+func a<b>(_: [(String, (b) -> () throws -> Void)]) {}
+
+class c {
+  func e() {}
+  static var d = [("", e)]
+}
+a(c.d)
+
+func b<T>(_: (T) -> () -> ()) {}
+
+b(c.e)
diff --git a/test/Constraints/members.swift b/test/Constraints/members.swift
index 3636ea4..09bf137 100644
--- a/test/Constraints/members.swift
+++ b/test/Constraints/members.swift
@@ -7,9 +7,9 @@
 struct X {
   func f0(_ i: Int) -> X { }
 
-  func f1(_ i: Int) { } // expected-note {{found this candidate}}
+  func f1(_ i: Int) { }
 
-  mutating func f1(_ f: Float) { } // expected-note {{found this candidate}}
+  mutating func f1(_ f: Float) { }
 
   func f2<T>(_ x: T) -> T { }
 }
@@ -28,9 +28,7 @@
 _ = x.f0(i)
 x.f0(i).f1(i)
 
-// FIXME: Is this a bug in Swift 4 mode?
 g0(X.f1)
-// expected-error@-1 {{ambiguous reference to member 'f1'}}
 
 _ = x.f0(x.f2(1))
 _ = x.f0(1).f2(i)