-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix subtype match of generic object types (#24430)
split from #24425 Matching `tyGenericBody` performs a match on the last child of the generic body, in this case the uninstantied `tyObject` type. If the object contains no generic fields, this ends up being the same type as all instantiated ones, but if it does, a new type is created. This fails the `sameObjectTypes` check that subtype matching for object types uses. To fix this, also consider that the pattern type could be the generic uninstantiated object type of the matched type in subtype matching.
- Loading branch information
Showing
3 changed files
with
50 additions
and
2 deletions.
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
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,18 @@ | ||
block: # has generic field | ||
type | ||
Foo[T] = object of RootObj | ||
x: T | ||
Bar = object of Foo[int] | ||
|
||
proc foo(x: typedesc[Foo]) = discard | ||
|
||
foo(Bar) | ||
|
||
block: # no generic field | ||
type | ||
Foo[T] = object of RootObj | ||
Bar = object of Foo[int] | ||
|
||
proc foo(x: typedesc[Foo]) = discard | ||
|
||
foo(Bar) |