diff --git a/.gitignore b/.gitignore index 882534c..6cdef8b 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,4 @@ callgrind.* githash.txt # Test results -tests/tc*/actual.txt +tests/tc*/actual*.txt diff --git a/src/conversion/third.d b/src/conversion/third.d index 737abda..aeccbc2 100644 --- a/src/conversion/third.d +++ b/src/conversion/third.d @@ -78,6 +78,21 @@ public: private: + bool shouldFollowtype(const ACSymbol* t, const SemanticSymbol* currentSymbol) + { + if (t is null) + return false; + if (currentSymbol.acSymbol.kind == CompletionKind.withSymbol + && (t.kind == CompletionKind.variableName + || t.kind == CompletionKind.aliasName)) + { + return true; + } + if (t.kind == CompletionKind.aliasName) + return true; + return false; + } + void thirdPass(SemanticSymbol* currentSymbol) { // Log.trace("third pass on ", currentSymbol.acSymbol.name); @@ -94,12 +109,8 @@ private: case aliasName: ACSymbol* t = resolveType(currentSymbol.initializer, currentSymbol.type, currentSymbol.acSymbol.location); - while (t !is null && (t.kind == CompletionKind.aliasName - || (currentSymbol.acSymbol.kind == CompletionKind.withSymbol - && t.kind == CompletionKind.variableName))) - { + while (shouldFollowtype(t, currentSymbol)) t = t.type; - } currentSymbol.acSymbol.type = t; break; case structName: @@ -141,12 +152,12 @@ private: void resolveInheritance(SemanticSymbol* currentSymbol) { -// Log.trace("Resolving inheritance for ", currentSymbol.acSymbol.name); outer: foreach (string[] base; currentSymbol.baseClasses) { ACSymbol* baseClass; if (base.length == 0) continue; + auto symbolScope = moduleScope.getScopeByCursor(currentSymbol.acSymbol.location); auto symbols = moduleScope.getSymbolsByNameAndCursor( base[0], currentSymbol.acSymbol.location); if (symbols.length == 0) @@ -160,6 +171,7 @@ private: baseClass = symbols[0]; } currentSymbol.acSymbol.parts.insert(baseClass.parts[]); + symbolScope.symbols.insert(baseClass.parts[]); } } @@ -224,7 +236,7 @@ private: slice.popFront(); auto s = symbols[0]; - while (s !is null && s.type !is null && !slice.empty) + while (s !is null && s.type !is null && s !is s.type && !slice.empty) { s = s.type; if (slice.front == "foreach") @@ -243,12 +255,14 @@ private: else if (slice.front == "[]") s = s.type; else - { - auto parts = s.getPartsByName(internString(slice.front)); - if (parts.length == 0) - return null; - s = parts[0]; - } + break; + } + while (s !is null && !slice.empty) + { + auto parts = s.getPartsByName(internString(slice.front)); + if (parts.length == 0) + return null; + s = parts[0]; slice.popFront(); } return s; @@ -258,7 +272,8 @@ private: { if (t is null) return resolveInitializerType(initializer, location); - if (t.type2 is null) return null; + if (t.type2 is null) + return null; ACSymbol* s; if (t.type2.builtinType != tok!"") s = convertBuiltinType(t.type2); diff --git a/tests/tc003/expected1.txt b/tests/tc003/expected1.txt new file mode 100644 index 0000000..3db681b --- /dev/null +++ b/tests/tc003/expected1.txt @@ -0,0 +1,2 @@ +identifiers +uvalue v diff --git a/tests/tc003/expected2.txt b/tests/tc003/expected2.txt new file mode 100644 index 0000000..569890d --- /dev/null +++ b/tests/tc003/expected2.txt @@ -0,0 +1,2 @@ +calltips +void setGrandChild(alias X, alias Y)() diff --git a/tests/tc003/run.sh b/tests/tc003/run.sh index ab35182..0d5ea61 100755 --- a/tests/tc003/run.sh +++ b/tests/tc003/run.sh @@ -1,5 +1,8 @@ set -e set -u -dcd-client file.d -c863 > actual.txt -diff actual.txt expected.txt +dcd-client file.d -c839 > actual1.txt +diff actual1.txt expected1.txt + +dcd-client file.d -c862 > actual2.txt +diff actual2.txt expected2.txt