mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8243074: Misplaced and/or duplicate super or this constructor invocation not attributed
Fully attributing misplaced and/or duplicated super/this constructor invocations Reviewed-by: mcimadamore
This commit is contained in:
parent
4b6e75dc72
commit
ec1c111c6c
3 changed files with 127 additions and 80 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2020, 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
|
||||
|
@ -23,7 +23,7 @@
|
|||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8012929
|
||||
* @bug 8012929 8243074
|
||||
* @summary Trees.getElement should work not only for declaration trees, but also for use-trees
|
||||
* @modules jdk.compiler
|
||||
* @build TestGetElementReference
|
||||
|
@ -55,11 +55,12 @@ public class TestGetElementReference {
|
|||
Integer.toString(Runtime.getRuntime().version().feature());
|
||||
|
||||
public static void main(String... args) throws IOException {
|
||||
analyze("TestGetElementReferenceData.java");
|
||||
analyze("mod/module-info.java", "mod/api/pkg/Api.java");
|
||||
analyze(false, "TestGetElementReferenceData.java");
|
||||
analyze(false, "mod/module-info.java", "mod/api/pkg/Api.java");
|
||||
analyze(true, "TestGetElementReferenceDataWithErrors.java");
|
||||
}
|
||||
|
||||
private static void analyze(String... fileNames) throws IOException {
|
||||
private static void analyze(boolean allowErrors, String... fileNames) throws IOException {
|
||||
try (StandardJavaFileManager fm = ToolProvider.getSystemJavaCompiler().getStandardFileManager(null, null, null)) {
|
||||
List<JavaFileObject> files = new ArrayList<>();
|
||||
for (String fileName : fileNames) {
|
||||
|
@ -78,9 +79,11 @@ public class TestGetElementReference {
|
|||
|
||||
ct.analyze();
|
||||
|
||||
for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
|
||||
if (d.getKind() == Diagnostic.Kind.ERROR) {
|
||||
throw new IllegalStateException("Should have been attributed without errors: " + diagnostics.getDiagnostics());
|
||||
if (!allowErrors) {
|
||||
for (Diagnostic<? extends JavaFileObject> d : diagnostics.getDiagnostics()) {
|
||||
if (d.getKind() == Diagnostic.Kind.ERROR) {
|
||||
throw new IllegalStateException("Should have been attributed without errors: " + diagnostics.getDiagnostics());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue