Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve implementation of implicit class defined in extern object #3549

Merged

Conversation

WojciechMazur
Copy link
Contributor

The implementation of implicit class constructor defined in extern object had a bug leading to incorrect NIR generation - Sig.Extern instead of Sig.Method, even though if implicit class / extensions methods was defining actual Scala logic. The main issue of that was checking only AST trees, and not symbols, leading to diverging outcomes depending on usage.
To fix this issue we introduce internal annotation not available to users @nonExtern. Based on the information provided in the PrepNativeInterop phases we're able to detect implicit class constructors and correctly handle them when generating NIR.

Additionally we add checks for calls to unsafe.extern used in non-extern methods leading to throwing an exception at runtime. Now, all such calls would be detected at compile-time which resolves #3380

@WojciechMazur WojciechMazur merged commit b4be56c into scala-native:main Oct 8, 2023
78 of 81 checks passed
@WojciechMazur WojciechMazur deleted the fix/extern-with-extension branch October 8, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

method with extern implementation in non-@extern object raises UndefinedBehaviorException
1 participant