Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Allow instantiation of Type[A], if A is abstract#2853
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
b0ff0cc71ea62fec22e4d80c82e7f52a3bd65eab954d2e6fdFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1151,14 +1151,15 @@ def check_assignment(self, lvalue: Lvalue, rvalue: Expression, infer_lvalue_type | ||
| else: | ||
| rvalue_type = self.check_simple_assignment(lvalue_type, rvalue, lvalue) | ||
| # Special case: only non-abstract classes can be assigned to variables | ||
| # with explicit type Type[A]. | ||
| if ( | ||
| isinstance(rvalue_type, CallableType) and rvalue_type.is_type_obj() and | ||
| ||
| rvalue_type.type_object().is_abstract and | ||
| isinstance(lvalue_type, TypeType) and | ||
| isinstance(lvalue_type.item, Instance) and lvalue_type.item.type.is_abstract | ||
| ): | ||
| self.fail("Can only assign non-abstract classes" | ||
| " to a variable of type '{}'".format(lvalue_type), rvalue) | ||
| return | ||
| if rvalue_type and infer_lvalue_type: | ||