@@ -538,8 +538,13 @@ boolean startsWith(String self, String prefix, long start, long end) {
538538 return doIt (self , prefix , correctIndex (start , self ), correctIndex (end , self ));
539539 }
540540
541- @ Specialization
541+ @ Specialization ( rewriteOn = ArithmeticException . class )
542542 boolean startsWith (String self , String prefix , PInt start , @ SuppressWarnings ("unused" ) PNone end ) {
543+ return startsWith (self , prefix , start .intValueExact (), self .length ());
544+ }
545+
546+ @ Specialization
547+ boolean startsWithPIntOvf (String self , String prefix , PInt start , @ SuppressWarnings ("unused" ) PNone end ) {
543548 return doIt (self , prefix , correctIndex (start , self ), self .length ());
544549 }
545550
@@ -563,11 +568,16 @@ boolean startsWith(String self, PTuple prefix, long start, long end) {
563568 return doIt (self , prefix , correctIndex (start , self ), correctIndex (end , self ));
564569 }
565570
566- @ Specialization
571+ @ Specialization ( rewriteOn = ArithmeticException . class )
567572 boolean startsWith (String self , PTuple prefix , PInt start , @ SuppressWarnings ("unused" ) PNone end ) {
573+ return startsWith (self , prefix , start .intValueExact (), end );
574+ }
575+
576+ @ Specialization
577+ boolean startsWithPIntOvf (String self , PTuple prefix , PInt start , @ SuppressWarnings ("unused" ) PNone end ) {
568578 return doIt (self , prefix , correctIndex (start , self ), self .length ());
569579 }
570-
580+
571581 @ Specialization
572582 boolean startsWith (String self , PTuple prefix , @ SuppressWarnings ("unused" ) PNone start , @ SuppressWarnings ("unused" ) PNone end ) {
573583 return startsWith (self , prefix , 0 , self .length ());
0 commit comments