Skip to content

Sema: Fix another SE-0110 issue #9454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/SILGen/SILGenFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ void SILGenFunction::emitCaptures(SILLocation loc,

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());
Expand Down
3 changes: 2 additions & 1 deletion lib/Sema/TypeCheckGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,8 @@ void TypeChecker::configureInterfaceType(AbstractFunctionDecl *func,

Type selfTy;
if (i == e-1 && hasSelf) {
selfTy = func->computeInterfaceSelfType();
selfTy = ParenType::get(Context, func->computeInterfaceSelfType());

// Substitute in our own 'self' parameter.

argTy = selfTy;
Expand Down
15 changes: 15 additions & 0 deletions test/Constraints/function_conversion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,18 @@ func existentialConversion(fn: @escaping (Refined) -> ()) {
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)
6 changes: 2 additions & 4 deletions test/Constraints/members.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 { }
}
Expand All @@ -28,9 +28,7 @@ func g0(_: (inout X) -> (Float) -> ()) {}
_ = 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)
Expand Down