mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8199762: JShell API: Failed to detect override when snippet to be overridden has been changed before
Reviewed-by: rfield
This commit is contained in:
parent
c003e3af3b
commit
4b6cd06e3d
3 changed files with 30 additions and 16 deletions
|
@ -42,7 +42,7 @@ import jdk.jshell.Key.MethodKey;
|
|||
public class MethodSnippet extends DeclarationSnippet {
|
||||
|
||||
final String signature;
|
||||
private String qualifiedParamaterTypes;
|
||||
private String qualifiedParameterTypes;
|
||||
|
||||
MethodSnippet(MethodKey key, String userSource, Wrap guts,
|
||||
String name, String signature, Wrap corralled,
|
||||
|
@ -90,10 +90,10 @@ public class MethodSnippet extends DeclarationSnippet {
|
|||
}
|
||||
|
||||
String qualifiedParameterTypes() {
|
||||
return qualifiedParamaterTypes;
|
||||
return qualifiedParameterTypes;
|
||||
}
|
||||
|
||||
void setQualifiedParamaterTypes(String sig) {
|
||||
qualifiedParamaterTypes = sig;
|
||||
void setQualifiedParameterTypes(String sig) {
|
||||
qualifiedParameterTypes = sig;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -397,12 +397,10 @@ final class Unit {
|
|||
if (replaceOldEvent != null) secondaryEvents.add(replaceOldEvent);
|
||||
|
||||
// Defined methods can overwrite methods of other (equivalent) snippets
|
||||
if (isNew && si.kind() == Kind.METHOD && status.isDefined()) {
|
||||
if (si.kind() == Kind.METHOD && status.isDefined()) {
|
||||
MethodSnippet msi = (MethodSnippet) si;
|
||||
String oqpt = msi.qualifiedParameterTypes();
|
||||
String nqpt = computeQualifiedParameterTypes(at, msi);
|
||||
if (!nqpt.equals(oqpt)) {
|
||||
msi.setQualifiedParamaterTypes(nqpt);
|
||||
msi.setQualifiedParameterTypes(
|
||||
computeQualifiedParameterTypes(at, msi));
|
||||
Status overwrittenStatus = overwriteMatchingMethod(msi);
|
||||
if (overwrittenStatus != null) {
|
||||
prevStatus = overwrittenStatus;
|
||||
|
@ -410,7 +408,6 @@ final class Unit {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if there is a method whose user-declared parameter types are
|
||||
// different (and thus has a different snippet) but whose compiled parameter
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8080357 8167643 8187359
|
||||
* @bug 8080357 8167643 8187359 8199762
|
||||
* @summary Tests for EvaluationState.methods
|
||||
* @build KullaTesting TestingInputStream ExpectedDiagnostic
|
||||
* @run testng MethodsTest
|
||||
|
@ -199,6 +199,23 @@ public class MethodsTest extends KullaTesting {
|
|||
assertActiveKeys();
|
||||
}
|
||||
|
||||
// 8199762
|
||||
public void methodsRedeclaration5() {
|
||||
Snippet m1 = methodKey(assertEval("int m(Object o) { return 10; }"));
|
||||
assertMethods(method("(Object)int", "m"));
|
||||
|
||||
Snippet m2 = methodKey(assertEval("int m(Object o) { return 30; }",
|
||||
ste(MAIN_SNIPPET, VALID, VALID, false, null),
|
||||
ste(m1, VALID, OVERWRITTEN, false, MAIN_SNIPPET)));
|
||||
|
||||
assertEval("<T> int m(T o) { return 30; }",
|
||||
ste(MAIN_SNIPPET, VALID, VALID, true, null),
|
||||
ste(m2, VALID, OVERWRITTEN, false, MAIN_SNIPPET));
|
||||
assertMethods(method("(T)int", "m"));
|
||||
assertEval("m(null)", "30");
|
||||
assertActiveKeys();
|
||||
}
|
||||
|
||||
public void methodsErrors() {
|
||||
assertDeclareFail("String f();",
|
||||
new ExpectedDiagnostic("compiler.err.missing.meth.body.or.decl.abstract", 0, 11, 7, -1, -1, Diagnostic.Kind.ERROR));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue