Commit Graph

1 Commits

Author SHA1 Message Date
Pavel Yaskevich
ffa49969f5 [ConstraintSystem] Mark generic parameter bindings as potentially incomplete by default
This helps to postpone attempting bindings related to generic
parameters with all else being equal.

Consider situation when function has class requirement on its
generic parameter. Without such requirement solver would infer
sub-class for `T`. But currently when requirement is present base
class is inferred instead, because when bindings for such generic
parameter are attempted early single available binding at that
point comes from the requirement.

```swift
class BaseClass {}
class SubClass: BaseClass {}

struct Box<T> { init(_: T.Type) {} }

func test<T: BaseClass>(box: Box<T>) -> T.Type {
  return T.self
}

test(box: .init(SubClass.self)) // `T` expected to be `SubClass`
```

Resolves: [SR-9626](https://bugs.swift.org/browse/SR-9626)
Resolves: rdar://problem/47324309
2019-01-16 14:07:36 -08:00