Repository navigation
fix(instance)!: stop generator { } from silently calling the InstanceContainer - #23
Merged
Merged
Conversation
… generator
The marker was never applied to a lambda type, so code inside
generator { } could implicitly call the enclosing InstanceContainer.
modify { } stays unmarked so GenerationUnit calls remain available.
BREAKING CHANGE: implicit InstanceContainer calls inside generator { }
no longer compile; use this@buildInstance explicitly.
oglassdev
force-pushed
the
fix/instance-dsl-scope
branch
from
October 14, 2026 22:52
13949f8 to
d7b1f66
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
@InstanceDslnever protected anything: it was only ever placed on thebuildInstancefunction, where a DSL marker has no effect. So insidegenerator { }, unqualified calls quietly resolved to the enclosingInstanceContainer:buildInstance { generator { setChunkSupplier(...) // compiled: InstanceContainer's method, called from inside a generator } }Minestom runs generators during world generation, possibly on worker threads, so touching the instance from there is almost always a mistake.
Now the
buildInstanceandgeneratorlambda receivers are marked@InstanceDsl, so those calls need an explicitthis@buildInstance.modify { }stays unmarked on purpose, soGenerationUnitcalls likeabsoluteStart()still work inside it.buildInstance { generator { setGenerator(null) } }generator { modify { setChunkSupplier(null) } }generator { modify { fill(absoluteStart(), absoluteEnd(), STONE) } }As a side effect,
buildInstance { }andgenerator { }get IDE DSL coloring again, from the marked lambda (IntelliJ 2026.2+).Breaking change
Code that relied on the leak needs an explicit receiver (
this@buildInstance.…).Testing
compileKotlin,compileTestKotlinand:example:compileKotlinpass. The example'sgenerator { modify { fillHeight(...) } }is unaffected.