Skip to content
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

When the common type of a shared property is not accessible within the library, attempt again with an ancestor type #851

Open
CodingSoot opened this issue Feb 5, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@CodingSoot
Copy link

The feature introduced in #740 is great.

However, sometimes the common type might not be accessible in the freezed file, which causes errors.

For example :

// In a library which only exports A, B and C and Common1 but doesn't export Common2
class Common1 {}

class Common2 extends Common1 {}

class A extends Common2{}

class B extends Common2{}
// In a different library that imports the library above
@freezed
class MyUnion with _$MyUnion {
  const factory MyUnion.first(A param) = _First;

  const factory MyUnion.second(B param) = _Second;
}

The generated getter is Common2 get param => throw _privateConstructorUsedError;, with an error Undefined class 'Common2'.

What should instead happen is skip the common type Common2, and pick instead Common1 which is higher in the class hierarchy but is accessible.

@CodingSoot CodingSoot added bug Something isn't working needs triage labels Feb 5, 2023
@rrousselGit rrousselGit changed the title Common properties nearest common type should be accessible When the common type of a shared property is not accessible within the library, attempt again with an ancestor type Feb 5, 2023
@rrousselGit rrousselGit added enhancement New feature or request and removed bug Something isn't working needs triage labels Feb 5, 2023
@rrousselGit rrousselGit self-assigned this May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants