Skip to content

Commit 079a6d2

Browse files
committed
Fix constructor test
1 parent 0d15c84 commit 079a6d2

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

Tests/JExtractSwiftTests/FuncImportTests.swift

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -418,15 +418,28 @@ final class MethodImportTests {
418418
* }
419419
*/
420420
public MySwiftClass(long len, long cap) {
421+
this(/*arena=*/null, len, cap);
422+
}
423+
/**
424+
* Create an instance of {@code MySwiftClass}.
425+
* This instance is managed by the passed in {@link SwiftArena} and may not outlive the arena's lifetime.
426+
*
427+
* {@snippet lang=swift :
428+
* public init(len: Swift.Int, cap: Swift.Int)
429+
* }
430+
*/
431+
public MySwiftClass(SwiftArena arena, long len, long cap) {
421432
var mh$ = init_len_cap.HANDLE;
422433
try {
423-
if (TRACE_DOWNCALLS) {
424-
traceDowncall(len, cap);
425-
}
426-
427-
this.selfMemorySegment = (MemorySegment) mh$.invokeExact(len, cap, TYPE_METADATA);
434+
if (TRACE_DOWNCALLS) {
435+
traceDowncall(len, cap);
436+
}
437+
this.selfMemorySegment = (MemorySegment) mh$.invokeExact(len, cap, TYPE_METADATA.$memorySegment());
438+
if (arena != null) {
439+
arena.register(this);
440+
}
428441
} catch (Throwable ex$) {
429-
throw new AssertionError(\"should not reach here\", ex$);
442+
throw new AssertionError("should not reach here", ex$);
430443
}
431444
}
432445
"""

0 commit comments

Comments
 (0)