reducer .ifLet seems to be causing unable to type-check this expression in reasonable time
#2725
-
DescriptionHello, I'd love to get any suggestions, thank you 🙏 I get type-check error in Here is the sample project where you can see .ifLet(\.subFeature1, action: /Action.subFeature1) { SubFeature1() }
.ifLet(\.subFeature2, action: /Action.subFeature2) { SubFeature2() }
.ifLet(\.subFeature3, action: /Action.subFeature3) { SubFeature3() }
.ifLet(\.subFeature4, action: /Action.subFeature4) { SubFeature4() }
.ifLet(\.subFeature5, action: /Action.subFeature5) { SubFeature5() }
.ifLet(\.subFeature6, action: /Action.subFeature6) { SubFeature6() }
.ifLet(\.subFeature7, action: /Action.subFeature7) { SubFeature7() }
.ifLet(\.subFeature8, action: /Action.subFeature8) { SubFeature8() }
.ifLet(\.subFeature9, action: /Action.subFeature9) { SubFeature9() } Checklist
Expected behaviorApp should build on the latest version or Actual behaviorApp build under version error shows: ![]() Steps to reproduceif I comment out The Composable Architecture version information1.6.0 Destination operating systemiOS 17.2 Xcode version informationVersion 15.2 (15C500b) Swift Compiler version informationswift-driver version: 1.87.3 Apple Swift version 5.9.2 (swiftlang-5.9.2.2.56 clang-1500.1.0.2.5)
Target: arm64-apple-macosx14.0 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @tisohjung! Version 1.4 introduced "case key path" overloads for In the meantime, you can extract these helpers to a dedicated place to improve compile times: extension Reducer where State == Feature1.State, Action == Feature1.Action {
func subFeatures() -> some ReducerOf<Self> {
self
.ifLet(\.subFeature1, action: /Action.subFeature1) { SubFeature1() }
.ifLet(\.subFeature2, action: /Action.subFeature2) { SubFeature2() }
.ifLet(\.subFeature3, action: /Action.subFeature3) { SubFeature3() }
.ifLet(\.subFeature4, action: /Action.subFeature4) { SubFeature4() }
.ifLet(\.subFeature5, action: /Action.subFeature5) { SubFeature5() }
.ifLet(\.subFeature6, action: /Action.subFeature6) { SubFeature6() }
.ifLet(\.subFeature7, action: /Action.subFeature7) { SubFeature7() }
.ifLet(\.subFeature8, action: /Action.subFeature8) { SubFeature8() }
.ifLet(\.subFeature9, action: /Action.subFeature9) { SubFeature9() }
}
} And you can break these methods down into Since this is more of a compiler issue than a bug in the library, I'm going to convert to a discussion. |
Beta Was this translation helpful? Give feedback.
Hi @tisohjung! Version 1.4 introduced "case key path" overloads for
ifLet
, which unfortunately expands the type checking space enough to cause regressions like this. While we will be able to remove these overloads in 2.0, we cannot make breaking changes till then.In the meantime, you can extract these helpers to a dedicated place to improve compile times: