diff options
author | Jim Laskey <jlaskey@openjdk.org> | 2023-08-09 10:46:42 +0000 |
---|---|---|
committer | Vitaly Provodin <vitaly.provodin@jetbrains.com> | 2023-08-12 06:47:31 +0700 |
commit | 82f1a2ce4a22e3d81bb745742a173993b2deb965 (patch) | |
tree | e4694a755f715884a458aa83d9a9c2fcb94a80cf | |
parent | 64c0d8c181cb8e6672bb84bbfc82ecc64a1461e4 (diff) | |
download | JetBrainsRuntime-82f1a2ce4a22e3d81bb745742a173993b2deb965.tar.gz |
8312814: Compiler crash when template processor type is a captured wildcard
Reviewed-by: jjg, vromero
Backport-of: f14245b3880ff735ae231b4c7d2c6b6907c5f7d4
-rw-r--r-- | src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java | 1 | ||||
-rw-r--r-- | test/langtools/tools/javac/template/T8312814.java | 39 |
2 files changed, 40 insertions, 0 deletions
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java index 4d1747c7389..36d3a2b24bd 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java @@ -838,6 +838,7 @@ public class TransTypes extends TreeTranslator { } public void visitStringTemplate(JCStringTemplate tree) { + tree.processor = translate(tree.processor, erasure(tree.processor.type)); tree.expressions = tree.expressions.stream() .map(e -> translate(e, erasure(e.type))).collect(List.collector()); tree.type = erasure(tree.type); diff --git a/test/langtools/tools/javac/template/T8312814.java b/test/langtools/tools/javac/template/T8312814.java new file mode 100644 index 00000000000..15207828a7d --- /dev/null +++ b/test/langtools/tools/javac/template/T8312814.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2023, 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 T8312814 + * @summary Verify proper behavior of TransType w.r.t. templated Strings + * @enablePreview + * @compile T8312814.java + */ + + +import java.util.List; + +public class T8312814 { + void x(List<? extends StringTemplate.Processor<String, RuntimeException>> list) { + list.get(0).""; + } +} + |