-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Feed the 'this' type as a type argument to constraints during relation checking #7290
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0abb4c9
Added tests.
DanielRosenwasser daf1596
Accepted baselines.
DanielRosenwasser cdd10b0
Instantiate type parameters with themselves as their 'this' type when…
DanielRosenwasser 268b2d4
Accepted baselines.
DanielRosenwasser fa67cb8
Merge remote-tracking branch 'origin/master' into thisTypesInBaseProp…
DanielRosenwasser ee4baef
Applied suggested change.
DanielRosenwasser b75605e
Accepted baselines.
DanielRosenwasser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/recurringTypeParamForContainerOfBase01.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//// [recurringTypeParamForContainerOfBase01.ts] | ||
|
||
interface BoxOfFoo<T extends Foo<T>> { | ||
item: T | ||
} | ||
|
||
interface Foo<T extends Foo<T>> { | ||
self: T; | ||
} | ||
|
||
interface Bar<T extends Bar<T>> extends Foo<T> { | ||
other: BoxOfFoo<T>; | ||
} | ||
|
||
//// [recurringTypeParamForContainerOfBase01.js] | ||
|
||
|
||
//// [recurringTypeParamForContainerOfBase01.d.ts] | ||
interface BoxOfFoo<T extends Foo<T>> { | ||
item: T; | ||
} | ||
interface Foo<T extends Foo<T>> { | ||
self: T; | ||
} | ||
interface Bar<T extends Bar<T>> extends Foo<T> { | ||
other: BoxOfFoo<T>; | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/recurringTypeParamForContainerOfBase01.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
=== tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts === | ||
|
||
interface BoxOfFoo<T extends Foo<T>> { | ||
>BoxOfFoo : Symbol(BoxOfFoo, Decl(recurringTypeParamForContainerOfBase01.ts, 0, 0)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 1, 19)) | ||
>Foo : Symbol(Foo, Decl(recurringTypeParamForContainerOfBase01.ts, 3, 1)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 1, 19)) | ||
|
||
item: T | ||
>item : Symbol(BoxOfFoo.item, Decl(recurringTypeParamForContainerOfBase01.ts, 1, 38)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 1, 19)) | ||
} | ||
|
||
interface Foo<T extends Foo<T>> { | ||
>Foo : Symbol(Foo, Decl(recurringTypeParamForContainerOfBase01.ts, 3, 1)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 5, 14)) | ||
>Foo : Symbol(Foo, Decl(recurringTypeParamForContainerOfBase01.ts, 3, 1)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 5, 14)) | ||
|
||
self: T; | ||
>self : Symbol(Foo.self, Decl(recurringTypeParamForContainerOfBase01.ts, 5, 33)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 5, 14)) | ||
} | ||
|
||
interface Bar<T extends Bar<T>> extends Foo<T> { | ||
>Bar : Symbol(Bar, Decl(recurringTypeParamForContainerOfBase01.ts, 7, 1)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 14)) | ||
>Bar : Symbol(Bar, Decl(recurringTypeParamForContainerOfBase01.ts, 7, 1)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 14)) | ||
>Foo : Symbol(Foo, Decl(recurringTypeParamForContainerOfBase01.ts, 3, 1)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 14)) | ||
|
||
other: BoxOfFoo<T>; | ||
>other : Symbol(Bar.other, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 48)) | ||
>BoxOfFoo : Symbol(BoxOfFoo, Decl(recurringTypeParamForContainerOfBase01.ts, 0, 0)) | ||
>T : Symbol(T, Decl(recurringTypeParamForContainerOfBase01.ts, 9, 14)) | ||
} |
37 changes: 37 additions & 0 deletions
37
tests/baselines/reference/recurringTypeParamForContainerOfBase01.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
=== tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts === | ||
|
||
interface BoxOfFoo<T extends Foo<T>> { | ||
>BoxOfFoo : BoxOfFoo<T> | ||
>T : T | ||
>Foo : Foo<T> | ||
>T : T | ||
|
||
item: T | ||
>item : T | ||
>T : T | ||
} | ||
|
||
interface Foo<T extends Foo<T>> { | ||
>Foo : Foo<T> | ||
>T : T | ||
>Foo : Foo<T> | ||
>T : T | ||
|
||
self: T; | ||
>self : T | ||
>T : T | ||
} | ||
|
||
interface Bar<T extends Bar<T>> extends Foo<T> { | ||
>Bar : Bar<T> | ||
>T : T | ||
>Bar : Bar<T> | ||
>T : T | ||
>Foo : Foo<T> | ||
>T : T | ||
|
||
other: BoxOfFoo<T>; | ||
>other : BoxOfFoo<T> | ||
>BoxOfFoo : BoxOfFoo<T> | ||
>T : T | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//// [thisTypeInBasePropertyAndDerivedContainerOfBase01.ts] | ||
|
||
interface BoxOfFoo<T extends Foo> { | ||
item: T | ||
} | ||
|
||
interface Foo { | ||
self: this; | ||
} | ||
|
||
interface Bar extends Foo { | ||
other: BoxOfFoo<this>; | ||
} | ||
|
||
//// [thisTypeInBasePropertyAndDerivedContainerOfBase01.js] | ||
|
||
|
||
//// [thisTypeInBasePropertyAndDerivedContainerOfBase01.d.ts] | ||
interface BoxOfFoo<T extends Foo> { | ||
item: T; | ||
} | ||
interface Foo { | ||
self: this; | ||
} | ||
interface Bar extends Foo { | ||
other: BoxOfFoo<this>; | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
=== tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts === | ||
|
||
interface BoxOfFoo<T extends Foo> { | ||
>BoxOfFoo : Symbol(BoxOfFoo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 0, 0)) | ||
>T : Symbol(T, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 1, 19)) | ||
>Foo : Symbol(Foo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 3, 1)) | ||
|
||
item: T | ||
>item : Symbol(BoxOfFoo.item, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 1, 35)) | ||
>T : Symbol(T, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 1, 19)) | ||
} | ||
|
||
interface Foo { | ||
>Foo : Symbol(Foo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 3, 1)) | ||
|
||
self: this; | ||
>self : Symbol(Foo.self, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 5, 15)) | ||
} | ||
|
||
interface Bar extends Foo { | ||
>Bar : Symbol(Bar, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 7, 1)) | ||
>Foo : Symbol(Foo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 3, 1)) | ||
|
||
other: BoxOfFoo<this>; | ||
>other : Symbol(Bar.other, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 9, 27)) | ||
>BoxOfFoo : Symbol(BoxOfFoo, Decl(thisTypeInBasePropertyAndDerivedContainerOfBase01.ts, 0, 0)) | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/baselines/reference/thisTypeInBasePropertyAndDerivedContainerOfBase01.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
=== tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts === | ||
|
||
interface BoxOfFoo<T extends Foo> { | ||
>BoxOfFoo : BoxOfFoo<T> | ||
>T : T | ||
>Foo : Foo | ||
|
||
item: T | ||
>item : T | ||
>T : T | ||
} | ||
|
||
interface Foo { | ||
>Foo : Foo | ||
|
||
self: this; | ||
>self : this | ||
} | ||
|
||
interface Bar extends Foo { | ||
>Bar : Bar | ||
>Foo : Foo | ||
|
||
other: BoxOfFoo<this>; | ||
>other : BoxOfFoo<this> | ||
>BoxOfFoo : BoxOfFoo<T> | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/cases/conformance/types/thisType/thisTypeInBasePropertyAndDerivedContainerOfBase01.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @declaration: true | ||
|
||
interface BoxOfFoo<T extends Foo> { | ||
item: T | ||
} | ||
|
||
interface Foo { | ||
self: this; | ||
} | ||
|
||
interface Bar extends Foo { | ||
other: BoxOfFoo<this>; | ||
} |
13 changes: 13 additions & 0 deletions
13
tests/cases/conformance/types/typeParameters/recurringTypeParamForContainerOfBase01.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @declaration: true | ||
|
||
interface BoxOfFoo<T extends Foo<T>> { | ||
item: T | ||
} | ||
|
||
interface Foo<T extends Foo<T>> { | ||
self: T; | ||
} | ||
|
||
interface Bar<T extends Bar<T>> extends Foo<T> { | ||
other: BoxOfFoo<T>; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this go away? We instantiate
this
as 'C', then somehow we don't notice thatalsoWorks
is missing now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure, but I have some thoughts which we can discuss offline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the result of the offline discussion:
The error's already elaborated at line 26. So now that
this
is instantiated asC
, the compiler knows that it's already reported this error once. (We think :) So it's fine to drop it here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this looks like a case of an elaboration that was already made and subsequently cached.