diff --git a/dsymbol/src/dsymbol/conversion/second.d b/dsymbol/src/dsymbol/conversion/second.d index 73fa012..2136202 100644 --- a/dsymbol/src/dsymbol/conversion/second.d +++ b/dsymbol/src/dsymbol/conversion/second.d @@ -97,8 +97,22 @@ void secondPass(SemanticSymbol* currentSymbol, Scope* moduleScope, ref ModuleCac break; } + // let's be methodic about the way we traverse symbols + // so that childs have access to resolved symbols + // functions should be last, because inside, there might be symbols that references + // code from the parent not yet resolved (templates) foreach (child; currentSymbol.children) - secondPass(child, moduleScope, cache); + if (child.acSymbol.kind != CompletionKind.variableName && child.acSymbol.kind != CompletionKind.functionName) + secondPass(child, moduleScope, cache); + + foreach (child; currentSymbol.children) + if (child.acSymbol.kind == CompletionKind.variableName) + secondPass(child, moduleScope, cache); + + foreach (child; currentSymbol.children) + if (child.acSymbol.kind == CompletionKind.functionName) + secondPass(child, moduleScope, cache); + // Alias this and mixin templates are resolved after child nodes are // resolved so that the correct symbol information will be available. diff --git a/tests/tc_templates_resolve/expected_3_2.txt b/tests/tc_templates_resolve/expected_3_2.txt new file mode 100644 index 0000000..6a19b1a --- /dev/null +++ b/tests/tc_templates_resolve/expected_3_2.txt @@ -0,0 +1,9 @@ +identifiers +alignof k +init k +mangleof k +sizeof k +stringof k +tupleof k +value_key v int value_key stdin 0 +value_value v int value_value stdin 0 diff --git a/tests/tc_templates_resolve/expected_3_3.txt b/tests/tc_templates_resolve/expected_3_3.txt new file mode 100644 index 0000000..6a19b1a --- /dev/null +++ b/tests/tc_templates_resolve/expected_3_3.txt @@ -0,0 +1,9 @@ +identifiers +alignof k +init k +mangleof k +sizeof k +stringof k +tupleof k +value_key v int value_key stdin 0 +value_value v int value_value stdin 0 diff --git a/tests/tc_templates_resolve/expected_3_4.txt b/tests/tc_templates_resolve/expected_3_4.txt new file mode 100644 index 0000000..6a19b1a --- /dev/null +++ b/tests/tc_templates_resolve/expected_3_4.txt @@ -0,0 +1,9 @@ +identifiers +alignof k +init k +mangleof k +sizeof k +stringof k +tupleof k +value_key v int value_key stdin 0 +value_value v int value_value stdin 0 diff --git a/tests/tc_templates_resolve/expected_3_5.txt b/tests/tc_templates_resolve/expected_3_5.txt new file mode 100644 index 0000000..bfc6075 --- /dev/null +++ b/tests/tc_templates_resolve/expected_3_5.txt @@ -0,0 +1,8 @@ +identifiers +alignof k +init k +mangleof k +max k +min k +sizeof k +stringof k diff --git a/tests/tc_templates_resolve/file3.d b/tests/tc_templates_resolve/file3.d index 4f2a26a..946c176 100644 --- a/tests/tc_templates_resolve/file3.d +++ b/tests/tc_templates_resolve/file3.d @@ -1,4 +1,4 @@ -struct HashMap(Key, Value) +struct TopHashMap(Key, Value) { Key value_key; Value value_value; @@ -6,6 +6,44 @@ struct HashMap(Key, Value) void main() { - auto hmap = HashMap!(int, int)(); - hmap. -} \ No newline at end of file + auto top = TopHashMap!(int, int)(); + auto bottom = BottomHashMap!(int, int)(); + { + top. + } + { + auto copy = top; + copy. + } + { + bottom. + } + { + auto copy = bottom; + copy. + } + { + auto wf = WithFunction!(int, int)(); + auto gkey = wf.get_key(); + gkey. + } +} + +struct BottomHashMap(Key, Value) +{ + Key value_key; + Value value_value; +} + +struct WithFunction(Key, Value) +{ + Key get_key() + { + return Key.init; + } + + Value get_value() + { + return Value.init; + } +} diff --git a/tests/tc_templates_resolve/run.sh b/tests/tc_templates_resolve/run.sh index 709d9c2..15b4c03 100755 --- a/tests/tc_templates_resolve/run.sh +++ b/tests/tc_templates_resolve/run.sh @@ -13,29 +13,39 @@ function check () { #echo "test1" -../../bin/dcd-client $1 file1.d --extended -c 280 > actual_1_1.txt -diff actual_1_1.txt expected_1_1.txt --strip-trailing-cr +check file1 280 actual_1_1 expected_1_1 #echo "test2" -../../bin/dcd-client $1 file1.d --extended -c 315 > actual_1_2.txt -diff actual_1_2.txt expected_1_2.txt --strip-trailing-cr - +check file1 315 actual_1_2 expected_1_2 #echo "test3" -../../bin/dcd-client $1 file2.d --extended -c 268 > actual_2_1.txt -diff actual_2_1.txt expected_2_1.txt --strip-trailing-cr +check file2 268 actual_2_1 expected_2_1 #echo "test4" -../../bin/dcd-client $1 file2.d --extended -c 305 > actual_2_2.txt -diff actual_2_2.txt expected_2_2.txt --strip-trailing-cr +check file2 305 actual_2_2 expected_2_2 #echo "test5" -../../bin/dcd-client $1 file3.d --extended -c 135 > actual_3_1.txt -diff actual_3_1.txt expected_3_1.txt --strip-trailing-cr +check file3 195 actual_3_1 expected_3_1 + + +#echo "test6" +check file3 246 actual_3_2 expected_3_2 + + +#echo "test7" +check file3 274 actual_3_3 expected_3_3 + + +#echo "test8" +check file3 328 actual_3_4 expected_3_4 + + +#echo "test9" +check file3 433 actual_3_5 expected_3_5 #echo "test complex"