Skip to content

Commit fadeb0e

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents 77c7101 + 9f30ed6 commit fadeb0e

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/Sema/CSBindings.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -66,6 +66,14 @@ ConstraintSystem::determineBestBindings() {
6666
continue;
6767

6868
for (auto &binding : relatedBindings->getSecond().Bindings) {
69+
// We need the binding kind for the potential binding to
70+
// either be Exact or Supertypes in order for it to make sense
71+
// to add Supertype bindings based on the relationship between
72+
// our type variables.
73+
if (binding.Kind != AllowedBindingKind::Exact &&
74+
binding.Kind != AllowedBindingKind::Supertypes)
75+
continue;
76+
6977
auto type = binding.BindingType;
7078

7179
if (ConstraintSystem::typeVarOccursInType(typeVar, type))

test/Constraints/sr7875.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
protocol Proto {}
4+
class Base {}
5+
class Test : Base, Proto {}
6+
7+
struct A {}
8+
struct B {}
9+
10+
func overloaded<T: Proto & Base>(_ f: () -> T, _ g: (T, A) -> ()) {}
11+
func overloaded<T: Proto & Base>(_ f: () -> T, _ g: (T, B) -> ()) {}
12+
13+
func f() -> Test { return Test() }
14+
15+
func g<T: Proto & Base>(_ t: T, _ a: A) -> () {}
16+
17+
func test() {
18+
overloaded(f, g as (Test, A) -> ())
19+
overloaded(f, g)
20+
}

0 commit comments

Comments
 (0)