This commit addresses the root cause identified in issue #1370 by preserving
Named interface type information through the interface construction phase.
**Root Cause:**
Named interfaces were prematurely unwrapped via Underlying() in the interface
construction phase (MakeInterface()/unsafeInterface()), causing the subsequent
ABI type generation to hit `case *types.Interface:` instead of
`case *types.Named:`, resulting in loss of package information.
**The Fix:**
1. Modified `unsafeInterface()` to accept a `namedIntf types.Type` parameter
2. Updated all callers to pass the Named type (tinter.raw.Type, assertedTyp.raw.Type, etc.)
3. When namedIntf is available, pass it to `abiType()` to ensure proper routing
through the type switch to `abiNamedInterfaceOf()` which has correct package context
4. Reverted the workaround logic in `abiInterfaceOf()` that extracted pkgPath from methods
**Impact:**
- Fixes segmentation faults when calling interface private methods across packages
- Ensures runtime receives correct package path for interface metadata
- Allows private method slots in itab to be properly filled
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fixes os.ReadDir segfault caused by package path mismatch between llgo
overlay packages and canonical standard library paths.
The issue occurred in: os.ReadDir → sort.Slice → reflectlite.Swapper
where internal/reflectlite.Type interface has private methods common()
and uncommon(). Using mPkg.Path() returned the overlay path
'github.com/goplus/llgo/runtime/internal/lib/internal/reflectlite'
instead of the canonical 'internal/reflectlite', causing runtime to
only fill public methods and leave private method pointers NULL.
Changed to use abi.PathOf() which returns the correct canonical package
path for matching, ensuring all interface methods (both public and
private) are properly filled in the interface table.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
The previous fix only extracted package path from private methods,
causing segfaults for interfaces with only exported methods (like fs.DirEntry).
Root cause:
- For interfaces with only exported methods, the loop never entered
the !token.IsExported(mName) block
- pkgPath remained empty and fell back to pkg.Path() (compilation package)
- This caused wrong PkgPath for standard library interfaces like fs.DirEntry
- Runtime received wrong package path, leading to segfaults
Fix:
- Extract pkgPath from the FIRST method (any method), not just private ones
- All methods have correct package information via m.Pkg()
- Only fall back to pkg.Path() if the interface has no methods or m.Pkg() is nil
This fixes the readdir demo segfault while maintaining the fix for issue #1370.
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
When converting concrete type pointers to interfaces with private methods
across packages, the interface metadata's PkgPath was incorrectly set to
the current compilation package instead of the interface definition package.
This caused the runtime to only fill exported methods in the itab, leaving
private method slots as NULL (0x0), which led to segmentation faults when
calling these private methods.
The fix extracts the package path from the interface's private methods
(if any) instead of using the current package path. This ensures the
runtime receives the correct package path for the visibility check.
Fixes#1370
Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: luoliwoshang <luoliwoshang@users.noreply.github.com>