Skip to content

Commit

Permalink
Make accidental instantiation of various Mu impossible
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Jul 23, 2024
1 parent 2d1ffa2 commit 2497c74
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public <T> DataResult<Codec<T>> interpret(Structure<T> structure) {
}

public record Holder<T>(Codec<T> codec) implements App<Holder.Mu, T> {
public static final class Mu implements K1 {}
public static final class Mu implements K1 { private Mu() {} }

static <T> Holder<T> unbox(App<Mu, T> box) {
return (Holder<T>) box;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public <T> DataResult<JsonObject> interpret(Structure<T> structure) {
}

public record Holder<T>(JsonObject jsonObject) implements App<Holder.Mu, T> {
public static final class Mu implements K1 {}
public static final class Mu implements K1 { private Mu() {} }

static <T> Holder<T> unbox(App<Holder.Mu, T> box) {
return (Holder<T>) box;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public <T> DataResult<MapCodec<T>> interpret(Structure<T> structure) {
}

public record Holder<T>(MapCodec<T> mapCodec) implements App<Holder.Mu, T> {
public static final class Mu implements K1 {}
public static final class Mu implements K1 { private Mu() {} }

static <T> Holder<T> unbox(App<Holder.Mu, T> box) {
return (Holder<T>) box;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.mojang.datafixers.kinds.K2;

public interface ParametricKeyedValue<N extends K1, MuP extends K1, MuO extends K1> extends App2<ParametricKeyedValue.Mu<N>, MuP, MuO> {
class Mu<N extends K1> implements K2 {}
final class Mu<N extends K1> implements K2 { private Mu() {} }

<T> App<N, App<MuO, T>> convert(App<MuP, T> parameter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.mojang.datafixers.kinds.K1;

public record Identity<T>(T value) implements App<Identity.Mu, T> {
public static final class Mu implements K1 {}
public static final class Mu implements K1 { private Mu() {} }

public static <T> Identity<T> unbox(App<Mu, T> input) {
return (Identity<T>) input;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

public class TestParametricKeys {
private record WithType<T>(String string) implements App<WithType.Mu, T> {
public static class Mu implements K1 {}
public static class Mu implements K1 { private Mu() {} }

private static <T> WithType<T> unbox(App<Mu, T> box) {
return (WithType<T>) box;
}
}

private record Prefix<T>(String string) implements App<Prefix.Mu, T> {
public static class Mu implements K1 {}
public static class Mu implements K1 { private Mu() {} }

private static <T> Prefix<T> unbox(App<Mu, T> box) {
return (Prefix<T>) box;
Expand Down

0 comments on commit 2497c74

Please sign in to comment.