Happy holidays :-) I started looking at this bug to see if I could figure out how to fix it: https://bugs.swift.org/browse/SR-3500
As the bug author points out, there is a TODO in GenericSignature::getSubstitutionMap, saying it needs to handle same-type requirements: https://github.com/apple/swift/blob/474096b9cbd6ff7ac998d7cea41d629512e25570/lib/AST/GenericSignature.cpp#L276 Most of the stuff going on here is way over my head right now, but maybe I can get there by asking some questions. Here is my repro case: protocol P { associatedtype Pmember } struct Bar {} struct Foo: P { typealias Pmember = Bar } protocol A { associatedtype Amember: P func doSomething() -> Amember.Pmember } extension A where Amember == Foo { func extensionFunc() { doSomething() // crash occurs when trying to subst() this call's return type } } Ultimately the problem is that, during SILFunctionType::substGenericArgs, getMemberForBaseType() returns null when called on the DependentMemberType (the function result type), because the result of lookupConformances is not concrete: https://github.com/apple/swift/blob/474096b9cbd6ff7ac998d7cea41d629512e25570/lib/AST/Type.cpp#L2843-L2845 Here are some things I don't understand: 1. Why does LookupConformanceFn return only a single conformance? Couldn't there be more than one conformance for a particular generic param? 2. Why does finding an abstract conformance constitute a failure of getMemberForBaseType? 3. At the lookupConformances call <https://github.com/apple/swift/blob/474096b9cbd6ff7ac998d7cea41d629512e25570/lib/AST/Type.cpp#L2843-L2845>, origBase is "τ_0_0.Amember", and substBase is the concrete type "Foo". However, the LookUpConformanceInSubstitutionMap drops the substBase ( <https://github.com/apple/swift/blob/474096b9cbd6ff7ac998d7cea41d629512e25570/lib/AST/Type.cpp#L2891> *conformingReplacementType)* on the floor <https://github.com/apple/swift/blob/474096b9cbd6ff7ac998d7cea41d629512e25570/lib/AST/Type.cpp#L2891>. Why? 4. Finally, is SubstitutionMap really the right place for same-type requirements? Maybe getMemberForBaseType would need more context passed to it than just the LookupConformanceFn? Thanks, Jacob
_______________________________________________ swift-dev mailing list swift-dev@swift.org https://lists.swift.org/mailman/listinfo/swift-dev