diff --git a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java index c7de83d7eaa..41fcf1e0ad5 100644 --- a/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java +++ b/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/TypeSystem.java @@ -94,9 +94,10 @@ public PTBKey(ReferenceBinding type, TypeBinding[] arguments, ReferenceBinding e TypeVariableBinding typeVariableBinding = (TypeVariableBinding) argument; Consumer previousConsumer = typeVariableBinding.updateWhenSettingTypeAnnotations; typeVariableBinding.updateWhenSettingTypeAnnotations = (newTvb) -> { - // update the TVB argument and simulate a re-hash: - ParameterizedTypeBinding[] value = HashedParameterizedTypes.this.hashedParameterizedTypes.get(this); - arguments[idx] = newTvb; + // Changing arguments[idx] changes PTBKey.equals() and PTBKey.hashCode(). + // So the old PTBKey has to be removed and a new has to be inserted: + ParameterizedTypeBinding[] value = HashedParameterizedTypes.this.hashedParameterizedTypes.remove(this); + this.arguments[idx] = newTvb; HashedParameterizedTypes.this.hashedParameterizedTypes.put(this, value); // for the unlikely case of multiple PTBKeys referring to this TVB chain to the next consumer: if (previousConsumer != null)