Commit b3ad6c19 authored by Tom Niget's avatar Tom Niget

Add field to store whether type is reference

parent f8194eae
......@@ -176,7 +176,7 @@ class ExpressionVisitor(NodeVisitor):
def visit_Attribute(self, node: ast.Attribute) -> Iterable[str]:
yield from self.prec(".").visit(node.value)
if isinstance(node.value.type, UserType):
if node.value.type.resolve().is_reference:
yield "->"
else:
yield "."
......
......@@ -18,6 +18,7 @@ class BaseType(ABC):
parents: List["BaseType"] = field(default_factory=list, init=False)
typevars: List["TypeVariable"] = field(default_factory=list, init=False)
def get_parents(self) -> List["BaseType"]:
return self.parents
......@@ -124,6 +125,7 @@ class TypeOperator(BaseType, ABC):
is_protocol: bool = False
is_protocol_gen: ClassVar[bool] = False
match_cache: set["TypeOperator"] = field(default_factory=set, init=False)
is_reference: bool = False
@staticmethod
def make_type(name: str):
......@@ -421,7 +423,7 @@ class Future(Promise):
class UserType(TypeOperator):
def __init__(self, name: str):
super().__init__([], name=name)
super().__init__([], name=name, is_reference=True)
def unify_internal(self, other: "BaseType"):
if type(self) != type(other):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment