feat(pbs): add parametric arrays and concrete generic contracts
Support explicit contract type parameters, canonical nominal applications, recursive substitution, concrete implementations and instantiated editor views. Complete parametric Array syntax and contextual construction integration. Preserve type origins across imports and reexports, fix trait argument stack order, and relocate global slots before lifecycle assembly. Publish specs, installed examples and consolidated discussion lessons. Validate frontend, common pipeline, architecture, LSP and installed knowledge gates, plus the full production VM conformance corpus with 14 generic fixtures.
This commit is contained in:
+2
@@ -1310,6 +1310,8 @@ public final class CompilerLanguageServiceBridge implements LanguageServiceBridg
|
||||
final List<FrontendSignature> signatures = symbol.signatures();
|
||||
if (!signatures.isEmpty()) {
|
||||
markdown.append("```pbs\n");
|
||||
if (symbol.kind() == p.studio.compiler.services.FrontendSymbolKind.CONTRACT)
|
||||
markdown.append(symbol.displayName()).append('\n');
|
||||
for (int index = 0; index < signatures.size(); index += 1) {
|
||||
if (index > 0) {
|
||||
markdown.append('\n');
|
||||
|
||||
+26
@@ -28,6 +28,32 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class CompilerLanguageServiceBridgeTest {
|
||||
|
||||
@Test void genericContractsKeepSubstitutedSignaturesAcrossTheBridge(@TempDir Path root) throws Exception {
|
||||
Files.createDirectories(root.resolve("src"));
|
||||
Files.writeString(root.resolve("prometeu.json"), """
|
||||
{"name":"app","version":"1.0.0","language":"pbs","stdlib":"1","target":"Game","dependencies":[]}
|
||||
""");
|
||||
String text = """
|
||||
declare contract Echo<T> { fn echo(value: T) -> T; }
|
||||
fn demo(reader: Echo<int>) -> int { return reader.echo(42); }
|
||||
""";
|
||||
Path file = Files.writeString(root.resolve("src/main.pbs"), text).toRealPath();
|
||||
Files.writeString(root.resolve("src/mod.barrel"), "pub contract Echo<T>; pub fn demo(reader: Echo<int>) -> int;");
|
||||
var bridge = new CompilerLanguageServiceBridge();
|
||||
var context = new LspProjectContext("app", "pbs", root.toRealPath());
|
||||
var mapper = new DocumentPositionMapper(text);
|
||||
var applied = mapper.positionOf(text.indexOf("Echo<int>"));
|
||||
var hover = bridge.hover(context, file.toUri().toString(), text, applied.line(), applied.character());
|
||||
assertTrue(hover.markdown().contains("Echo<int>"), hover.markdown());
|
||||
assertTrue(hover.markdown().contains("value: int"), hover.markdown());
|
||||
var argument = mapper.positionOf(text.indexOf("42)"));
|
||||
var help = bridge.signatureHelp(context, file.toUri().toString(), text, argument.line(), argument.character());
|
||||
assertEquals("echo(value: int) -> int", help.signatures().getFirst().label());
|
||||
var parameter = mapper.positionOf(text.indexOf("value: T")+7);
|
||||
var definition = bridge.definition(context, file.toUri().toString(), text, parameter.line(), parameter.character());
|
||||
assertEquals(text.indexOf("<T>")+1, definition.locations().getFirst().startCharacter());
|
||||
}
|
||||
|
||||
@Test
|
||||
void retainedDependencyUsesOriginalSemanticSnapshotAfterDiskChanges(@TempDir Path temporary) throws Exception {
|
||||
final Path root = temporary.toRealPath();
|
||||
|
||||
Reference in New Issue
Block a user