Skip to content
This repository has been archived by the owner on Dec 6, 2017. It is now read-only.

Is di.key.Key code right ? #94

Closed
vicb opened this issue Apr 26, 2014 · 2 comments
Closed

Is di.key.Key code right ? #94

vicb opened this issue Apr 26, 2014 · 2 comments

Comments

@vicb
Copy link
Contributor

vicb commented Apr 26, 2014

  factory Key(Type type, [Type annotation]) {
    var _hashCode = type.hashCode + annotation.hashCode;
    var _id = _hashToKey.putIfAbsent(_hashCode, () => _lastKeyId++);
    return new Key._newKey(type, annotation, _hashCode, _id);
  }

  Key._newKey(this.type, this.annotation, this.hashCode, this.id);

  bool operator ==(other) =>
      other is Key && other.hashCode == hashCode;

Is this code right ?

I think Key(A, B) == Key (B, A) is wrong.

Two objects that are equal have the same hash code but two objects with the same hash code are not necessary equal (however this is assumed by the current code)

pavelgj added a commit to pavelgj/di.dart that referenced this issue Apr 27, 2014
@pavelgj
Copy link
Contributor

pavelgj commented Apr 27, 2014

@vicb Good catch. Fix PR: #96

@vicb vicb mentioned this issue Apr 28, 2014
@pavelgj pavelgj closed this as completed in d1f7dde May 5, 2014
pavelgj pushed a commit to pavelgj/di.dart that referenced this issue May 5, 2014
@pavelgj
Copy link
Contributor

pavelgj commented May 5, 2014

Fixed via f673267

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants