Skip to content
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

TypeResolver: Resolve Module.Type as qualified type name #69855

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AnthonyLatsis
Copy link
Collaborator

Resolves #67378.

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test Linux

auto ty = resolveType(repr->getBase(), options);
baseOptions |= TypeResolutionFlags::DisallowOpaqueTypes;

// The parser assumes 'X.Type' is a metatype representation, but it might be
Copy link
Member

Choose a reason for hiding this comment

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

Can we get rid of metatype representations and model them as a MemberTypeRepr?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, but we will need two bits to disambiguate between X.Type/X.Protocol and X.`Type`/X.`Protocol`. Does that sound alright?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Or just one isEscaped bit for SimpleIdentTypeRepr really.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We absolutely need that bit to disambiguate in expression context anyway. Currently, both of these type-check as Int.Type.Type instances:

extension Int {
  struct `Type` {}
}

_ = Int.`Type`.self
_ = Int.Type.self

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let’s start with #70467.

auto *memberTR =
MemberTypeRepr::create(ctx, {simpleIdentBase, memberComponent});

auto ty = resolveType(memberTR, options);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Local ty variable seems kind of ambiguous here as it has the same name as the one we resolve base type, wonder if would be better name then differently?

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.

Types named "Type" don't fare well with explicit qualification
3 participants