@@ -1640,13 +1640,13 @@ public IRubyObject write(ThreadContext context, IRubyObject[] args) {
1640
1640
cat = lookup .findVirtual (RubyString .class , "catWithCodeRange" , MethodType .methodType (RubyString .class , RubyString .class ));
1641
1641
modify = lookup .findVirtual (RubyString .class , "modifyAndClearCodeRange" , MethodType .methodType (void .class ));
1642
1642
substr = lookup .findVirtual (RubyString .class , "substrEnc" , MethodType .methodType (IRubyObject .class , Ruby .class , int .class , int .class ));
1643
- checkEncoding = lookup .findStatic (RubyEncoding .class , "checkEncoding" , MethodType .methodType (void .class , ThreadContext .class , Encoding .class , CodeRangeable .class ));
1643
+ checkEncoding = lookup .findStatic (RubyEncoding .class , "checkEncoding" , MethodType .methodType (Encoding .class , ThreadContext .class , Encoding .class , CodeRangeable .class ));
1644
1644
} catch (NoSuchMethodException | IllegalAccessException ex ) {
1645
1645
try {
1646
1646
cat = lookup .findVirtual (RubyString .class , "cat19" , MethodType .methodType (RubyString .class , RubyString .class ));
1647
1647
modify = lookup .findVirtual (RubyString .class , "modify19" , MethodType .methodType (void .class ));
1648
1648
substr = lookup .findVirtual (RubyString .class , "substr19" , MethodType .methodType (IRubyObject .class , Ruby .class , int .class , int .class ));
1649
- checkEncoding = lookup .findStatic (StringIO .class , "checkEncoding" , MethodType .methodType (void .class , ThreadContext .class , Encoding .class , CodeRangeable .class ));
1649
+ checkEncoding = lookup .findStatic (StringIO .class , "checkEncoding" , MethodType .methodType (Encoding .class , ThreadContext .class , Encoding .class , CodeRangeable .class ));
1650
1650
} catch (NoSuchMethodException | IllegalAccessException ex2 ) {
1651
1651
throw new ExceptionInInitializerError (ex2 );
1652
1652
}
@@ -1737,7 +1737,7 @@ private long stringIOWrite(ThreadContext context, Ruby runtime, IRubyObject arg)
1737
1737
1738
1738
private static void rb_enc_check (ThreadContext context , Encoding enc , CodeRangeable str ) {
1739
1739
try {
1740
- CHECK_ENCODING .invokeExact (context , enc , str );
1740
+ Encoding ignored = ( Encoding ) CHECK_ENCODING .invokeExact (context , enc , str );
1741
1741
} catch (Throwable t ) {
1742
1742
Helpers .throwException (t );
1743
1743
}
@@ -1748,11 +1748,12 @@ private static void rb_enc_check(ThreadContext context, Encoding enc, CodeRangea
1748
1748
*
1749
1749
* See discussion in https://github.com/ruby/stringio/pull/116.
1750
1750
*/
1751
- private static void checkEncoding (ThreadContext context , Encoding enc , CodeRangeable str ) {
1752
- CodeRangeable fakeCodeRangeable = new EncodingOnlyCodeRangeable (enc );
1753
- Encoding enc1 = StringSupport .areCompatible (fakeCodeRangeable , str );
1754
- if (enc1 == null ) throw context .runtime .newEncodingCompatibilityError ("incompatible character encodings: " +
1755
- enc1 + " and " + str .getByteList ().getEncoding ());
1751
+ private static Encoding checkEncoding (ThreadContext context , Encoding encoding , CodeRangeable str ) {
1752
+ CodeRangeable fakeCodeRangeable = new EncodingOnlyCodeRangeable (encoding );
1753
+ Encoding enc = StringSupport .areCompatible (fakeCodeRangeable , str );
1754
+ if (enc == null ) throw context .runtime .newEncodingCompatibilityError ("incompatible character encodings: " +
1755
+ enc + " and " + str .getByteList ().getEncoding ());
1756
+ return enc ;
1756
1757
}
1757
1758
1758
1759
private static class EncodingOnlyCodeRangeable implements CodeRangeable {
0 commit comments