Skip to content

Commit

Permalink
Fix #184
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackerpilot committed Jan 30, 2015
1 parent 2129f06 commit 15aeda1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ callgrind.*
githash.txt

# Test results
tests/tc*/actual.txt
tests/tc*/actual*.txt
43 changes: 29 additions & 14 deletions src/conversion/third.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -160,6 +171,7 @@ private:
baseClass = symbols[0];
}
currentSymbol.acSymbol.parts.insert(baseClass.parts[]);
symbolScope.symbols.insert(baseClass.parts[]);
}
}

Expand Down Expand Up @@ -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")
Expand All @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tests/tc003/expected1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
identifiers
uvalue v
2 changes: 2 additions & 0 deletions tests/tc003/expected2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
calltips
void setGrandChild(alias X, alias Y)()
7 changes: 5 additions & 2 deletions tests/tc003/run.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 15aeda1

Please sign in to comment.