From 695cf99be2e60c9a33304fefc559d35764d7c800 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Thu, 3 Mar 2022 21:37:44 -0500 Subject: [PATCH] Tweak a few generic signatures to work around a bug in the Requirement Machine Here is the reduced test case: func foo(_: C, _: R) where C.SubSequence == Substring, C.Element == R.Element {} The Requirement Machine produces a valid but different minimization than the GenericSignatureBuilder for this signature, which flags the assert since right now we run both and compare the results: error: compile command failed due to signal 6 (use -v to see invocation) RequirementMachine generic signature minimization is broken: RequirementMachine says: GenericSignatureBuilder says: Radar tracking the fix: rdar://problem/89791117 --- .../_StringProcessing/Algorithms/Algorithms/Replace.swift | 6 +++--- .../Algorithms/Matching/MatchReplace.swift | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Sources/_StringProcessing/Algorithms/Algorithms/Replace.swift b/Sources/_StringProcessing/Algorithms/Algorithms/Replace.swift index 36a28b381..6a8c97a6a 100644 --- a/Sources/_StringProcessing/Algorithms/Algorithms/Replace.swift +++ b/Sources/_StringProcessing/Algorithms/Algorithms/Replace.swift @@ -154,7 +154,7 @@ extension RangeReplaceableCollection where SubSequence == Substring { with replacement: Replacement, subrange: Range, maxReplacements: Int = .max - ) -> Self where Replacement.Element == Element { + ) -> Self where Replacement.Element == Character { replacing( RegexConsumer(regex), with: replacement, @@ -166,7 +166,7 @@ extension RangeReplaceableCollection where SubSequence == Substring { _ regex: R, with replacement: Replacement, maxReplacements: Int = .max - ) -> Self where Replacement.Element == Element { + ) -> Self where Replacement.Element == Character { replacing( regex, with: replacement, @@ -178,7 +178,7 @@ extension RangeReplaceableCollection where SubSequence == Substring { _ regex: R, with replacement: Replacement, maxReplacements: Int = .max - ) where Replacement.Element == Element { + ) where Replacement.Element == Character { self = replacing( regex, with: replacement, diff --git a/Sources/_StringProcessing/Algorithms/Matching/MatchReplace.swift b/Sources/_StringProcessing/Algorithms/Matching/MatchReplace.swift index 2feb09df0..281b568f7 100644 --- a/Sources/_StringProcessing/Algorithms/Matching/MatchReplace.swift +++ b/Sources/_StringProcessing/Algorithms/Matching/MatchReplace.swift @@ -80,7 +80,7 @@ extension RangeReplaceableCollection where SubSequence == Substring { with replacement: (_MatchResult>) throws -> Replacement, subrange: Range, maxReplacements: Int = .max - ) rethrows -> Self where Replacement.Element == Element { + ) rethrows -> Self where Replacement.Element == Character { try replacing( RegexConsumer(regex), with: replacement, @@ -92,7 +92,7 @@ extension RangeReplaceableCollection where SubSequence == Substring { _ regex: R, with replacement: (_MatchResult>) throws -> Replacement, maxReplacements: Int = .max - ) rethrows -> Self where Replacement.Element == Element { + ) rethrows -> Self where Replacement.Element == Character { try replacing( regex, with: replacement, @@ -104,7 +104,7 @@ extension RangeReplaceableCollection where SubSequence == Substring { _ regex: R, with replacement: (_MatchResult>) throws -> Replacement, maxReplacements: Int = .max - ) rethrows where Replacement.Element == Element { + ) rethrows where Replacement.Element == Character { self = try replacing( regex, with: replacement,