Diagnose an attempt to pass raw representable type where its raw value
is expected instead.
```swift
enum E : Int {
case one = 1
}
let _: Int = E.one
```
`E.one` has to use `.rawValue` to match `Int` expected by pattern binding.
Diagnose an attempt to initialize raw representable type or convert to it
a value of some other type that matches its `RawValue` type.
```swift
enum E : Int {
case a, b, c
}
let _: E = 0
```
`0` has to be wrapped into `E(rawValue: 0)` and either defaulted via `??` or
force unwrapped to constitute a valid binding.
In situations where left-hand side requires value-to-optional
promotion which ends up in type mismatch let's not mention
optionals in the diagnostic because they are unrelated e.g.
```swift
func test(_: UnsafePointer<Int>??) {}
var value: Float = 0
test(&value)
```
In this example `value` gets implicitly wrapped into a double optional
before `UnsafePointer<Float>` could be matched against `UnsafePointer<Int>`
associated with the parameter.
Diagnostic is about generic argument mismatch `Float` vs. `Int`
and shouldn't mention any optionals.
If closure is an argument to a call to a missing member or invalid
contextual member reference let's not diagnose problems related to
inability to infer parameter types because root issue is that context
for closure inference couldn't be established.
Annotate the covered switches with `llvm_unreachable` to avoid the MSVC
warning which does not recognise the covered switches. This allows us
to avoid a spew of warnings.
When simplifying a keypath constraint with a function type binding, single-parameter functions have the parameter type and the return type matched against the keypath root and value; whereas multiple-parameter functions cause an ambiguous failure (in `simplifyKeyPathConstraint`).
Resolves rdar://problem/57930643
This is useful when diagnostic needs to check something about type
variables involved in a particular type e.g. whether type variable
has been defaulted.
All callers can trivially be refactored to use ModuleDecl::lookupConformance()
instead. Since this was the last flag in ConformanceCheckOptions, we can remove
that, too.
Remove duplication in the modeling of TypeExpr. The type of a TypeExpr
node is always a metatype corresponding to the contextual
type of the type it's referencing. For some reason, the instance type
was also stored in this TypeLoc at random points in semantic analysis.
Under the assumption that this instance type is always going to be the
instance type of the contextual type of the expression, introduce
a number of simplifications:
1) Explicit TypeExpr nodes must be created with a TypeRepr node
2) Implicit TypeExpr nodes must be created with a contextual type
3) The typing rules for implicit TypeExpr simply opens this type
Originally such accessors were only useful for `FailureDiagnostic` but
now since `ConstraintLocator` is anchored with `TypedNode` it makes sense
to make them universally accessible.