This crash happens because shouldAddSelfFixit (a check for the expected_self_before_reference diagnotic) performs name lookup inside the parser, which causes a search for extensions, which triggers the mangler, which can get confused if we are in an unfinished declaration (a PatternBindingInitilizer in this case).
A cleaner fix would be to move that logic inside Sema, but it would require much more refactoring that I don’t feel comfortable doing. Instead, this band-aid checks if the innermost type is inside a local context. If that’s the case, we can ignore the search for extensions.
The @_versioned accessibility check is done against the formal access. But the diagnostics is printed with getAccessForDiagnostics. In cases where the effective access is internal, the diagnostics will crash. Example:
```
class A { // implicitly internal
@_versioned public var a: Int = 0 // explicity public
}
```
New GenericTypeParamDecls should always be created with an
InvalidDepth, to prevent canonicalization before the generic
parameter list has been type checked.
If typechecking fails, the expression will have unsolved type variables
written into it. This Crashes The Compiler.
In that case, there’s no reason to keep a tree of dangling references
around. Detach the initializer expression from the AST, but continue
to typecheck it to see if we can get some useful diagnostics out of it.
The list of directly inherited protocols of a ProtocolDecl is already
encoded in the requirement signature, as conformance constraints where
the subject is Self. Gather the list from there rather than separately
computing/storing the list of "inherited protocols".
After we call into typeCheckExpression() we need to cache the
resulting types in the constraint system type map because we later
call into code that reads the types out of the type map.
Fixes rdar://problem/30376186 as well as a couple crashers.
We allow a member of a type to be more accessible than the type
itself. In this case, the broader accessibility is ignored, and
the effective access of the member is constrained by the
accessibility of its parent type.
We sometimes construct DependentMemberTypes with an UnresolvedType
base. These are not "real" interface types and can end up in
places where we don't expect interface types, triggering an
assertion. Make sure such types don't respond true to hasTypeParameter().
Swift 3.0 allowed constructing an enum or calling a function-typed
property with multiple arguments even when a single argument of tuple
type was expected. Emulate that in Swift 3 mode by wrapping in an
extra level of parentheses when the situation comes up.
Last vestiges of fallout from SE-0110. Hopefully last, anyway. A nice
follow-up to this commit might be to /warn/ in Swift 3 mode when this
happens.
rdar://problem/30171399
In Swift 3, these attributes were changed to apply to the type,
and not the parameter. If they appear on the parameter, we would
go down a diagnostic code path.
When checking a generic function signature, we might not have a
contextual type for the parameter yet, so bail out instead of
crashing.
If there are unresolved generic parameters present and we are trying
to diagnose problems related to initializer call, it makes sense to
check argument expression first, which might be erroneous and then move
on to the ambiguity checking instead of trying to lookup possible
constructors directly.
1efafbcd9b restricted our classification
of various optional-related conversions (implicit forcing of IUOs,
optional-to-optional conversions, value-to-optional conversions) to
produce a single potential classification. However, in the presence of
type variables, we cannot always determine which particular conversion
restriction might apply. Prior to 1efafb, we produced too many
options; after 1efafb, we produced too few. Here, enumerate a more
bounded (but complete) set of potential conversions, taking into
account embedded type variables.
This is a better fix for rdar://problem/29977523 than simply reverting
1efafb, because it bounds the set of optional conversions we attempt.
Add additional checks before trying to re-check argument expression in
`FailureDiagnosis::diagnoseImplicitSelfErrors` and before trying to use
its resulting type, which can only be either tuple or paren type.