- 
                Notifications
    You must be signed in to change notification settings 
- Fork 10.6k
Add a BuiltinGenericType base class. #85169
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
base: main
Are you sure you want to change the base?
Conversation
| @swift-ci Please test | 
| SubstitutionMap subs, | ||
| bool validate) { | ||
| if (!subs.getGenericSignature()->isEqual(getBuiltinGenericSignature(C, kind))) { | ||
| return ErrorType::get(BuiltinUnboundGenericType::get(kind, C)); | 
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.
Shouldn't this be an ASSERT? What is the caller expected to do if they receive an ErrorType?
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 tried removing the ErrorType formation, and some diagnostic tests started failing, so it appears that some parts of Sema throw type bindings in here and rely on this logic for diagnostics.
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.
Can you move the ErrorType formation up to the affected callers then?
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.
(It would also be cleaner if this method always returned the right type of Type, instead of just Type itself.)
Builtin.FixedArray was introduced as the first generic builtin type, with special case handling in all the various recursive visitors. Introduce a base class, and move the handling to that base class, so it is easier to introduce other generic builtins in the future.
8d58b68    to
    cf5f7c8      
    Compare
  
    | @slavapestov I added caches and removed the assertion from CSSimplify; how's this look now? I can look into chasing down the ErrorType clients in a follow-up. | 
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.
Alright, sounds good. Yeah we generally want to form ErrorTypes as close as possible "to the surface" because when they propagate around silently it can be difficult to debug the root cause of the problem.
| @swift-ci Please test | 
| @swift-ci Please test Windows | 
Builtin.FixedArray was introduced as the first generic builtin type, with special case handling in all the various recursive visitors. Introduce a base class, and move the handling to that base class, so it is easier to introduce other generic builtins in the future.