|
62 | 62 | import org.jruby.api.Create; |
63 | 63 | import org.jruby.api.JRubyAPI; |
64 | 64 | import org.jruby.ast.util.ArgsUtil; |
65 | | -import org.jruby.common.IRubyWarnings.ID; |
66 | 65 | import org.jruby.exceptions.JumpException; |
67 | 66 | import org.jruby.platform.Platform; |
68 | 67 | import org.jruby.runtime.Arity; |
|
89 | 88 | import java.util.Locale; |
90 | 89 | import java.util.function.Function; |
91 | 90 |
|
92 | | -import static org.jruby.ObjectFlags.CHILLED_F; |
| 91 | +import static org.jruby.ObjectFlags.CHILLED_LITERAL_F; |
| 92 | +import static org.jruby.ObjectFlags.CHILLED_SYMBOL_TO_S_F; |
93 | 93 | import static org.jruby.RubyComparable.invcmp; |
94 | 94 | import static org.jruby.RubyEnumerator.SizeFn; |
95 | 95 | import static org.jruby.RubyEnumerator.enumeratorize; |
@@ -984,12 +984,20 @@ public final void ensureInstanceVariablesSettable() { |
984 | 984 | } |
985 | 985 |
|
986 | 986 | private void mutateChilledString() { |
987 | | - getRuntime().getWarnings().warn("literal string will be frozen in the future"); |
988 | | - flags &= ~CHILLED_F; |
| 987 | + if ((flags & CHILLED_LITERAL_F) != 0) { |
| 988 | + getRuntime().getWarnings().warn("literal string will be frozen in the future"); |
| 989 | + } else if ((flags & CHILLED_SYMBOL_TO_S_F) != 0) { |
| 990 | + getRuntime().getWarnings().warn("string returned by :" + value + ".to_s will be frozen in the future"); |
| 991 | + } |
| 992 | + flags &= ~(CHILLED_LITERAL_F|CHILLED_SYMBOL_TO_S_F); |
989 | 993 | } |
990 | 994 |
|
991 | 995 | protected boolean isChilled() { |
992 | | - return (flags & CHILLED_F) != 0; |
| 996 | + return (flags & (CHILLED_LITERAL_F|CHILLED_SYMBOL_TO_S_F)) != 0; |
| 997 | + } |
| 998 | + |
| 999 | + protected boolean isChilledLiteral() { |
| 1000 | + return (flags & CHILLED_LITERAL_F) != 0; |
993 | 1001 | } |
994 | 1002 |
|
995 | 1003 | /** rb_str_modify |
@@ -6803,14 +6811,19 @@ public IRubyObject scrub_bang(ThreadContext context, IRubyObject repl, Block blo |
6803 | 6811 |
|
6804 | 6812 | @JRubyMethod @JRubyAPI |
6805 | 6813 | public IRubyObject freeze(ThreadContext context) { |
6806 | | - if (isChilled()) flags &= ~CHILLED_F; |
| 6814 | + if (isChilled()) flags &= ~(CHILLED_LITERAL_F|CHILLED_SYMBOL_TO_S_F); |
6807 | 6815 | if (isFrozen()) return this; |
6808 | 6816 | resize(size()); |
6809 | 6817 | return super.freeze(context); |
6810 | 6818 | } |
6811 | 6819 |
|
6812 | 6820 | public RubyString chill() { |
6813 | | - flags |= CHILLED_F; |
| 6821 | + flags |= CHILLED_LITERAL_F; |
| 6822 | + return this; |
| 6823 | + } |
| 6824 | + |
| 6825 | + public RubyString chill_symbol_string() { |
| 6826 | + flags |= CHILLED_SYMBOL_TO_S_F; |
6814 | 6827 | return this; |
6815 | 6828 | } |
6816 | 6829 |
|
|
0 commit comments