Files
swift-mirror/test/SILGen/literal_expr_conditional_conformance.swift
Slava Pestov 7a8a56254a AST: Fix substitution map composition edge case
Adding `T == Int` to

    G1 := <T where T: Equatable>

gives us

    G2 := <T where T == Int>

which means that if I have this substitution map for G2:

    S2 := { Int }

then `SubstitutionMap::get(G1, S2)` should give me this substitution map
for G1:

    S2 := { Int, [Int: Equatable] }

But it didn't, instead returning a substitution map with an invalid
conformance.

The problem is that local conformance lookup alone cannot recover
`[Int: Equatable]` in this case, because there is no "concrete
conformance requirement" `[T == Int: Equatable]` recorded anywhere
in G2.

This is of course a legacy of the GenericSignatureBuilder. It would have
been better to not drop conformance requirements made concrete. But oh
well.

Fixes https://github.com/swiftlang/swift/issues/74465
Fixes rdar://130404629.
2024-07-01 14:15:41 -04:00

20 lines
322 B
Swift

// RUN: %target-swift-emit-silgen %s
public protocol P {
associatedtype A : Equatable
}
public struct G<A: Equatable>: P {}
extension P where A == Int {
public init(integerLiteral: Int) {
fatalError()
}
}
extension G: ExpressibleByIntegerLiteral where A == Int {}
public func f() -> G<Int> {
return 123
}