diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Symbolic/SymbolicRegexMatcher.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Symbolic/SymbolicRegexMatcher.cs index 1d1f9f30a4942c..7931bd41986690 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Symbolic/SymbolicRegexMatcher.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Symbolic/SymbolicRegexMatcher.cs @@ -238,8 +238,10 @@ internal SymbolicRegexMatcher(SymbolicRegexNode sr, RegexCode code, Ch /// Interface for transitions used by the method. private interface ITransition { +#pragma warning disable CA2252 // This API requires opting into preview features /// Find the next state given the current state and next character. - DfaMatchingState TakeTransition(SymbolicRegexMatcher matcher, DfaMatchingState currentState, int mintermId, TSetType minterm); + static abstract DfaMatchingState TakeTransition(SymbolicRegexMatcher matcher, DfaMatchingState currentState, int mintermId, TSetType minterm); +#pragma warning restore CA2252 } /// Compute the target state for the source state and input[i] character. @@ -262,14 +264,14 @@ private DfaMatchingState Delta(ReadOnlySpan input, minterms[mintermId] : _builder._solver.False; // minterm=False represents \Z - return default(TTransition).TakeTransition(this, sourceState, mintermId, minterm); + return TTransition.TakeTransition(this, sourceState, mintermId, minterm); } /// Transition for Brzozowski-style derivatives (i.e. a DFA). private readonly struct BrzozowskiTransition : ITransition { [MethodImpl(MethodImplOptions.AggressiveInlining)] - public DfaMatchingState TakeTransition( + public static DfaMatchingState TakeTransition( SymbolicRegexMatcher matcher, DfaMatchingState currentState, int mintermId, TSetType minterm) { SymbolicRegexBuilder builder = matcher._builder; @@ -284,13 +286,13 @@ public DfaMatchingState TakeTransition( private readonly struct AntimirovTransition : ITransition { [MethodImpl(MethodImplOptions.AggressiveInlining)] - public DfaMatchingState TakeTransition( + public static DfaMatchingState TakeTransition( SymbolicRegexMatcher matcher, DfaMatchingState currentStates, int mintermId, TSetType minterm) { if (currentStates.Node.Kind != SymbolicRegexKind.Or) { // Fall back to Brzozowski when the state is not a disjunction. - return default(BrzozowskiTransition).TakeTransition(matcher, currentStates, mintermId, minterm); + return BrzozowskiTransition.TakeTransition(matcher, currentStates, mintermId, minterm); } SymbolicRegexBuilder builder = matcher._builder;