Skip to content

RequirementMachine: Skip protocol type aliases that contain unbound dependent member types #80281

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 2 commits into from
Mar 26, 2025

Conversation

slavapestov
Copy link
Contributor

@slavapestov slavapestov commented Mar 25, 2025

In the below, 'Self.A.A' is not a type parameter; rather, since 'Self.A' is concretely known to be 'S' via a protocol type alias, we resolve it as 'S.A', which performs a name lookup and finds the concrete type alias 'A' of 'S', which is just 'Int':

public struct S {
  public typealias A = Int
}

public protocol P {
  typealias A = S
}

public struct G<T> {}

public protocol Q: P {
  typealias B = G<Self.A.A>
}

This is fine, but such a type alias should not participate in the rewrite system. Let's exclude them like any other invalid requirement.

The type alias itself is not an error; however, it is an error to use it from a 'where' clause requirement. This is not diagnosed yet, though.

Fixes rdar://136686001.

…ependent member types

In the below, 'Self.A.A' is not a type parameter; rather, since
'Self.A' is concretely known to be 'S', we resolve it as 'S.A',
which performs a name lookup and finds the concrete type alias 'A':

    public struct S {
      public typealias A = Int
    }

    public protocol P {
      typealias A = S
    }

    public struct G<T> {}

    public protocol Q: P {
      typealias B = G<Self.A.A>
    }

This is fine, but such a type alias should not participate in
the rewrite system. Let's exclude them like any other invalid
requirement.

The type alias itself is not an error; however, it is an error
to use it from a 'where' clause requirement. This is not
diagnosed yet, though.

Fixes rdar://136686001.
@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov
Copy link
Contributor Author

@swift-ci Please test source compatibility

@slavapestov slavapestov merged commit c481769 into swiftlang:main Mar 26, 2025
4 of 5 checks passed
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