Skip to content

Conversation

@slavapestov
Copy link
Contributor

No description provided.

When looking up a generic parameter inside a nominal type context,
we would go down the most general substitution-based code path,
usually meant for typealiases, instead of calling the much simpler
resolveGenericTypeParamType(). Amazingly, everything still worked.
Now we have LookUpConformanceInModule and
LookUpConformanceInSubstitutionMap.
First, add some new utility methods to create SubstitutionMaps:

- GenericSignature::getSubstitutionMap() -- provides a new
  way to directly build a SubstitutionMap. It takes a
  TypeSubstitutionFn and LookupConformanceFn. This is
  equivalent to first calling getSubstitutions() with the two
  functions to create an ArrayRef<Substitution>, followed by
  the old form of getSubstitutionMap() on the result.

- TypeBase::getContextSubstitutionMap() -- replacement for
  getContextSubstitutions(), returning a SubstitutionMap.

- TypeBase::getMemberSubstitutionMap() -- replacement for
  getMemberSubstitutions(), returning a SubstitutionMap.

With these in place, almost all existing uses of subst() taking
a ModuleDecl can now use the new form taking a SubstitutionMap
instead. The few remaining cases are explicitly written to use a
TypeSubstitutionFn and LookupConformanceFn.
@slavapestov slavapestov changed the title [WIP] SubstitutionMap cleanups SubstitutionMap cleanups Feb 4, 2017
@slavapestov
Copy link
Contributor Author

Please test with following pull request:
apple/swift-lldb#133

@swift-ci Please smoke test

@slavapestov slavapestov merged commit c6df1cd into swiftlang:master Feb 4, 2017
slavapestov added a commit to slavapestov/swift that referenced this pull request Feb 17, 2017
The hasPolymorphicParameters() method always returns true for a
SILFunctionType with witness_method calling convention, because
we have to pass the type metadata for 'Self'.

However, it is possible for a witness_method to have no generic
signature, if we're directly calling a concrete witness method
thunk, as can happen after devirtualization.

In this case, we would crash if the witness_method was partially
applied. Handle this case.

This fixes a regression from the recent cleanup to have IRGen use
SubstitutionMap: <swiftlang#7211>
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