Skip to content

Feature/mixin quantifiers - #2643

Open
LlamaLad7 wants to merge 8 commits into
minecraft-dev:devfrom
LlamaLad7:feature/mixin-quantifiers
Open

Feature/mixin quantifiers#2643
LlamaLad7 wants to merge 8 commits into
minecraft-dev:devfrom
LlamaLad7:feature/mixin-quantifiers

Conversation

@LlamaLad7

Copy link
Copy Markdown
Contributor

Basic support for Mixin quantifiers, along with related bugfixes. Commits best consumed invididually.

Closes #2518

@Earthcomputer Earthcomputer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to test it, but reviewed the code

Comment thread src/main/kotlin/util/MemberReference.kt Outdated
override fun matchField(owner: String, name: String, desc: String): Boolean {
assert(!owner.contains('.'))
return (this.matchAllNames || this.name == name) &&
return canEverMatch(name) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the implementation is the same, I'm not sure this is the right function to use here logically. Maybe however we can rename the function to matchesName or something

override fun matchField(owner: String, name: String, desc: String): Boolean {
assert(!owner.contains('.'))
return (this.matchAllNames || this.name == name) &&
return canEverMatch(name) &&

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Comment thread src/main/kotlin/util/sequences.kt Outdated

val Sequence<*>.countIs get() = SequenceCountCompareOps(this)

class SequenceCountCompareOps(private val sequence: Sequence<*>) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a big fan of magic syntax like this

@LlamaLad7 LlamaLad7 Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you suggest instead? It's a concept from Scala so it's at least somewhat established in that sense, but even aside from being nice to read I don't think there's any other way to expose the same functionality without 3 (or even 6) separate functions which feels overkill.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't familiar with the pattern and since it's not a Scala codebase you can't necessarily expect the average reader to be familiar with the pattern. I was also confused at the usage site and had to read the implementation to understand what it was.

I reckon that unless this is commonly needed, reverting to the previous code .drop(1).any() is fine

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's used in 2 other places too as .countIs >= minMatches or similar

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It reads quite well imo

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read it as "count is" initially and I was like "what is i?". I'm just not expecting to read code in this way.

I think implementing them as separate functions is clearer. You can express all the inequalities as drop(?).any() so it's at least not too many lines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps sizeIs would be clearer? Or would you rather .countIsAtLeast, .countIsMoreThan, etc?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah let's do countIsAtLeast

Mixin MemberInfo strings are only tangentially related to concrete MemberReferences. We also introduce a MemberMatcher superinterface for resolving things.
Really nothing is "ambiguous" (except perhaps to the reader), it's just that Mixin's default behaviour of matching the first method in a given class is unexpected, but I'll leave the terminology for now. Adding any explicit quantifier suppresses this inspection, including `{1}` if that's really what's desired.

Additionally, adding a wildcard is almost never the correct fix. Choosing one of the available descriptors is what should be offered instead, but I'll leave that too for now.
Causes targets not to show as unresolved when they should.
@LlamaLad7
LlamaLad7 force-pushed the feature/mixin-quantifiers branch from ffdb662 to a0977d6 Compare September 4, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mixin wildcard * is not properly accounted for

2 participants