Skip to content
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

Names overlap between outer method args and anonymous class method args #340

Open
TropheusJ opened this issue Jan 24, 2024 · 0 comments
Open
Labels
bug Something isn't working Priority: Medium Medium priority Subsystem: Variables Anything concerning variables, types, assignments, and casting

Comments

@TropheusJ
Copy link

Specific case in Minecraft: (mojmap)
BundlerInfo.createForPacket:

static <T extends PacketListener, P extends BundlePacket<T>> BundlerInfo createForPacket(
		Class<P> packetClass, Function<Iterable<Packet<T>>, P> bundler, BundleDelimiterPacket<T> packet
	) {
		return new BundlerInfo() {
			// ...

			@Nullable
			@Override
			public BundlerInfo.Bundler startPacketBundling(Packet<?> packet) {
				return packet == packet ? new BundlerInfo.Bundler() {
					private final List<Packet<T>> bundlePackets = new ArrayList();

					@Nullable
					@Override
					public Packet<?> addPacket(Packet<?> packet) {
						if (packet == packet) {
							return (Packet<?>)bundler.apply(this.bundlePackets);
						} else if (this.bundlePackets.size() >= 4096) {
							throw new IllegalStateException("Too many packets in a bundle");
						} else {
							this.bundlePackets.add(packet);
							return null;
						}
					}
				} : null;
			}
		};
	}

Note the two packet == packet. Those are supposed to be comparing the addPacket / startPacketBundling packet args with the enclosing createForPacket one.

This is actually valid output that could be recompiled, but would result in incorrect behavior.

@TropheusJ TropheusJ changed the title Names overlap between method args and anonymous class method params Names overlap between outer method args and anonymous class method args Jan 24, 2024
@jaskarth jaskarth added bug Something isn't working Priority: Medium Medium priority Subsystem: Variables Anything concerning variables, types, assignments, and casting labels Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority: Medium Medium priority Subsystem: Variables Anything concerning variables, types, assignments, and casting
Projects
None yet
Development

No branches or pull requests

2 participants