8000 Fix conflict with parameter named 'value' by guilhermearaujo · Pull Request #39 · jankuss/genq · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix conflict with parameter named 'value' #39

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

8000
Merged
merged 1 commit into from
Sep 22, 2024

Conversation

guilhermearaujo
Copy link
Contributor

There is a conflict when a class has a parameter named value
Example:

@genq
class Example with _$Example {
  factory Example({required int value}) = _Example;
}

Generates:

class _$ExampleCopyWithImpl implements $ExampleCopyWith {
  final _$Example value;

  _$ExampleCopyWithImpl(this.value);

  @override
  Example call({
    Object? value = genq,
  }) {
    return Example(
      value: value == genq ? value.value : value as int,
    );                             ^^^^^
  }
}

Which results in the error:
example.genq.dart:xx:yy: Error: The getter 'value' isn't defined for the class 'Object?'

The fixed output should use __value instead:

class _$ExampleCopyWithImpl implements $ExampleCopyWith {
  final _$Example __value;

  _$ExampleCopyWithImpl(this.__value);

  @override
  Example call({
    Object? value = genq,
  }) {
    return Example(
      value: value == genq ? __value.value : value as int,
    );
  }
}

@jankuss jankuss self-requested a review September 22, 2024 22:07
@jankuss jankuss merged commit ca8cdfa into jankuss:main Sep 22, 2024
8 checks passed
@jankuss
Copy link
Owner
jankuss commented Sep 22, 2024

Good catch, thank you for your contribution! This fix is included in the 0.5.1 release.

brew upgrade jankuss/genq/genq

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

Successfully merging this pull request may close these issues.

2 participants
0