提交 cf74e42e 编写于 作者: V vromero

7179353: try-with-resources fails to compile with generic exception parameters

Reviewed-by: mcimadamore
上级 5baf545d
......@@ -808,9 +808,10 @@ public class Flow {
*/
void markThrown(JCTree tree, Type exc) {
if (!chk.isUnchecked(tree.pos(), exc)) {
if (!chk.isHandled(exc, caught))
if (!chk.isHandled(exc, caught)) {
pendingExits.append(new FlowPendingExit(tree, exc));
thrown = chk.incl(exc, thrown);
}
thrown = chk.incl(exc, thrown);
}
}
......@@ -1066,8 +1067,9 @@ public class Flow {
names.close,
List.<Type>nil(),
List.<Type>nil());
Type mt = types.memberType(resource.type, closeMethod);
if (closeMethod.kind == MTH) {
for (Type t : ((MethodSymbol)closeMethod).getThrownTypes()) {
for (Type t : mt.getThrownTypes()) {
markThrown(resource, t);
}
}
......
......@@ -349,7 +349,7 @@ public class Resolve {
: isAccessible(env, t.tsym, checkInner);
}
/** Is symbol accessible as a member of given type in given evironment?
/** Is symbol accessible as a member of given type in given environment?
* @param env The current environment.
* @param site The type of which the tested symbol is regarded
* as a member.
......@@ -490,11 +490,11 @@ public class Resolve {
};
/** Try to instantiate the type of a method so that it fits
* given type arguments and argument types. If succesful, return
* given type arguments and argument types. If successful, return
* the method's instantiated type, else return null.
* The instantiation will take into account an additional leading
* formal parameter if the method is an instance method seen as a member
* of un underdetermined site In this case, we treat site as an additional
* of an under determined site. In this case, we treat site as an additional
* parameter and the parameters of the class containing the method as
* additional type variables that get instantiated.
*
......
/*
* Copyright (c) 2013, 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 7179353
* @summary try-with-resources fails to compile with generic exception parameters
* @compile GenericsAndTWRCompileErrorTest.java
*/
public class GenericsAndTWRCompileErrorTest {
public static class Resource<E extends Exception> implements AutoCloseable {
public void close() throws E { }
}
public <E extends Exception> void test() throws E {
try (Resource<E> r = new Resource<E>()) {
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册