Skip to content

GSB: use a request for the structural type of type aliases #24204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 30, 2019

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Apr 22, 2019

No description provided.

@xymus
Copy link
Contributor Author

xymus commented Apr 22, 2019

@swift-ci Please smoke test

@xymus xymus force-pushed the structural-type-request branch from 191fdc5 to d3b7306 Compare April 22, 2019 20:52
@xymus xymus changed the title GSB: use a request evaluator for the structural type of type aliases GSB: use a request for the structural type of type aliases Apr 22, 2019
@xymus
Copy link
Contributor Author

xymus commented Apr 22, 2019

@swift-ci Please smoke test

@xymus xymus force-pushed the structural-type-request branch from d3b7306 to 44c9459 Compare April 24, 2019 17:54
@xymus
Copy link
Contributor Author

xymus commented Apr 24, 2019

@swift-ci Please smoke test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor

Fix looks good

@slavapestov
Copy link
Contributor

@swift-ci Please smoke test macOS

xymus added 2 commits April 25, 2019 10:21
…iases

This request evaluator doesn't rely on the previous execution of
a compilation phase but it caches the result in a compatible way.
@xymus xymus force-pushed the structural-type-request branch from 58f6c5e to 9e6713d Compare April 25, 2019 17:25
@xymus
Copy link
Contributor Author

xymus commented Apr 25, 2019

@swift-ci Please smoke test macOS

@xymus
Copy link
Contributor Author

xymus commented Apr 25, 2019

@swift-ci Please smoke test Linux

@xymus
Copy link
Contributor Author

xymus commented Apr 25, 2019

@swift-ci Please test source compatibility

TypeAliasDecl *D) const {
auto typeRepr = D->getUnderlyingTypeLoc().getTypeRepr();
auto resolution = TypeResolution::forStructural(D);
return resolution.resolveType(typeRepr, None);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to use the same options as in validateTypeAliasType():

  TypeResolutionOptions options(
    (typeAlias->getGenericParams() ?
     TypeResolverContext::GenericTypeAliasDecl :
     TypeResolverContext::TypeAliasDecl));

  if (!typeAlias->getDeclContext()->isCascadingContextForLookup(
        /*functionsAreNonCascading*/true)) {
     options |= TypeResolutionFlags::KnownNonCascadingDependency;
  }

For now you can just copy and paste that code, we'll factor it out later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... however a generic type alias will never end up here, so you remove that part. In fact, can you assert(!getGenericParams()) in TypeAliasDecl::getStructuralType()?

@xymus xymus force-pushed the structural-type-request branch from 9e6713d to c27dca3 Compare April 26, 2019 17:29
@xymus
Copy link
Contributor Author

xymus commented Apr 26, 2019

@swift-ci Please smoke test macOS

@xymus
Copy link
Contributor Author

xymus commented Apr 26, 2019

@swift-ci Please smoke test Linux

@xymus
Copy link
Contributor Author

xymus commented Apr 26, 2019

@swift-ci Please test source compatibility

@slavapestov
Copy link
Contributor

It looks like expandConformanceRequirement() needs to skip generic type aliases altogether.

@slavapestov
Copy link
Contributor

... and generic types in general. They're not something the GSB tries to model anyway.

Fixes crashes in 28437-swift-typechecker-validatedecl.swift (from previous commit)
and the compiler crasher 28861-gpdecl-getdepth-generictypeparamdecl-
invaliddepth-parameter-hasnt-been-validated.swift.
@xymus
Copy link
Contributor Author

xymus commented Apr 30, 2019

@swift-ci Please smoke test macOS

@xymus
Copy link
Contributor Author

xymus commented Apr 30, 2019

@swift-ci Please smoke test Linux

@xymus
Copy link
Contributor Author

xymus commented Apr 30, 2019

@swift-ci Please test source compatibility

@xymus
Copy link
Contributor Author

xymus commented Apr 30, 2019

@swift-ci Please smoke test Linux

@xymus xymus merged commit 1119b91 into swiftlang:master Apr 30, 2019
@xymus xymus deleted the structural-type-request branch May 13, 2019 20:58
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.

2 participants