-
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.
Treat associated constants as entities parameterized by Self (#4837)
Add a full entity representation for associated constants, and build a `Generic` object for them. This `Generic` is parameterized by the enclosing `Self` type, allowing the use of `Self` within the type of the associated constant to be supported. When performing impl lookup for an associated constant, produce the type with the provided self type substituted for its `Self` along with any generic parameters of the interface. Split the handling of associated constant declarations into two parts, corresponding to the code before the `=`, and the code between the `=` and `;` (if any). The former goes into the generic declaration region; the latter into the generic definition region. This prepares us to handle the default value for an associated constant, but for now we're just storing the information and not actually using it. Remove the entity type field from `assoc_entity_type`, because it's almost unused and is an attractive nuisance -- it must necessarily be a type in the generic scope of the associated constant rather than in the scope of the instruction (because there is no `Self` anywhere else), which means that it's hard to substitute into or derive meaning from. See `toolchain/check/testdata/impl/assoc_const_self.carbon` for tests of the new functionality; these used to cause the toolchain to crash.
- Loading branch information
Showing
108 changed files
with
3,726 additions
and
1,680 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.