-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dyno: Improve initialization of fields from non-matching types (#26219)
Prior to this PR InitResolver would always use the RHS type of field initialization statements to set the type of the field. For example, in "this.foo = RHS;", the field 'foo' would always use the type of RHS when resolving any relevant initialization calls (e.g. assignment). A real-world example is initializing a nilable class from ``nil``. This PR uses ``Resolver::getTypeForDecl`` to check that the types are compatible, and then uses the computed type for 'foo'. This PR also includes various other improvements needed to get tests working: - correctly identifying field initialization during call-init-deinit (thanks to @brandon-neth) - fix faulty "invalid class type construction" error when not dealing with managed classes - Enable comparisons between types and ``?`` - Fix for faulty ``isCoercible`` error (mistakenly attempted to resolve as a method) - Update ``isRecordLike`` in call-init-deinit to return false for any-managed - Improve syntactic detection of genericity for managed and nilable classes (thanks to @DanilaFe) Thusly, new tests are added to demonstrate correct initialization of generic fields when initialized from a type that does not match. [reviewed-by @DanilaFe]
- Loading branch information
Showing
9 changed files
with
335 additions
and
52 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
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
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
Oops, something went wrong.