From 15a7e2a38917de7749cbac567e827b7847624347 Mon Sep 17 00:00:00 2001 From: Dmitry Kashitsyn Date: Sun, 17 Jul 2016 23:49:15 +0600 Subject: [PATCH] Fixes Type::toString() Issue: #17 Issue: #92 --- include/inference.h | 4 ++-- src/TypeAnalyzer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/inference.h b/include/inference.h index eb62e33..83ab0a2 100644 --- a/include/inference.h +++ b/include/inference.h @@ -39,7 +39,7 @@ class Type { // tkMonotype (class name) (SmallInt) // tkComposite (class name, ...) (SmallInt, *) // tkArray class name [...] Array[String, *, (*, *), (True, False)] - std::string toString(bool subtypesOnly = false) const; + std::string toString(bool subtypesOnly = true) const; Type(TKind kind = tkUndefined) : m_kind(kind), m_value(0) {} Type(TObject* literal, TKind kind = tkLiteral) { set(literal, kind); } @@ -79,7 +79,7 @@ class Type { bool isBlock() const { return isMonotype() && - m_value == globals.blockClass && + (m_value == globals.blockClass) && !m_subTypes.empty(); } diff --git a/src/TypeAnalyzer.cpp b/src/TypeAnalyzer.cpp index 2ac2dbb..8b29892 100644 --- a/src/TypeAnalyzer.cpp +++ b/src/TypeAnalyzer.cpp @@ -26,7 +26,7 @@ static void printBlock(const Type& blockType, std::stringstream& stream) { stream << blockType[Type::bstCaptureIndex].toString(); // capture context index } -std::string Type::toString(bool subtypesOnly /*= false*/) const { +std::string Type::toString(bool subtypesOnly /*= true*/) const { std::stringstream stream; switch (m_kind) { @@ -62,7 +62,7 @@ std::string Type::toString(bool subtypesOnly /*= false*/) const { break; case tkArray: - if (subtypesOnly) + if (!subtypesOnly) stream << getValue()->cast()->name->toString(); case tkComposite: { stream << (m_kind == tkComposite ? "(" : "[");