Skip to content

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