Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/private/js_string.dart

Issue 3005533002: Fix the return type of String.split in DDC to be correct (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/corelib_2/corelib_2.status » ('j') | tests/corelib_2/corelib_2.status » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart._interceptors; 5 part of dart._interceptors;
6 6
7 /** 7 /**
8 * The interceptor class for [String]. The compiler recognizes this 8 * The interceptor class for [String]. The compiler recognizes this
9 * class as an interceptor, and changes references to [:this:] to 9 * class as an interceptor, and changes references to [:this:] to
10 * actually use the receiver of the method, which is generated as an extra 10 * actually use the receiver of the method, which is generated as an extra
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 String replaceFirstMapped( 90 String replaceFirstMapped(
91 Pattern from, @nullCheck String replace(Match match), 91 Pattern from, @nullCheck String replace(Match match),
92 [@nullCheck int startIndex = 0]) { 92 [@nullCheck int startIndex = 0]) {
93 RangeError.checkValueInInterval(startIndex, 0, this.length, "startIndex"); 93 RangeError.checkValueInInterval(startIndex, 0, this.length, "startIndex");
94 return stringReplaceFirstMappedUnchecked(this, from, replace, startIndex); 94 return stringReplaceFirstMappedUnchecked(this, from, replace, startIndex);
95 } 95 }
96 96
97 @notNull 97 @notNull
98 List<String> split(@nullCheck Pattern pattern) { 98 List<String> split(@nullCheck Pattern pattern) {
99 if (pattern is String) { 99 if (pattern is String) {
100 return JS('JSExtendableArray', r'#.split(#)', this, pattern); 100 return new JSArray.of(JS('', r'#.split(#)', this, pattern));
101 } else if (pattern is JSSyntaxRegExp && regExpCaptureCount(pattern) == 0) { 101 } else if (pattern is JSSyntaxRegExp && regExpCaptureCount(pattern) == 0) {
102 var re = regExpGetNative(pattern); 102 var re = regExpGetNative(pattern);
103 return JS('JSExtendableArray', r'#.split(#)', this, re); 103 return new JSArray.of(JS('', r'#.split(#)', this, re));
104 } else { 104 } else {
105 return _defaultSplit(pattern); 105 return _defaultSplit(pattern);
106 } 106 }
107 } 107 }
108 108
109 @notNull 109 @notNull
110 String replaceRange( 110 String replaceRange(
111 @nullCheck int start, int end, @nullCheck String replacement) { 111 @nullCheck int start, int end, @nullCheck String replacement) {
112 end = RangeError.checkValidRange(start, end, this.length); 112 end = RangeError.checkValidRange(start, end, this.length);
113 return stringReplaceRangeUnchecked(this, start, end, replacement); 113 return stringReplaceRangeUnchecked(this, start, end, replacement);
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 int get length => JS('int', r'#.length', this); 499 int get length => JS('int', r'#.length', this);
500 500
501 @notNull 501 @notNull
502 String operator [](@nullCheck int index) { 502 String operator [](@nullCheck int index) {
503 if (index >= JS('int', '#.length', this) || index < 0) { 503 if (index >= JS('int', '#.length', this) || index < 0) {
504 throw diagnoseIndexError(this, index); 504 throw diagnoseIndexError(this, index);
505 } 505 }
506 return JS('String', '#[#]', this, index); 506 return JS('String', '#[#]', this, index);
507 } 507 }
508 } 508 }
OLDNEW
« no previous file with comments | « no previous file | tests/corelib_2/corelib_2.status » ('j') | tests/corelib_2/corelib_2.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698