Skip to content

Repeatedly call Basic Type Resolvers #1036

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ protected SimpleTypeResolverBase(TypeStore typeStore) : base(typeStore)
/// <inheritdoc />
protected override TypeReference VisitTypeReference(TypeReference typeSymbol)
{
if (typeSymbol is UnresolvedTypeReference utr)
while (true)
{
return TryResolve(utr, out var result) ? result! : utr;
if (typeSymbol is UnresolvedTypeReference utr)
{
if (TryResolve(utr, out var result))
{
typeSymbol = result!;
continue;
}
return utr;
}
return base.VisitTypeReference(typeSymbol);
}
return base.VisitTypeReference(typeSymbol);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


/* -------------------------- NEW OUTPUT -------------------------- */

namespace LIBRARY_NAMESPACE
{
public struct Test
{
public System.Int32*** f1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,21 @@ public Task Test10()
");
return Verifier.Verify(result);
}

[Fact,
Trait("Category", "Integration"),
Trait("Source Language", "C++"),
Trait("Target Language", "C#"),
Trait("Feature", "Structs"),
Trait("Feature", "Fields")]
public Task Test11()
{
var result = TestHelper.GetCSharpOutputFromCpp(@"
#include <stdint.h>

typedef struct {
int32_t*** f1;
} Test;");
return Verifier.Verify(result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,17 @@ public void ShouldNotResolve(string text)
var finalSymbol = output.Visit(symbol);
Assert.IsNotType<PointerTypeReference>(finalSymbol);
}

[Fact, Trait("Category", "Type Resolution")]
public void MultiPointer()
{
var symbol = new UnresolvedTypeReference("int***");
var output = new PointerTypeResolver(new TypeStore());

var finalSymbol = output.Visit(symbol);
var outer = Assert.IsType<PointerTypeReference>(finalSymbol);
var middle = Assert.IsType<PointerTypeReference>(outer.Underlying);
var inner = Assert.IsType<PointerTypeReference>(middle.Underlying);
Assert.IsNotType<PointerTypeReference>(inner.Underlying);
}
}