Conversation
These fast paths make no sense, it should be perfectly sensible to reference the mixin class anywhere.
2504005 to
f058fb7
Compare
78938b8 to
b83f778
Compare
Makes analysis much more convenient and matches behaviour for methods.
9d4238f to
7be28cf
Compare
src/main/java/org/spongepowered/asm/mixin/transformer/EnumExtensionUtils.java
Outdated
Show resolved
Hide resolved
src/main/java/org/spongepowered/asm/mixin/transformer/EnumInfo.java
Outdated
Show resolved
Hide resolved
src/main/java/org/spongepowered/asm/mixin/transformer/MixinApplicatorEnum.java
Show resolved
Hide resolved
7be28cf to
46833ce
Compare
Earthcomputer
left a comment
There was a problem hiding this comment.
Didn't spot any other issues with this.
I assume the new shadow constructors are a feature applicable more widely than enum extensions? Like, now you could do:
@Mixin(TargetClass.class)
class MixinClass {
@Shadow
private MixinClass() {}
void foo() {
TargetClass newTarget = (TargetClass) (Object) new MixinClass();
}
}to create a new instance of TargetClass if the constructor is private (as an alternative to using an invoker)?
|
Yes. You can already do this just without |
NeoForge wants this so they can disable extending `IExtensibleEnum`s with Mixin.
46833ce to
6f5407d
Compare
6f5407d to
e8bd94a
Compare
modmuss50
left a comment
There was a problem hiding this comment.
Looks great, I havent done an indepth review of the logic as I dont think its worth my time and I am not that familar with it. But the high level design looks solid alongside the CT changes that have already gone in.
As discussed automated testing can be handled as a seperate thing. We will also want to decide how/where to formally document this.
Closes #190
Commits best consumed individually.
Requires https://github.com/LlamaLad7/fabric-loader/tree/temp/enum-extensions-testing
This adds enum extensions, which follow the general shape of:
They require the as-yet-unreleased compat level of 0.17.1, partially to encourage migrating but also because they make use of the new
<clinit>logic.Notable features include:
MixinIntrinsics.currentEnumOrdinal()method which can be used in enum initializers to access the relevant constant's final ordinal@Shadowon constructors. Declared constructors can already implicitly shadow, but@Shadowhas the benefit of failing fast if a matching constructor is not found. All constructors in enum extensions are assumed to have@Shadowimplicitly, unlike constructors in normal mixins which must be assumed to be there only to appease the compilerWe make some (relatively minor) assumptions about the structure of enum classes, throwing informative errors if any of them are violated.
For both mixin enums and target enums we assume:
ThisClass[]For mixin enums we additionally assume:
<clinit>, the first loaded int constant will be the ordinal of the first enum constant, and then after that enum constant is assigned, the next loaded int constant will be the ordinal of the second enum constant, etc