|
18 | 18 |
|
19 | 19 | import static com.google.common.base.Preconditions.checkArgument;
|
20 | 20 | import static com.google.common.base.Preconditions.checkNotNull;
|
| 21 | +import static com.google.common.base.Preconditions.checkState; |
21 | 22 |
|
22 | 23 | import com.google.common.base.Preconditions;
|
23 | 24 | import com.google.common.collect.ImmutableList;
|
@@ -148,24 +149,11 @@ public void add(SourceFile file) {
|
148 | 149 | /** Adds a source code input to this chunk. */
|
149 | 150 | public void add(CompilerInput input) {
|
150 | 151 | String inputName = input.getName();
|
151 |
| - checkArgument( |
152 |
| - !inputs.containsKey(inputName), "%s already exist in chunk %s", inputName, this.getName()); |
153 |
| - inputs.put(inputName, input); |
| 152 | + CompilerInput previous = inputs.put(inputName, input); |
| 153 | + checkState(previous == null, "%s already exist in chunk %s", inputName, this.getName()); |
154 | 154 | input.setChunk(this);
|
155 | 155 | }
|
156 | 156 |
|
157 |
| - /** |
158 |
| - * Adds a source code input to this chunk. Call only if the input might already be associated with |
159 |
| - * a chunk. Otherwise, use add(CompilerInput input). |
160 |
| - */ |
161 |
| - void addAndOverrideChunk(CompilerInput input) { |
162 |
| - String inputName = input.getName(); |
163 |
| - checkArgument( |
164 |
| - !inputs.containsKey(inputName), "%s already exist in chunk %s", inputName, this.getName()); |
165 |
| - inputs.put(inputName, input); |
166 |
| - input.overrideModule(this); |
167 |
| - } |
168 |
| - |
169 | 157 | /** Adds a dependency on another chunk. */
|
170 | 158 | public void addDependency(JSChunk dep) {
|
171 | 159 | checkNotNull(dep);
|
|
0 commit comments