Skip to content

Commit

Permalink
Fix thisPredicateFunction{Completions,QuickInfo}02 tests.
Browse files Browse the repository at this point in the history
The Crate<T> class had a "this" type predicate that referenced the type
parameter T, preventing T from being covariant, which caused undesired
behavior elsewhere.  Apply the workaround described here:

#27686 (comment)
  • Loading branch information
mattmccutchen committed Mar 16, 2019
1 parent d47dbb7 commit 8de6b18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//// contents: T;
//// isSundries(): this is Crate<Sundries>;
//// isSupplies(): this is Crate<Supplies>;
//// isPackedTight(): this is (this & {extraContents: T});
//// isPackedTight<U>(this: this & Crate<U>): this is {extraContents: U};
//// }
//// const crate: Crate<any>;
//// if (crate.isPackedTight()) {
Expand Down
12 changes: 6 additions & 6 deletions tests/cases/fourslash/thisPredicateFunctionQuickInfo02.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//// contents: T;
//// /*1*/isSundries(): this is Crate<Sundries>;
//// /*2*/isSupplies(): this is Crate<Supplies>;
//// /*3*/isPackedTight(): this is (this & {extraContents: T});
//// /*3*/isPackedTight<U>(this: this & Crate<U>): this is {extraContents: U};
//// }
//// const crate: Crate<any>;
//// if (crate.isPackedTight/*4*/()) {
Expand All @@ -34,18 +34,18 @@
verify.quickInfos({
1: "(method) Crate<T>.isSundries(): this is Crate<Sundries>",
2: "(method) Crate<T>.isSupplies(): this is Crate<Supplies>",
3: `(method) Crate<T>.isPackedTight(): this is this & {
extraContents: T;
3: `(method) Crate<T>.isPackedTight<U>(this: this & Crate<U>): this is {
extraContents: U;
}`,
4: `(method) Crate<any>.isPackedTight(): this is Crate<any> & {
4: `(method) Crate<any>.isPackedTight<any>(this: Crate<any>): this is {
extraContents: any;
}`,
5: "(method) Crate<any>.isSundries(): this is Crate<Sundries>",
6: `(method) Crate<Sundries>.isPackedTight(): this is Crate<Sundries> & {
6: `(method) Crate<Sundries>.isPackedTight<Sundries>(this: Crate<Sundries>): this is {
extraContents: Sundries;
}`,
7: "(method) Crate<any>.isSupplies(): this is Crate<Supplies>",
8: `(method) Crate<Supplies>.isPackedTight(): this is Crate<Supplies> & {
8: `(method) Crate<Supplies>.isPackedTight<Supplies>(this: Crate<Supplies>): this is {
extraContents: Supplies;
}`
});

0 comments on commit 8de6b18

Please sign in to comment.