Skip to content

Commit 17634b5

Browse files
cpovirkGoogle Java Core Libraries
authored andcommitted
Change <? extends @nullable Object> back to <?>.
(i.e., roll back the com.google.common part of cl/377083162) The two should be equivalent, but Kotlin has/had a bug with `<?>` in the context of `@ElementTypesAreNonnullByDefault` (and/or `@ParametersAreNonnullByDefault`?). Now that we're moving away from `@*AreNonnullByDefault` and onto `@NullMarked`, we can use the simpler version. This is the next step toward [using JSpecify in Guava](jspecify/jspecify#239 (comment)). PiperOrigin-RevId: 708605353
1 parent 8ebb375 commit 17634b5

File tree

2 files changed

+14
-36
lines changed

2 files changed

+14
-36
lines changed

android/guava/src/com/google/common/base/Joiner.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,12 @@ private Joiner(Joiner prototype) {
8686
this.separator = prototype.separator;
8787
}
8888

89-
/*
90-
* In this file, we use <? extends @Nullable Object> instead of <?> to work around a Kotlin bug
91-
* (see b/189937072 until we file a bug against Kotlin itself). (The two should be equivalent, so
92-
* we normally prefer the shorter one.)
93-
*/
94-
9589
/**
9690
* Appends the string representation of each of {@code parts}, using the previously configured
9791
* separator between each, to {@code appendable}.
9892
*/
9993
@CanIgnoreReturnValue
100-
public <A extends Appendable> A appendTo(A appendable, Iterable<? extends @Nullable Object> parts)
101-
throws IOException {
94+
public <A extends Appendable> A appendTo(A appendable, Iterable<?> parts) throws IOException {
10295
return appendTo(appendable, parts.iterator());
10396
}
10497

@@ -109,8 +102,7 @@ public <A extends Appendable> A appendTo(A appendable, Iterable<? extends @Nulla
109102
* @since 11.0
110103
*/
111104
@CanIgnoreReturnValue
112-
public <A extends Appendable> A appendTo(A appendable, Iterator<? extends @Nullable Object> parts)
113-
throws IOException {
105+
public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
114106
checkNotNull(appendable);
115107
if (parts.hasNext()) {
116108
appendable.append(toString(parts.next()));
@@ -151,8 +143,7 @@ public final <A extends Appendable> A appendTo(
151143
* Iterable)}, except that it does not throw {@link IOException}.
152144
*/
153145
@CanIgnoreReturnValue
154-
public final StringBuilder appendTo(
155-
StringBuilder builder, Iterable<? extends @Nullable Object> parts) {
146+
public final StringBuilder appendTo(StringBuilder builder, Iterable<?> parts) {
156147
return appendTo(builder, parts.iterator());
157148
}
158149

@@ -164,8 +155,7 @@ public final StringBuilder appendTo(
164155
* @since 11.0
165156
*/
166157
@CanIgnoreReturnValue
167-
public final StringBuilder appendTo(
168-
StringBuilder builder, Iterator<? extends @Nullable Object> parts) {
158+
public final StringBuilder appendTo(StringBuilder builder, Iterator<?> parts) {
169159
try {
170160
appendTo((Appendable) builder, parts);
171161
} catch (IOException impossible) {
@@ -204,7 +194,7 @@ public final StringBuilder appendTo(
204194
* Returns a string containing the string representation of each of {@code parts}, using the
205195
* previously configured separator between each.
206196
*/
207-
public String join(Iterable<? extends @Nullable Object> parts) {
197+
public String join(Iterable<?> parts) {
208198
// We don't use the same optimization here as in the JRE flavor.
209199
// TODO: b/381289911 - Evaluate the performance impact of doing so.
210200
return join(parts.iterator());
@@ -224,7 +214,7 @@ public String join(Iterable<? extends @Nullable Object> parts) {
224214
*
225215
* @since 11.0
226216
*/
227-
public final String join(Iterator<? extends @Nullable Object> parts) {
217+
public final String join(Iterator<?> parts) {
228218
return appendTo(new StringBuilder(), parts).toString();
229219
}
230220

@@ -284,8 +274,7 @@ public String join(Iterable<? extends @Nullable Object> parts) {
284274
}
285275

286276
@Override
287-
public <A extends Appendable> A appendTo(
288-
A appendable, Iterator<? extends @Nullable Object> parts) throws IOException {
277+
public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
289278
checkNotNull(appendable, "appendable");
290279
checkNotNull(parts, "parts");
291280
while (parts.hasNext()) {

guava/src/com/google/common/base/Joiner.java

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,12 @@ private Joiner(Joiner prototype) {
8686
this.separator = prototype.separator;
8787
}
8888

89-
/*
90-
* In this file, we use <? extends @Nullable Object> instead of <?> to work around a Kotlin bug
91-
* (see b/189937072 until we file a bug against Kotlin itself). (The two should be equivalent, so
92-
* we normally prefer the shorter one.)
93-
*/
94-
9589
/**
9690
* Appends the string representation of each of {@code parts}, using the previously configured
9791
* separator between each, to {@code appendable}.
9892
*/
9993
@CanIgnoreReturnValue
100-
public <A extends Appendable> A appendTo(A appendable, Iterable<? extends @Nullable Object> parts)
101-
throws IOException {
94+
public <A extends Appendable> A appendTo(A appendable, Iterable<?> parts) throws IOException {
10295
return appendTo(appendable, parts.iterator());
10396
}
10497

@@ -109,8 +102,7 @@ public <A extends Appendable> A appendTo(A appendable, Iterable<? extends @Nulla
109102
* @since 11.0
110103
*/
111104
@CanIgnoreReturnValue
112-
public <A extends Appendable> A appendTo(A appendable, Iterator<? extends @Nullable Object> parts)
113-
throws IOException {
105+
public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
114106
checkNotNull(appendable);
115107
if (parts.hasNext()) {
116108
appendable.append(toString(parts.next()));
@@ -151,8 +143,7 @@ public final <A extends Appendable> A appendTo(
151143
* Iterable)}, except that it does not throw {@link IOException}.
152144
*/
153145
@CanIgnoreReturnValue
154-
public final StringBuilder appendTo(
155-
StringBuilder builder, Iterable<? extends @Nullable Object> parts) {
146+
public final StringBuilder appendTo(StringBuilder builder, Iterable<?> parts) {
156147
return appendTo(builder, parts.iterator());
157148
}
158149

@@ -164,8 +155,7 @@ public final StringBuilder appendTo(
164155
* @since 11.0
165156
*/
166157
@CanIgnoreReturnValue
167-
public final StringBuilder appendTo(
168-
StringBuilder builder, Iterator<? extends @Nullable Object> parts) {
158+
public final StringBuilder appendTo(StringBuilder builder, Iterator<?> parts) {
169159
try {
170160
appendTo((Appendable) builder, parts);
171161
} catch (IOException impossible) {
@@ -204,7 +194,7 @@ public final StringBuilder appendTo(
204194
* Returns a string containing the string representation of each of {@code parts}, using the
205195
* previously configured separator between each.
206196
*/
207-
public String join(Iterable<? extends @Nullable Object> parts) {
197+
public String join(Iterable<?> parts) {
208198
/*
209199
* If we can quickly determine how many elements there are likely to be, then we can use the
210200
* fastest possible implementation, which delegates to the array overload of String.join.
@@ -264,7 +254,7 @@ public String join(Iterable<? extends @Nullable Object> parts) {
264254
*
265255
* @since 11.0
266256
*/
267-
public final String join(Iterator<? extends @Nullable Object> parts) {
257+
public final String join(Iterator<?> parts) {
268258
return appendTo(new StringBuilder(), parts).toString();
269259
}
270260

@@ -324,8 +314,7 @@ public String join(Iterable<? extends @Nullable Object> parts) {
324314
}
325315

326316
@Override
327-
public <A extends Appendable> A appendTo(
328-
A appendable, Iterator<? extends @Nullable Object> parts) throws IOException {
317+
public <A extends Appendable> A appendTo(A appendable, Iterator<?> parts) throws IOException {
329318
checkNotNull(appendable, "appendable");
330319
checkNotNull(parts, "parts");
331320
while (parts.hasNext()) {

0 commit comments

Comments
 (0)