-
Notifications
You must be signed in to change notification settings - Fork 509
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better detection of enumerable type from an instance (#3358)
* Add failing tests * Change fallback type detection of Enumerable instance When detecting the type of an enumerable from an instance, `TypedEnumerable` tries to match it to a couple of well-known enumerable classes (like `Array`, `Hash`, etc). The fallback case, however, tries to match it to the class of the type that the instance is being validated against, which does not make a lot sense. That behaviour means, if the instance is being compared against `T::Array[Foo]`, we would try to infer the type of the enumerable instance as a kind of `T::Array`. But, if it was being compared against a `T::Set[Foo]`, then the type of the instance would be inferred to be a `T::Set`. This leads to the problem outlined in #2808. In reality, Sorbet should not try to infer the type based on what type the instance is being compared against, but should return the type of the instance as is.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
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