File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -66,6 +66,14 @@ ConstraintSystem::determineBestBindings() {
66
66
continue ;
67
67
68
68
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
+
69
77
auto type = binding.BindingType ;
70
78
71
79
if (ConstraintSystem::typeVarOccursInType (typeVar, type))
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments