Introduce a fix to detect and diagnose situations when omitted
generic arguments couldn't be deduced by the solver based on
the enclosing context.
Example:
```swift
struct S<T> {
}
_ = S() // There is not enough context to deduce `T`
```
Resolves: rdar://problem/51203824
For example, if someone tries to use the newly-generic type Cache,
from Foundation:
var cache = Cache()
they'll now get a fix-it to substitute the default generic parameters:
var cache = Cache<AnyObject, AnyObject>()
The rules for choosing this placeholder type are based on constraints
and won't be right 100% of the time, but they should be reasonable.
(In particular, constraints on associated types are ignored.)
In cases where there's no one concrete type that will work, an Xcode-
style placeholder is inserted instead.
- An unconstrained generic parameter defaults to 'Any'.
- A superclass-constrained parameter defaults to that class,
e.g. 'UIView'.
- A parameter constrained to a single @objc protocol (or to AnyObject)
defaults to that protocol, e.g. 'NSCoding'.
- Anything else gets a placeholder using the generic parameter's name
and protocol composition syntax.
rdar://problem/27087345
information about where the archetype was defined. Before:
t.swift:6:17: error: generic parameter 'T' could not be inferred
var a : Int = A.foo()
^
After:
t.swift:6:17: error: generic parameter 'T' could not be inferred
var a : Int = A.foo()
^
t.swift:2:8: note: 'T' declared as parameter to type 'A'
struct A<T> {
^
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK. The driver was defaulting to the
host OS. Thus, we could not run the tests when the standard library was
not built for OS X.
Swift SVN r24504
t2.swift:3:1: error: argument for generic parameter 'U' could not be
inferred
f(i)
^
t2.swift:2:6: note: in call to function 'f'
func f<T, U>(t: T) -> U? { return nil }
^
Our lack of decent locator information means that we don't get notes
in all of the cases we want them. I'll look at that separately.
Swift SVN r21921
Handle an UnresolvedDot in the fallback case of the constraint solver where there are no active constraints but the system is ambiguous. Fixes the common case of 'Array.map' taking down SourceKit halfway through typing an expression. <rdar://problem/17125912>
Swift SVN r20450