Add TypeVar.strip_sameas().

Strips out any type variable copies from an expression.
This commit is contained in:
Jakob Stoklund Olesen
2016-11-10 10:40:53 -08:00
parent d22541dfa2
commit 129fd4b06e

View File

@@ -313,6 +313,19 @@ class TypeVar(object):
self.base = base
self.derived_func = derived_func
def strip_sameas(self):
# type: () -> TypeVar
"""
Strip any `SAMEAS` functions from this typevar.
Also rewrite any `SAMEAS` functions nested under this typevar.
"""
if self.is_derived:
self.base = self.base.strip_sameas()
if self.derived_func == self.SAMEAS:
return self.base
return self
def lane_of(self):
# type: () -> TypeVar
"""