Skip to content

(#1572) Covariance for func.FuncWithFallback #1607

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 6 commits into from
May 13, 2021

Conversation

DmitryBarskov
Copy link
Contributor

For #1572:

  • Generify ScalarWithFallback (generify this class since FuncWithFallback depends on it)
  • Generify FuncWithFallback

Now fallbacks for ScalarWithFallback and FuncWithFallback can produce object derived types from given original type.

Fallback<Long> longOnNoFile = new Fallback.From<>(FileNotFoundException.class, _t -> 0L);
Fallback<Double> doubleOnIo = new Fallback.From<>(IOException.class, _t -> 0.0);
Fallback<Integer> intOtherwise = new Fallback.From<>(Exception.class, _t -> 0);

Func<String, Number> readFileLength = new FuncOf<>(fileName -> {
  throw new IOException("Access denied. You can't read file " + fileName);
});

FuncWithFallback<String, Number> safeReadFileLength =
  new FuncWithFallback<String, Number>(
    readFileLength,
    longOnNoFile,
    doubleOnIo,
    intOtherwise
  );

Copy link
Collaborator

@victornoel victornoel left a comment

Choose a reason for hiding this comment

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

@DmitryBarskov Scalar is missing the covariance too.

@DmitryBarskov DmitryBarskov requested a review from victornoel May 12, 2021 09:49
@victornoel
Copy link
Collaborator

@rultor merge

@rultor
Copy link
Collaborator

rultor commented May 13, 2021

@rultor merge

@victornoel OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 9fbb757 into yegor256:master May 13, 2021
@rultor
Copy link
Collaborator

rultor commented May 13, 2021

@rultor merge

@victornoel Done! FYI, the full log is here (took me 8min)

@victornoel
Copy link
Collaborator

@0crat status

@DmitryBarskov DmitryBarskov deleted the issue-1572 branch June 10, 2021 16:43
@0crat 0crat removed the 0crat/scope label Jun 11, 2021
@0crat
Copy link
Collaborator

0crat commented Jun 11, 2021

@andreoss/z resigned from #1607, since the job is not in scope anymore

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.

5 participants