Strip TypeLoc from EnumElementPattern

This commit is contained in:
Robert Widmann
2020-06-10 13:15:10 -07:00
parent fc9070c072
commit 2371e5c260
12 changed files with 159 additions and 126 deletions

View File

@@ -1481,11 +1481,6 @@ namespace {
Type resolveTypeReferenceInExpression(TypeRepr *repr,
TypeResolverContext resCtx) {
TypeLoc loc(repr);
return resolveTypeReferenceInExpression(loc, resCtx);
}
Type resolveTypeReferenceInExpression(TypeLoc &loc,
TypeResolverContext resCtx) {
TypeResolutionOptions options(resCtx);
options |= TypeResolutionFlags::AllowUnboundGenerics;
bool hadError = TypeChecker::validateType(
@@ -2581,10 +2576,16 @@ namespace {
CS.getConstraintLocator(locator),
TVO_CanBindToLValue | TVO_CanBindToNoEscape);
FunctionRefKind functionRefKind = FunctionRefKind::Compound;
if (!enumPattern->getParentType().isNull()) {
if (enumPattern->getParentType() || enumPattern->getParentTypeRepr()) {
// Resolve the parent type.
Type parentType = resolveTypeReferenceInExpression(
enumPattern->getParentType(), TypeResolverContext::InExpression);
Type parentType = [&]() -> Type {
if (auto preTy = enumPattern->getParentType()) {
return preTy;
}
return resolveTypeReferenceInExpression(
enumPattern->getParentTypeRepr(),
TypeResolverContext::InExpression);
}();
if (!parentType)
return Type();