aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <c@ethdev.com>2015-01-16 03:04:06 +0800
committerChristian <c@ethdev.com>2015-01-20 06:35:04 +0800
commitfb41b96bb89d2e250759159f992b460442fa0b06 (patch)
tree24a9e02bc91b2b54c8cc210adac075db7e2504cb
parentffed2f37cbd6ccde0f58df8e24e801e61c1ae353 (diff)
downloaddexon-solidity-fb41b96bb89d2e250759159f992b460442fa0b06.tar.gz
dexon-solidity-fb41b96bb89d2e250759159f992b460442fa0b06.tar.zst
dexon-solidity-fb41b96bb89d2e250759159f992b460442fa0b06.zip
Import inherited members into the contract's scope.
-rw-r--r--SolidityNameAndTypeResolution.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/SolidityNameAndTypeResolution.cpp b/SolidityNameAndTypeResolution.cpp
index e2b4f160..f4a1abbd 100644
--- a/SolidityNameAndTypeResolution.cpp
+++ b/SolidityNameAndTypeResolution.cpp
@@ -357,7 +357,6 @@ BOOST_AUTO_TEST_CASE(function_canonical_signature_type_aliases)
}
}
-
BOOST_AUTO_TEST_CASE(hash_collision_in_interface)
{
char const* text = "contract test {\n"
@@ -369,6 +368,40 @@ BOOST_AUTO_TEST_CASE(hash_collision_in_interface)
BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
}
+BOOST_AUTO_TEST_CASE(inheritance_basic)
+{
+ char const* text = R"(
+ contract base { uint baseMember; struct BaseType { uint element; } }
+ contract derived is base {
+ BaseType data;
+ function f() { baseMember = 7; }
+ }
+ )";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+BOOST_AUTO_TEST_CASE(inheritance_diamond_basic)
+{
+ char const* text = R"(
+ contract root { function rootFunction() {} }
+ contract inter1 is root { function f() {} }
+ contract inter2 is root { function f() {} }
+ contract derived is inter1, inter2, root {
+ function g() { f(); rootFunction(); }
+ }
+ )";
+ BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
+}
+
+BOOST_AUTO_TEST_CASE(cyclic_inheritance)
+{
+ char const* text = R"(
+ contract A is B { }
+ contract B is A { }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(text), TypeError);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}