Improve implementation of implicit class defined in extern object #3549
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thePrepNativeInterop
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