File tree Expand file tree Collapse file tree 1 file changed +28
-6
lines changed Expand file tree Collapse file tree 1 file changed +28
-6
lines changed Original file line number Diff line number Diff line change @@ -60,11 +60,30 @@ class FieldIndex {
6060
6161 static void validate (Translator translator) {
6262 void check (Class cls, String name, int expectedIndex) {
63- assert (
64- translator.fieldIndex[
65- cls.fields.firstWhere ((f) => f.name.text == name)] ==
66- expectedIndex,
67- "Unexpected field index for ${cls .name }.$name " );
63+ Field ? field;
64+
65+ for (Field clsField in cls.fields) {
66+ if (clsField.name.text == name) {
67+ field = clsField;
68+ break ;
69+ }
70+ }
71+
72+ if (field == null ) {
73+ throw AssertionError ("$cls doesn't have field $name " );
74+ }
75+
76+ final actualIndex = translator.fieldIndex[field];
77+
78+ if (actualIndex == null ) {
79+ throw AssertionError ("$cls field $name doesn't have an index assigned" );
80+ }
81+
82+ if (actualIndex != expectedIndex) {
83+ throw AssertionError (
84+ "$cls field $name expected index = $expectedIndex , "
85+ "actual index = $actualIndex " );
86+ }
6887 }
6988
7089 check (translator.asyncSuspendStateClass, "_resume" ,
@@ -510,7 +529,10 @@ class ClassInfoCollector {
510529 }
511530
512531 // Validate that all internally used fields have the expected indices.
513- FieldIndex .validate (translator);
532+ assert ((() {
533+ FieldIndex .validate (translator);
534+ return true ;
535+ })());
514536 }
515537}
516538
You can’t perform that action at this time.
0 commit comments