Closed
Description
I'm working on a CL that adds strong mode type checks to invocations. The CL is currently failing tests like language_2/reg_ex2_test
with exceptions like this:
Unhandled exception:
type 'List' is not a subtype of type 'List<int>' where
List is from dart:core
List is from dart:core
int is from dart:core
#0 _RegExp.firstMatch (dart:core)
#1 RegEx2Test.testMain (file:///usr/local/google/home/paulberry/dart1/sdk/tests/language_2/reg_ex2_test.dart:10:32)
#2 main (file:///usr/local/google/home/paulberry/dart1/sdk/tests/language_2/reg_ex2_test.dart:25:14)
#3 _startIsolate.<anonymous closure> (dart:isolate:1252:19)
#4 _RawReceivePortImpl._handleMessage (dart:isolate:1142:12)
For reference, the definition of firstMatch
is:
Match firstMatch(String str) {
if (str is! String) throw new ArgumentError(str);
List match = _ExecuteMatch(str, 0);
if (match == null) {
return null;
}
return new _RegExpMatch(this, str, match);
}
and the definition of _ExecuteMatch
is:
List _ExecuteMatch(String str, int start_index) native "RegExp_ExecuteMatch";
The problem is that _RegExpMatch
requires its third argument to be List<int>
, but RegExp_ExecuteMatch
apparently returns List
.
An alternative fix would be to change the type of _RegExpMatch._match
to List
, however this would be less performant because it would incur an implicit downcast in _RegExpMatch._start
and _RegExpMatch._end
.