Skip to content

service_worker_test.dart has a type error #99522

@christopherfujino

Description

@christopherfujino

The //dev/bots/service_worker_test.dart file has a custom, null-safe implementation of expect() that can run outside of test zones: https://github.com/flutter/flutter/blob/master/dev/bots/service_worker_test.dart#L61. Note the lines:

  final Map<Object, Object> matchState = <Object, Object>{};
  if (matcher.matches(actual, matchState)) {

When #96774 made a change that should have failed this expectation, rather than throwing a TestFailure, it actually threw a type error:

Unhandled exception:
type '_InternalLinkedHashMap<dynamic, dynamic>' is not a subtype of type 'Map<Object, Object>' of 'other'
#0      _InternalLinkedHashMap.addAll (dart:collection-patch/compact_hash.dart)
#1      addStateInfo (package:matcher/src/util.dart:29:14)
#2      _DeepMatcher.matches (package:matcher/src/equals_matcher.dart:261:5)
#3      expect (file:///b/s/w/ir/x/w/flutter/dev/bots/service_worker_test.dart:61:15)
#4      runWebServiceWorkerTest.expectRequestCounts (file:///b/s/w/ir/x/w/flutter/dev/bots/service_worker_test.dart:76:5)
#5      runWebServiceWorkerTest (file:///b/s/w/ir/x/w/flutter/dev/bots/service_worker_test.dart:137:5)
<asynchronous suspension>
#6      _runShardRunnerIndexOfTotalSubshard (file:///b/s/w/ir/x/w/flutter/dev/bots/test.dart:1931:5)
<asynchronous suspension>
#7      _runWebLongRunningTests (file:///b/s/w/ir/x/w/flutter/dev/bots/test.dart:1115:3)
<asynchronous suspension>
#8      _runFromList (file:///b/s/w/ir/x/w/flutter/dev/bots/test.dart:1973:5)
<asynchronous suspension>
#9      main (file:///b/s/w/ir/x/w/flutter/dev/bots/test.dart:199:5)
<asynchronous suspension>

This is because an internal, untyped map literal in package:matcher https://github.com/dart-lang/matcher/blob/0.12.11/lib/src/equals_matcher.dart#L261 is inferred to be Map<dynamic, dynamic> which is not of the same type as the null-safe typed map literal in service_worker_test.dart.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our teststeam-infraOwned by Infrastructure team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions