-
Notifications
You must be signed in to change notification settings - Fork 0
feat: delegate SurfHytaleApi implementation to surfHytaleApi via comp… #179
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
base: version/1.21.11
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This pull request attempts to add delegation to the SurfHytaleApi companion object by making it implement the SurfHytaleApi interface through delegation to the surfHytaleApi top-level property.
Changes:
- Modified the companion object declaration in
SurfHytaleApito implementSurfHytaleApivia delegation tosurfHytaleApi
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| interface SurfHytaleApi : SurfCoreApi { | ||
| companion object { | ||
| companion object : SurfHytaleApi by surfHytaleApi { |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code introduces a circular dependency that will cause a runtime error. The companion object delegates to surfHytaleApi on line 7, but surfHytaleApi is defined on line 12 as SurfHytaleApi.instance, which in turn references instance on line 8. This creates a cycle where:
- Accessing
SurfHytaleApi.companiontries to resolve the delegatesurfHytaleApi surfHytaleApigetter callsSurfHytaleApi.instanceSurfHytaleApi.instanceis a property of the companion object being initialized
This will result in initialization errors or infinite recursion. The companion object should not delegate to the interface; instead, it should simply provide access to the instance, as seen in the other API implementations (SurfVelocityApi, SurfCoreApi). Remove the delegation pattern and keep the original companion object structure.
| companion object : SurfHytaleApi by surfHytaleApi { | |
| companion object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c81dc6453
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| interface SurfHytaleApi : SurfCoreApi { | ||
| companion object { | ||
| companion object : SurfHytaleApi by surfHytaleApi { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid delegating companion to instance before init
The companion object now delegates SurfHytaleApi to surfHytaleApi, but that getter returns SurfHytaleApi.instance, which is initialized after the delegate expression runs. During companion object construction the delegate is therefore resolved before instance is set, so it becomes null (or triggers an init-time error) and any call to a delegated SurfHytaleApi method on the companion will throw at runtime. This happens on first access to the companion object (class init) and breaks any code that uses the new static delegation.
Useful? React with 👍 / 👎.
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
1 similar comment
|
This PR contains changes that modified the public API. To update the reference ABI dumps: ./gradlew updateLegacyAbi
git add **/api/**
git commit -m "Update ABI reference"
git pushAfter updating, the CI will pass. Make sure the changes are backward compatible. |
…anion object