Skip to content

Two internal types created from one type declaration when a test uses relative imports #41868

@escamoteur

Description

@escamoteur
  • Dart SDK Version (dart --version)
    Dart VM version: 2.9.0-7.0.dev.flutter-617bc54b71 (be) (Thu May 7 23:23:09 2020 +0000) on "windows_x64"

  • Whether you are using Windows, MacOSX, or Linux (if applicable)
    Windows

A user of my package get_it raised an issue that a type that he registered in GetIt was not available when he tried to access it later.

GetIt uses internally a `map<Type,Object> to store registered Objects. When debugging the test I observed that the type in question was indeed stored in the map and that the type that was passed to access it was the same type but still the map returned always null.
When comparing the hashcodes of both type instances they were different.

Following a hunch I changed all relative imports to package imports because there were problems before and suddenly it worked.

I tried to reproduce it in a new project but didn't succeed. So I stripped down the project that had the problem.

Please watch this screencast:
https://www.screencast.com/t/dqufsChuC

you find the project here: https://github.com/escamoteur/spacex_flights_get_it_assertion

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed-as-intendedClosed as the reported issue is expected behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions