Skip to content

Fix double props when inherited from parameterized class [#1228] #1303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 22, 2016

Conversation

astashov
Copy link
Contributor

@astashov astashov commented Dec 22, 2016

Sometimes, when a subclass inherits a property from a parameterized
class, the property appears twice in the docs.

That happens, because (by some reason, I'm not sure why) the field
objects for those getters and setters have different references
(though they are the same - their names are the same, returning types
are the same, etc). Since FieldElementImpl doesn't override default
equality, after we added the field for getter into
_inheritedProperties, when handling setter, we compare fields of
getter and setter by reference there:

if (_inheritedProperties.any((f) => f.element == e)) {

And usually these are the same object, so we won't see 2 properties in
the generated docs. But in that case by some reason they are 2 different
objects, so we add the field of the setter as well, and then we have 2
same props in the generated docs as a result.

It seems like we can safely compare their names (since there couldn't be
2 properties with the same name in a class anyway). That would fix the
problem.

I've added that in this commit, and also a unit test covering that case.

Fixes #1228

]

Sometimes, when a subclass inherits properties from a parameterized
class, they appear twice in the docs.

That happens, because (by some reason, I'm not sure why) the field
objects for those getters and setters have different references
(though they are the same - their names are the same, returning types
are the same, etc). Since `FieldElementImpl` doesn't override default
equality, after we added the field for getter into
`_inheritedProperties`, when handling setter, we compare fields of
getter and setter by reference there:

https://github.com/dart-lang/dartdoc/blob/38a7863ed87892461d6ac4c448a6a719fbe95463/lib/src/model.dart#L479

And usually these are the same object, so we won't see 2 properties in
the generated docs. But in that case by some reason they are 2 different
objects, so we add the field of the setter as well, and then we have 2
same props in the generated docs as a result.

It seems like we can safely compare their names (since there couldn't be
2 properties with the same name in a class anyway). That would fix the
problem.

I've added that in this commit, and also a unit test covering that case.

Fixes dart-lang#1228
@googlebot googlebot added the cla: yes Google CLA check succeeded. label Dec 22, 2016
@devoncarew
Copy link
Member

Thanks! and lgtm

@devoncarew devoncarew merged commit d0db2f9 into dart-lang:master Dec 22, 2016
@astashov astashov deleted the fix-inherited-double-props branch December 22, 2016 23:15
@Hixie
Copy link
Contributor

Hixie commented Dec 22, 2016

We really should figure out why we're getting two setters and getters. There could be an underlying more serious bug there.

@astashov
Copy link
Contributor Author

It's not 2 setters and getters, it's a setter and a getter have variable property, which usually returns the same object for both getter and setter, and the code relied on that. And in this edge case their variable property by some reason return different, but equal objects (they have different hashCodes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Duplicate entries in Flutter docs for RectTween members begin and end
4 participants