Commit d8891f7d authored by Tom Niget's avatar Tom Niget

Add field to store whether type is reference

parent bbff8ada
...@@ -176,7 +176,7 @@ class ExpressionVisitor(NodeVisitor): ...@@ -176,7 +176,7 @@ class ExpressionVisitor(NodeVisitor):
def visit_Attribute(self, node: ast.Attribute) -> Iterable[str]: def visit_Attribute(self, node: ast.Attribute) -> Iterable[str]:
yield from self.prec(".").visit(node.value) yield from self.prec(".").visit(node.value)
if isinstance(node.value.type, UserType): if node.value.type.resolve().is_reference:
yield "->" yield "->"
else: else:
yield "." yield "."
......
...@@ -18,6 +18,7 @@ class BaseType(ABC): ...@@ -18,6 +18,7 @@ class BaseType(ABC):
parents: List["BaseType"] = field(default_factory=list, init=False) parents: List["BaseType"] = field(default_factory=list, init=False)
typevars: List["TypeVariable"] = field(default_factory=list, init=False) typevars: List["TypeVariable"] = field(default_factory=list, init=False)
def get_parents(self) -> List["BaseType"]: def get_parents(self) -> List["BaseType"]:
return self.parents return self.parents
...@@ -124,6 +125,7 @@ class TypeOperator(BaseType, ABC): ...@@ -124,6 +125,7 @@ class TypeOperator(BaseType, ABC):
is_protocol: bool = False is_protocol: bool = False
is_protocol_gen: ClassVar[bool] = False is_protocol_gen: ClassVar[bool] = False
match_cache: set["TypeOperator"] = field(default_factory=set, init=False) match_cache: set["TypeOperator"] = field(default_factory=set, init=False)
is_reference: bool = False
@staticmethod @staticmethod
def make_type(name: str): def make_type(name: str):
...@@ -421,7 +423,7 @@ class Future(Promise): ...@@ -421,7 +423,7 @@ class Future(Promise):
class UserType(TypeOperator): class UserType(TypeOperator):
def __init__(self, name: str): def __init__(self, name: str):
super().__init__([], name=name) super().__init__([], name=name, is_reference=True)
def unify_internal(self, other: "BaseType"): def unify_internal(self, other: "BaseType"):
if type(self) != type(other): 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