@@ -1769,6 +1769,9 @@ class P(Protocol):
17691769class NominalSubtype :
17701770 def m (self , y : int ) -> None : ...
17711771
1772+ class NominalSubtype2 :
1773+ def m (self , * args : object ) -> None : ...
1774+
17721775class NotSubtype :
17731776 def m (self , x : int ) -> int :
17741777 return 42
@@ -1785,18 +1788,24 @@ class DefinitelyNotSubtype:
17851788 m = None
17861789
17871790static_assert(is_subtype_of(NominalSubtype, P))
1791+ static_assert(is_subtype_of(NominalSubtype2, P))
1792+ static_assert(is_subtype_of(NominalSubtype | NominalSubtype2, P))
17881793static_assert(not is_assignable_to(DefinitelyNotSubtype, P))
17891794static_assert(not is_assignable_to(NotSubtype, P))
1795+ static_assert(not is_assignable_to(NominalSubtype | NotSubtype, P))
1796+ static_assert(not is_assignable_to(NominalSubtype2 | DefinitelyNotSubtype, P))
17901797
17911798# `m` has the correct signature when accessed on instances of `NominalWithClassMethod`,
17921799# but not when accessed on the class object `NominalWithClassMethod` itself
17931800#
1794- # TODO : this should pass
1801+ # TODO : these should pass
17951802static_assert(not is_assignable_to(NominalWithClassMethod, P)) # error: [static-assert-error]
1803+ static_assert(not is_assignable_to(NominalSubtype | NominalWithClassMethod, P)) # error: [static-assert-error]
17961804
17971805# Conversely, `m` has the correct signature when accessed on the class object
17981806# `NominalWithStaticMethod`, but not when accessed on instances of `NominalWithStaticMethod`
17991807static_assert(not is_assignable_to(NominalWithStaticMethod, P))
1808+ static_assert(not is_assignable_to(NominalSubtype | NominalWithStaticMethod, P))
18001809```
18011810
18021811A callable instance attribute is not sufficient for a type to satisfy a protocol with a method
@@ -2112,6 +2121,7 @@ static_assert(is_subtype_of(NClassMethodGood, PClassMethod)) # error: [static-a
21122121static_assert(is_subtype_of(NClassMethodGood, PStaticMethod)) # error: [static-assert-error]
21132122static_assert(not is_assignable_to(NClassMethodBad, PClassMethod)) # error: [static-assert-error]
21142123static_assert(not is_assignable_to(NClassMethodBad, PStaticMethod)) # error: [static-assert-error]
2124+ static_assert(not is_assignable_to(NClassMethodGood | NClassMethodBad, PClassMethod)) # error: [static-assert-error]
21152125
21162126static_assert(is_assignable_to(NStaticMethodGood, PClassMethod))
21172127static_assert(is_assignable_to(NStaticMethodGood, PStaticMethod))
@@ -2120,6 +2130,7 @@ static_assert(is_subtype_of(NStaticMethodGood, PClassMethod)) # error: [static-
21202130static_assert(is_subtype_of(NStaticMethodGood, PStaticMethod)) # error: [static-assert-error]
21212131static_assert(not is_assignable_to(NStaticMethodBad, PClassMethod)) # error: [static-assert-error]
21222132static_assert(not is_assignable_to(NStaticMethodBad, PStaticMethod)) # error: [static-assert-error]
2133+ static_assert(not is_assignable_to(NStaticMethodGood | NStaticMethodBad, PStaticMethod)) # error: [static-assert-error]
21232134```
21242135
21252136## Equivalence of protocols with method or property members
0 commit comments