Skip to content

Conversation

@slavapestov
Copy link
Contributor

With added bonus, name lookup cleanup.

- TypeMatchVisitor doesn't like seeing ErrorTypes -- stop if we have one.

- Common logic for replacing type parameters and variables with
  UnresolvedType.

- Fix crash in coerceToType() if one of the two types has an UnresolvedType
  in it, but not at the top level.

Fixes one compiler_crasher and some regressions with upcoming patches.
…values/etc

Previously all of the following would strip off varying amounts of
MetatypeType, LValueType, InOutType, DynamicSelfType, etc:

- ConstraintSystem::performMemberLookup()
- ConstraintSystem::lookupMember()
- TypeChecker::lookupMember()
- DeclContext::lookupQualified()
- Type::getContextSubstitutions()

The problem is that the higher level methods that took a lookup type
would call the lower level methods, and post-process the result using
the given lookup type. Since different levels of sugar were stripped,
it made the code hard to reason about and opened up edge cases, eg
if a DynamicSelfType or InOutType appears where we didn't expect it.

Since filtering out static/instance and mutating/nonmutating members
is done at higher levels, there's no reason for these name lookup
operations to accept anything other than nominal types, existentials
and archetypes.

Make this so with assertions, and deal with the fallout.
Not really specific to typealiases; but we don't allow nominal types
to be nested inside protocols yet, and all other types of protocol
members have witnesses in the concrete type.

Fixes <https://bugs.swift.org/browse/SR-2792>.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant