@@ -405,27 +405,29 @@ String doSSSimple(String self, String other) {
405
405
}
406
406
407
407
@ Specialization (guards = "!concatGuard(self, other.getCharSequence())" )
408
- Object doSSSimple (String self , PString other ) {
408
+ String doSSSimple (String self , PString other ) {
409
409
if (LazyString .length (self , leftProfile1 , leftProfile2 ) == 0 ) {
410
- return other ;
410
+ // result type has to be str
411
+ return toString (other .getCharSequence ());
411
412
}
412
413
return self ;
413
414
}
414
415
415
416
@ Specialization (guards = "!concatGuard(self.getCharSequence(), other)" )
416
- Object doSSSimple (PString self , String other ) {
417
+ String doSSSimple (PString self , String other ) {
417
418
if (LazyString .length (self .getCharSequence (), leftProfile1 , leftProfile2 ) == 0 ) {
418
419
return other ;
419
420
}
420
- return self ;
421
+ // result type has to be str
422
+ return toString (self .getCharSequence ());
421
423
}
422
424
423
425
@ Specialization (guards = "!concatGuard(self.getCharSequence(), other.getCharSequence())" )
424
- PString doSSSimple (PString self , PString other ) {
426
+ String doSSSimple (PString self , PString other ) {
425
427
if (LazyString .length (self .getCharSequence (), leftProfile1 , leftProfile2 ) == 0 ) {
426
- return other ;
428
+ return toString ( other . getCharSequence ()) ;
427
429
}
428
- return self ;
430
+ return toString ( self . getCharSequence ()) ;
429
431
}
430
432
431
433
@ Specialization (guards = "concatGuard(self.getCharSequence(), other)" )
@@ -474,6 +476,11 @@ private static String stringConcat(CharSequence left, CharSequence right) {
474
476
return left .toString () + right .toString ();
475
477
}
476
478
479
+ @ TruffleBoundary
480
+ private static String toString (CharSequence cs ) {
481
+ return cs .toString ();
482
+ }
483
+
477
484
@ Specialization (guards = "isString(self)" )
478
485
Object doSNative (VirtualFrame frame , Object self , PythonAbstractNativeObject other ,
479
486
@ Cached CastToJavaStringNode cast ,
0 commit comments