Skip to content

Commit

Permalink
Instead of calling Subject.actual(), store the actual value in a fiel…
Browse files Browse the repository at this point in the history
…d, and read that.

actual() is being removed.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=247039297
  • Loading branch information
cpovirk authored and ronshapiro committed May 8, 2019
1 parent cc350c6 commit ea179b9
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ public static <T, P extends CheckedProvider<T>> CheckedProviderSubject<T, P> ass
return assertAbout(CheckedProviderSubject.<T, P>checkedProviders()).that(provider);
}

private final P actual;

private CheckedProviderSubject(FailureMetadata failureMetadata, @Nullable P subject) {
super(failureMetadata, subject);
this.actual = subject;
}

/**
Expand All @@ -50,7 +53,7 @@ private CheckedProviderSubject(FailureMetadata failureMetadata, @Nullable P subj
* @return a {@link Subject} for asserting against the return value of {@link CheckedProvider#get}
*/
public Subject<?, Object> providedValue() {
P provider = actual();
P provider = actual;
T got;
try {
got = provider.get();
Expand All @@ -71,7 +74,7 @@ public Subject<?, Object> providedValue() {
* CheckedProvider#get}
*/
public ThrowableSubject thrownException() {
P provider = actual();
P provider = actual;
T got;
try {
got = provider.get();
Expand Down Expand Up @@ -103,8 +106,11 @@ public UnexpectedFailureSubject createSubject(FailureMetadata metadata, Throwabl

private static final class UnexpectedFailureSubject
extends Subject<UnexpectedFailureSubject, Throwable> {
private final Throwable actual;

UnexpectedFailureSubject(FailureMetadata metadata, @Nullable Throwable actual) {
super(metadata, actual);
this.actual = actual;
}

void doFail(String format, Object... args) {
Expand Down

0 comments on commit ea179b9

Please sign in to comment.