File tree Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Expand file tree Collapse file tree 2 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -201,7 +201,18 @@ def _add_new_instance_type(
201
201
len (ctx .context .decorators ) > 1
202
202
)
203
203
if has_multiple_decorators :
204
- # TODO: what happens here?
204
+ # If we have multiple decorators on a function,
205
+ # it is not safe to assume
206
+ # that all the regular instance type is fine. Here's an example:
207
+ #
208
+ # @some.instance(str)
209
+ # @other.instance(int)
210
+ # (instance: Union[str, int]) -> ...
211
+ #
212
+ # So, if we just copy copy `instance`,
213
+ # both typeclasses will have both `int` and `str`
214
+ # as their instance types. This is not what we want.
215
+ # We want: `some` to have `str` and `other` to have `int`
205
216
new_type = inference .infer_runtime_type_from_context (
206
217
fallback = new_type ,
207
218
fullname = fullname ,
Original file line number Diff line number Diff line change @@ -31,12 +31,7 @@ def load_typeclass(
31
31
fullname : str ,
32
32
ctx : MethodContext ,
33
33
) -> Instance :
34
- """
35
- Loads given typeclass from a symboltable by a fullname.
36
-
37
- There are two ways to load a typeclass by name:
38
- # TODO
39
- """
34
+ """Loads given typeclass from a symboltable by a fullname."""
40
35
typeclass_info = ctx .api .lookup_qualified (fullname ) # type: ignore
41
36
assert isinstance (typeclass_info .type , Instance )
42
37
return typeclass_info .type
You can’t perform that action at this time.
0 commit comments