Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions aten/src/ATen/core/jit_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -1380,12 +1380,6 @@ struct CAFFE2_API ClassType : public Type {
return false;
}

bool isSubtypeOf(const TypePtr rhs) const override {
// XXX: We do not have inheritance implemented, only types that are the
// same can subtype from each other.
return *this == *rhs;
}

std::string str() const override {
return std::string("ClassType<") + name_.name() + ">";
}
Expand Down
11 changes: 11 additions & 0 deletions test/test_jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16050,6 +16050,17 @@ def copy(self):
other.stack = list(self.stack)
return other

def test_optional_type_promotion(self):
# should not throw
@torch.jit.script # noqa: B903
class Tree(object):
def __init__(self):
self.parent = torch.jit.annotate(Optional[Tree], None)

def add_child(self, child):
# type: (Tree) -> None
child.parent = torch.jit.annotate(Optional[Tree], self)


class TestLogging(JitTestCase):
def test_bump_numeric_counter(self):
Expand Down