Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[pigeon] Made using enums in type arguments an error, added workaround#527

Merged
fluttergithubbot merged 2 commits intoflutter:masterfrom
gaaclarke:error-enum-in-type-arg
Nov 30, 2021
Merged

[pigeon] Made using enums in type arguments an error, added workaround#527
fluttergithubbot merged 2 commits intoflutter:masterfrom
gaaclarke:error-enum-in-type-arg

Conversation

@gaaclarke
Copy link
Member

@gaaclarke gaaclarke commented Nov 24, 2021

There are a lot of features related to enum's we don't yet support. Issuing an error in the front-end is better than a compilation error later.

As a workaround I started always generating enums in code whether they were referenced or not so users can use their integer values.

issues:

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@gaaclarke gaaclarke force-pushed the error-enum-in-type-arg branch from a717e3c to b9d982e Compare November 24, 2021 21:53
@gaaclarke gaaclarke changed the title [pigeon] Made using enums in type arguments an error. [pigeon] Made using enums in type arguments an error, added workaround Nov 24, 2021
Copy link
Collaborator

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits

* [ci] Started transitioning to a Dart test runner, added windows support.
* [front-end] Started issuing an error if enums are used in type arguments.
* [front-end] Passed through all enums, referenced or not so they can be used as
a work around for direct enum support.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: There's now a style guide for CHANGELOGs, so these should follow it (e.g., Starts issuing, Passes through)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

.removeWhere((Class x) => !referencedTypeNames.contains(x.name));

final List<Enum> referencedEnums = List<Enum>.from(_enums);
referencedEnums.removeWhere(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to leave a TODO here to re-add this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily. Only generating output for referenced types has lead to a lot of bugs. It was necessary when we we were using reflection, now it isn't needed. If we start supporting multiple imports in pigeon files we might have to revisit it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants