summaryrefslogtreecommitdiff
path: root/chapter28b/src/test/java/com
diff options
context:
space:
mode:
authorCliff Click <cliffc@acm.org>2026-10-27 16:06:06 -0700
committerCliff Click <cliffc@acm.org>2026-10-27 16:06:06 -0700
commitcee889b33477e753ff26f56a05f6ae27cdb43cb1 (patch)
tree5750d679d4b9d9a1eb7cf56559952e7558adf6ae /chapter28b/src/test/java/com
parent0bf3ce826ca0546b08f9d7a513930017fcf63f89 (diff)
downloadSimple-cee889b33477e753ff26f56a05f6ae27cdb43cb1.tar.gz
Simple-cee889b33477e753ff26f56a05f6ae27cdb43cb1.zip
Bugfix escapes not-coded <init>
Diffstat (limited to 'chapter28b/src/test/java/com')
-rw-r--r--chapter28b/src/test/java/com/seaofnodes/simple/Chapter25Test.java19
1 files changed, 19 insertions, 0 deletions
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() {