Skip to content
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

Load other shapes when a mixin can't be resolved #2214

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 @@ -229,7 +229,7 @@ private List<ShapeId> sort() {
emitUnresolved(shape, e.getUnresolved(), e.getResolved());
}
}
return Collections.emptyList();
return e.getResolved();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.junit.jupiter.api.AfterEach;
Expand Down Expand Up @@ -1391,4 +1392,28 @@ public void handlesMultipleInheritanceForMixinMembers() {
String actualPattern = shape.expectTrait(PatternTrait.class).getValue();
assertThat(actualPattern, equalTo("baz"));
}

@Test
public void loadsShapesWhenThereAreUnresolvedMixins() {
String modelText = "$version: \"2\"\n"
+ "namespace com.foo\n"
+ "\n"
+ "string Foo\n"
+ "@mixin\n"
+ "structure Bar {}\n"
+ "structure Baz with [Unknown] {}\n";
ValidatedResult<Model> result = Model.assembler()
.addUnparsedModel("foo.smithy", modelText)
.assemble();

assertThat(result.isBroken(), is(true));
assertThat(result.getResult().isPresent(), is(true));
Set<ShapeId> fooShapes = result.getResult().get().getShapeIds().stream()
.filter(id -> id.getNamespace().equals("com.foo"))
.collect(Collectors.toSet());
assertThat(fooShapes, containsInAnyOrder(
ShapeId.from("com.foo#Foo"),
ShapeId.from("com.foo#Bar")
));
}
}