Skip to content

Commit aab90a7

Browse files
author
shinyafox
committed
8141415: JShell: wrap erroneous with one-liner comment-outed imports
Reviewed-by: rfield
1 parent c85226f commit aab90a7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

langtools/src/jdk.jshell/share/classes/jdk/jshell/ImportSnippet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,6 @@ ImportKey key() {
101101

102102
@Override
103103
String importLine(JShell state) {
104-
return source();
104+
return guts().wrapped();
105105
}
106106
}

langtools/test/jdk/jshell/ImportTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
/*
2525
* @test
26+
* @bug 8141415
2627
* @summary Test imports
2728
* @modules jdk.compiler/com.sun.tools.javac.api
2829
* jdk.compiler/com.sun.tools.javac.main
@@ -162,4 +163,9 @@ public void testImportMemberRedefinition() {
162163
assertEval("field;", "\"A\"");
163164
assertEval("method();", "\"A\"");
164165
}
166+
167+
public void testImportWithComment() {
168+
assertImportKeyMatch("import java.util.List;//comment", "List", SINGLE_TYPE_IMPORT_SUBKIND, added(VALID));
169+
assertEval("List l = null;");
170+
}
165171
}

0 commit comments

Comments
 (0)