From cee889b33477e753ff26f56a05f6ae27cdb43cb1 Mon Sep 17 00:00:00 2001 From: Cliff Click Date: Tue, 27 Oct 2026 16:06:06 -0700 Subject: Bugfix escapes not-coded --- .../java/com/seaofnodes/simple/Chapter25Test.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'chapter28b/src/test') diff --git a/chapter28b/src/test/java/com/seaofnodes/simple/Chapter25Test.java b/chapter28b/src/test/java/com/seaofnodes/simple/Chapter25Test.java index dbb2a5ca..f94f641b 100644 --- a/chapter28b/src/test/java/com/seaofnodes/simple/Chapter25Test.java +++ b/chapter28b/src/test/java/com/seaofnodes/simple/Chapter25Test.java @@ -218,6 +218,25 @@ public class Chapter25Test { code.driver(CodeGen.Phase.TypeCheck); } + @Test public void testTypeOnlyFileReference() throws IOException { + Path base = Path.of("build/objs"); + Files.createDirectories(base); + Path root = Files.createTempDirectory(base,"type-only-"); + Files.createDirectory(root.resolve("A")); + Files.writeString(root.resolve("A/B.smp"),"int x = 0;"); + // B declares only a class initializer. Using its name as a type + // must not publish a nonexistent instance initializer during Opto. + for( String src : new String[]{ + "B? b = null; return 0;", + "val readB = { B b -> 0; }; return 0;" + } ) { + Files.writeString(root.resolve("A.smp"),src); + CodeGen code = new CodeGen(root.toString(),root.resolve("obj").toString(),null, + "A",null,123,true,TypeInteger.BOT).driver(CodeGen.Phase.TypeCheck); + assertEquals("0",Eval2.eval(code,0)); + } + } + @Test public void testPostfixFieldUpdate() { -- cgit v1.2.3