Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8268148: unchecked warnings handle ? and ? extends Object differently
Reviewed-by: jlahoda
  • Loading branch information
Vicente Romero committed Sep 3, 2021
1 parent 8c37909 commit ff4018b
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
Expand Up @@ -877,7 +877,9 @@ public boolean isExtendsBound() {
kind == UNBOUND;
}
public boolean isUnbound() {
return kind == UNBOUND;
// is it `?` or `? extends Object`?
return kind == UNBOUND ||
(kind == EXTENDS && type.tsym.flatName() == type.tsym.name.table.names.java_lang_Object);
}

@Override
Expand Down
@@ -1,8 +1,7 @@
T8176534.java:12:43: compiler.warn.unchecked.meth.invocation.applied: kindname.method, forEnumeration, java.util.Enumeration<T>, java.util.Enumeration, kindname.class, T8176534
T8176534.java:12:44: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Enumeration, java.util.Enumeration<T>
T8176534.java:12:28: compiler.warn.unchecked.meth.invocation.applied: kindname.method, newArrayList, java.util.Iterator<? extends E>, java.util.Iterator, kindname.class, T8176534
T8176534.java:12:43: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.Iterator, java.util.Iterator<? extends E>
T8176534.java:12:28: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.util.ArrayList, java.util.List<java.lang.String>
- compiler.err.warnings.and.werror
1 error
5 warnings
4 warnings
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/*
* @test
* @bug 8268148
* @summary unchecked warnings handle ? and ? extends Object differently
* @compile -Xlint:all -Werror UnboundAndBoundByObjectTest.java
*/

import java.util.List;

class UnboundAndBoundByObjectTest {
void f(List<? extends Object> x) {}
void g(List<?> x) {}

void h(List<String> x) {
f((List) x);
g((List) x);
}
}

1 comment on commit ff4018b

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.