Skip to content

Commit f14245b

Browse files
author
Jim Laskey
committedAug 2, 2023
8312814: Compiler crash when template processor type is a captured wildcard
Reviewed-by: jlahoda, mcimadamore, vromero
1 parent 9b55e9a commit f14245b

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed
 

‎src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java

+1
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,7 @@ else if (tree.sym.kind == VAR) {
838838
}
839839

840840
public void visitStringTemplate(JCStringTemplate tree) {
841+
tree.processor = translate(tree.processor, erasure(tree.processor.type));
841842
tree.expressions = tree.expressions.stream()
842843
.map(e -> translate(e, erasure(e.type))).collect(List.collector());
843844
tree.type = erasure(tree.type);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test T8312814
26+
* @summary Verify proper behavior of TransType w.r.t. templated Strings
27+
* @enablePreview
28+
* @compile T8312814.java
29+
*/
30+
31+
32+
import java.util.List;
33+
34+
public class T8312814 {
35+
void x(List<? extends StringTemplate.Processor<String, RuntimeException>> list) {
36+
list.get(0)."";
37+
}
38+
}
39+

0 commit comments

Comments
 (0)
Please sign in to comment.