author | mcimadamore |
Mon, 24 Oct 2011 13:00:30 +0100 | |
changeset 10816 | ce8a7e9d8882 |
child 14963 | 974d4423c999 |
permissions | -rw-r--r-- |
10816
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
1 |
/* |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
4 |
* |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
8 |
* |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
14 |
* |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
18 |
* |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
21 |
* questions. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
23 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
24 |
/* |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
26 |
* @bug 7098660 |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
27 |
* @summary Write better overload resolution/inference tests |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
28 |
* @library ../lib |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
29 |
* @build JavacTestingAbstractProcessor ResolveHarness |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
30 |
* @run main ResolveHarness |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
31 |
*/ |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
32 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
33 |
import com.sun.source.util.JavacTask; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
34 |
import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
35 |
import com.sun.tools.javac.code.Type.MethodType; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
36 |
import com.sun.tools.javac.util.JCDiagnostic; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
37 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
38 |
import java.io.File; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
39 |
import java.util.Set; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
40 |
import java.util.Arrays; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
41 |
import java.util.ArrayList; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
42 |
import java.util.Collections; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
43 |
import java.util.HashMap; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
44 |
import java.util.HashSet; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
45 |
import java.util.List; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
46 |
import java.util.Map; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
47 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
48 |
import javax.annotation.processing.AbstractProcessor; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
49 |
import javax.annotation.processing.RoundEnvironment; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
50 |
import javax.annotation.processing.SupportedAnnotationTypes; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
51 |
import javax.lang.model.element.Element; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
52 |
import javax.lang.model.element.TypeElement; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
53 |
import javax.tools.Diagnostic; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
54 |
import javax.tools.Diagnostic.Kind; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
55 |
import javax.tools.DiagnosticListener; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
56 |
import javax.tools.JavaCompiler; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
57 |
import javax.tools.JavaFileObject; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
58 |
import javax.tools.StandardJavaFileManager; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
59 |
import javax.tools.ToolProvider; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
60 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
61 |
import static javax.tools.StandardLocation.*; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
62 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
63 |
public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileObject> { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
64 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
65 |
static int nerrors = 0; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
66 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
67 |
static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
68 |
static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
69 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
70 |
public static void main(String[] args) throws Exception { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
71 |
fm.setLocation(SOURCE_PATH, |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
72 |
Arrays.asList(new File(System.getProperty("test.src"), "tests"))); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
73 |
for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
74 |
new ResolveHarness(jfo).check(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
75 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
76 |
if (nerrors > 0) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
77 |
throw new AssertionError("Errors were found"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
78 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
79 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
80 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
81 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
82 |
JavaFileObject jfo; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
83 |
DiagnosticProcessor[] diagProcessors; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
84 |
Map<ElementKey, Candidate> candidatesMap = new HashMap<ElementKey, Candidate>(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
85 |
Set<String> declaredKeys = new HashSet<>(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
86 |
List<Diagnostic<? extends JavaFileObject>> diags = new ArrayList<>(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
87 |
List<ElementKey> seenCandidates = new ArrayList<>(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
88 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
89 |
protected ResolveHarness(JavaFileObject jfo) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
90 |
this.jfo = jfo; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
91 |
this.diagProcessors = new DiagnosticProcessor[] { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
92 |
new VerboseResolutionNoteProcessor(), |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
93 |
new VerboseDeferredInferenceNoteProcessor(), |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
94 |
new ErrorProcessor() |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
95 |
}; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
96 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
97 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
98 |
protected void check() throws Exception { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
99 |
String[] options = { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
100 |
"-XDshouldStopPolicy=ATTR", |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
101 |
"-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference" |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
102 |
}; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
103 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
104 |
AbstractProcessor[] processors = { new ResolveCandidateFinder(), null }; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
105 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
106 |
@SuppressWarnings("unchecked") |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
107 |
DiagnosticListener<? super JavaFileObject>[] diagListeners = |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
108 |
new DiagnosticListener[] { new DiagnosticHandler(false), new DiagnosticHandler(true) }; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
109 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
110 |
for (int i = 0 ; i < options.length ; i ++) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
111 |
JavacTask ct = (JavacTask)comp.getTask(null, fm, diagListeners[i], |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
112 |
Arrays.asList(options[i]), null, Arrays.asList(jfo)); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
113 |
if (processors[i] != null) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
114 |
ct.setProcessors(Collections.singleton(processors[i])); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
115 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
116 |
ct.analyze(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
117 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
118 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
119 |
//check diags |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
120 |
for (Diagnostic<? extends JavaFileObject> diag : diags) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
121 |
for (DiagnosticProcessor proc : diagProcessors) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
122 |
if (proc.matches(diag)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
123 |
proc.process(diag); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
124 |
break; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
125 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
126 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
127 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
128 |
//check all candidates have been used up |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
129 |
for (Map.Entry<ElementKey, Candidate> entry : candidatesMap.entrySet()) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
130 |
if (!seenCandidates.contains(entry.getKey())) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
131 |
error("Redundant @Candidate annotation on method " + entry.getKey().elem); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
132 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
133 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
134 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
135 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
136 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
137 |
diags.add(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
138 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
139 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
140 |
Candidate getCandidateAtPos(Element methodSym, long line, long col) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
141 |
Candidate c = candidatesMap.get(new ElementKey(methodSym)); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
142 |
if (c != null) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
143 |
Pos pos = c.pos(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
144 |
if (!pos.userDefined() || |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
145 |
(pos.line() == line && pos.col() == col)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
146 |
seenCandidates.add(new ElementKey(methodSym)); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
147 |
return c; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
148 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
149 |
} else { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
150 |
error("Missing @Candidate annotation on method " + methodSym); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
151 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
152 |
return null; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
153 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
154 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
155 |
void checkSig(Candidate c, Element methodSym, MethodType mtype) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
156 |
if (c.sig().length() > 0 && !c.sig().equals(mtype.toString())) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
157 |
error("Inferred type mismatch for method: " + methodSym); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
158 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
159 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
160 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
161 |
protected void error(String msg) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
162 |
nerrors++; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
163 |
System.err.printf("Error occurred while checking file: %s\nreason: %s\n", jfo.getName(), msg); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
164 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
165 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
166 |
/** |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
167 |
* Base class for diagnostic processor. It provides methods for matching and |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
168 |
* processing a given diagnostic object (overridden by subclasses). |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
169 |
*/ |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
170 |
abstract class DiagnosticProcessor { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
171 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
172 |
List<String> codes; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
173 |
Diagnostic.Kind kind; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
174 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
175 |
public DiagnosticProcessor(Kind kind, String... codes) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
176 |
this.codes = Arrays.asList(codes); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
177 |
this.kind = kind; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
178 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
179 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
180 |
abstract void process(Diagnostic<? extends JavaFileObject> diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
181 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
182 |
boolean matches(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
183 |
return (codes.isEmpty() || codes.contains(diagnostic.getCode())) && |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
184 |
diagnostic.getKind() == kind; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
185 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
186 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
187 |
JCDiagnostic asJCDiagnostic(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
188 |
if (diagnostic instanceof JCDiagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
189 |
return (JCDiagnostic)diagnostic; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
190 |
} else if (diagnostic instanceof DiagnosticSourceUnwrapper) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
191 |
return ((DiagnosticSourceUnwrapper)diagnostic).d; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
192 |
} else { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
193 |
throw new AssertionError("Cannot convert diagnostic to JCDiagnostic: " + diagnostic.getClass().getName()); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
194 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
195 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
196 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
197 |
List<JCDiagnostic> subDiagnostics(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
198 |
JCDiagnostic diag = asJCDiagnostic(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
199 |
if (diag instanceof JCDiagnostic.MultilineDiagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
200 |
return ((JCDiagnostic.MultilineDiagnostic)diag).getSubdiagnostics(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
201 |
} else { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
202 |
throw new AssertionError("Cannot extract subdiagnostics: " + diag.getClass().getName()); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
203 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
204 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
205 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
206 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
207 |
/** |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
208 |
* Processor for verbose resolution notes generated by javac. The processor |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
209 |
* checks that the diagnostic is associated with a method declared by |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
210 |
* a class annotated with the special @TraceResolve marker annotation. If |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
211 |
* that's the case, all subdiagnostics (one for each resolution candidate) |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
212 |
* are checked against the corresponding @Candidate annotations, using |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
213 |
* a VerboseCandidateSubdiagProcessor. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
214 |
*/ |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
215 |
class VerboseResolutionNoteProcessor extends DiagnosticProcessor { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
216 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
217 |
VerboseResolutionNoteProcessor() { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
218 |
super(Kind.NOTE, |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
219 |
"compiler.note.verbose.resolve.multi", |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
220 |
"compiler.note.verbose.resolve.multi.1"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
221 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
222 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
223 |
@Override |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
224 |
void process(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
225 |
Element siteSym = getSiteSym(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
226 |
if (siteSym.getAnnotation(TraceResolve.class) == null) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
227 |
return; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
228 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
229 |
int candidateIdx = 0; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
230 |
for (JCDiagnostic d : subDiagnostics(diagnostic)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
231 |
boolean isMostSpecific = candidateIdx++ == mostSpecific(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
232 |
VerboseCandidateSubdiagProcessor subProc = |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
233 |
new VerboseCandidateSubdiagProcessor(isMostSpecific, phase(diagnostic), success(diagnostic)); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
234 |
if (subProc.matches(d)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
235 |
subProc.process(d); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
236 |
} else { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
237 |
throw new AssertionError("Bad subdiagnostic: " + d.getCode()); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
238 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
239 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
240 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
241 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
242 |
Element getSiteSym(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
243 |
return (Element)asJCDiagnostic(diagnostic).getArgs()[1]; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
244 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
245 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
246 |
int mostSpecific(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
247 |
return success(diagnostic) ? |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
248 |
(Integer)asJCDiagnostic(diagnostic).getArgs()[2] : -1; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
249 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
250 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
251 |
boolean success(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
252 |
return diagnostic.getCode().equals("compiler.note.verbose.resolve.multi"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
253 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
254 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
255 |
Phase phase(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
256 |
return Phase.fromString(asJCDiagnostic(diagnostic).getArgs()[3].toString()); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
257 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
258 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
259 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
260 |
/** |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
261 |
* Processor for verbose resolution subdiagnostic notes generated by javac. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
262 |
* The processor checks that the details of the overload candidate |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
263 |
* match against the info contained in the corresponding @Candidate |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
264 |
* annotation (if any). |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
265 |
*/ |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
266 |
class VerboseCandidateSubdiagProcessor extends DiagnosticProcessor { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
267 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
268 |
boolean mostSpecific; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
269 |
Phase phase; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
270 |
boolean success; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
271 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
272 |
public VerboseCandidateSubdiagProcessor(boolean mostSpecific, Phase phase, boolean success) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
273 |
super(Kind.OTHER, |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
274 |
"compiler.misc.applicable.method.found", |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
275 |
"compiler.misc.applicable.method.found.1", |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
276 |
"compiler.misc.not.applicable.method.found"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
277 |
this.mostSpecific = mostSpecific; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
278 |
this.phase = phase; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
279 |
this.success = success; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
280 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
281 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
282 |
@Override |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
283 |
void process(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
284 |
Element methodSym = methodSym(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
285 |
Candidate c = getCandidateAtPos(methodSym, |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
286 |
asJCDiagnostic(diagnostic).getLineNumber(), |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
287 |
asJCDiagnostic(diagnostic).getColumnNumber()); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
288 |
if (c == null) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
289 |
return; //nothing to check |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
290 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
291 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
292 |
if (c.applicable().length == 0 && c.mostSpecific()) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
293 |
error("Inapplicable method cannot be most specific " + methodSym); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
294 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
295 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
296 |
if (isApplicable(diagnostic) != Arrays.asList(c.applicable()).contains(phase)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
297 |
error("Invalid candidate's applicability " + methodSym); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
298 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
299 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
300 |
if (success) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
301 |
for (Phase p : c.applicable()) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
302 |
if (phase.ordinal() < p.ordinal()) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
303 |
error("Invalid phase " + p + " on method " + methodSym); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
304 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
305 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
306 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
307 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
308 |
if (Arrays.asList(c.applicable()).contains(phase)) { //applicable |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
309 |
if (c.mostSpecific() != mostSpecific) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
310 |
error("Invalid most specific value for method " + methodSym); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
311 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
312 |
MethodType mtype = getSig(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
313 |
if (mtype != null) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
314 |
checkSig(c, methodSym, mtype); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
315 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
316 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
317 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
318 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
319 |
boolean isApplicable(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
320 |
return !diagnostic.getCode().equals("compiler.misc.not.applicable.method.found"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
321 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
322 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
323 |
Element methodSym(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
324 |
return (Element)asJCDiagnostic(diagnostic).getArgs()[1]; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
325 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
326 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
327 |
MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
328 |
JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2]; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
329 |
if (details == null) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
330 |
return null; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
331 |
} else if (details instanceof JCDiagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
332 |
return details.getCode().equals("compiler.misc.full.inst.sig") ? |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
333 |
(MethodType)details.getArgs()[0] : null; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
334 |
} else { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
335 |
throw new AssertionError("Bad diagnostic arg: " + details); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
336 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
337 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
338 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
339 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
340 |
/** |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
341 |
* Processor for verbose deferred inference notes generated by javac. The |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
342 |
* processor checks that the inferred signature for a given generic method |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
343 |
* call corresponds to the one (if any) declared in the @Candidate annotation. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
344 |
*/ |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
345 |
class VerboseDeferredInferenceNoteProcessor extends DiagnosticProcessor { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
346 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
347 |
public VerboseDeferredInferenceNoteProcessor() { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
348 |
super(Kind.NOTE, "compiler.note.deferred.method.inst"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
349 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
350 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
351 |
@Override |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
352 |
void process(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
353 |
Element methodSym = methodSym(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
354 |
Candidate c = getCandidateAtPos(methodSym, |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
355 |
asJCDiagnostic(diagnostic).getLineNumber(), |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
356 |
asJCDiagnostic(diagnostic).getColumnNumber()); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
357 |
MethodType sig = sig(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
358 |
if (c != null && sig != null) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
359 |
checkSig(c, methodSym, sig); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
360 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
361 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
362 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
363 |
Element methodSym(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
364 |
return (Element)asJCDiagnostic(diagnostic).getArgs()[0]; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
365 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
366 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
367 |
MethodType sig(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
368 |
return (MethodType)asJCDiagnostic(diagnostic).getArgs()[1]; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
369 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
370 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
371 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
372 |
/** |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
373 |
* Processor for all error diagnostics; if the error key is not declared in |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
374 |
* the test file header, the processor reports an error. |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
375 |
*/ |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
376 |
class ErrorProcessor extends DiagnosticProcessor { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
377 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
378 |
public ErrorProcessor() { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
379 |
super(Diagnostic.Kind.ERROR); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
380 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
381 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
382 |
@Override |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
383 |
void process(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
384 |
if (!declaredKeys.contains(diagnostic.getCode())) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
385 |
error("Unexpected compilation error key '" + diagnostic.getCode() + "'"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
386 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
387 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
388 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
389 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
390 |
@SupportedAnnotationTypes({"Candidate","TraceResolve"}) |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
391 |
class ResolveCandidateFinder extends JavacTestingAbstractProcessor { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
392 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
393 |
@Override |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
394 |
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
395 |
if (roundEnv.processingOver()) |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
396 |
return true; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
397 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
398 |
TypeElement traceResolveAnno = elements.getTypeElement("TraceResolve"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
399 |
TypeElement candidateAnno = elements.getTypeElement("Candidate"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
400 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
401 |
if (!annotations.contains(traceResolveAnno)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
402 |
error("no @TraceResolve annotation found in test class"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
403 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
404 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
405 |
if (!annotations.contains(candidateAnno)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
406 |
error("no @candidate annotation found in test class"); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
407 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
408 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
409 |
for (Element elem: roundEnv.getElementsAnnotatedWith(traceResolveAnno)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
410 |
TraceResolve traceResolve = elem.getAnnotation(TraceResolve.class); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
411 |
declaredKeys.addAll(Arrays.asList(traceResolve.keys())); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
412 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
413 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
414 |
for (Element elem: roundEnv.getElementsAnnotatedWith(candidateAnno)) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
415 |
candidatesMap.put(new ElementKey(elem), elem.getAnnotation(Candidate.class)); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
416 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
417 |
return true; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
418 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
419 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
420 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
421 |
class ElementKey { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
422 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
423 |
String key; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
424 |
Element elem; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
425 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
426 |
public ElementKey(Element elem) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
427 |
this.elem = elem; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
428 |
this.key = computeKey(elem); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
429 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
430 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
431 |
@Override |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
432 |
public boolean equals(Object obj) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
433 |
if (obj instanceof ElementKey) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
434 |
ElementKey other = (ElementKey)obj; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
435 |
return other.key.equals(key); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
436 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
437 |
return false; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
438 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
439 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
440 |
@Override |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
441 |
public int hashCode() { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
442 |
return key.hashCode(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
443 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
444 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
445 |
String computeKey(Element e) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
446 |
StringBuilder buf = new StringBuilder(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
447 |
while (e != null) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
448 |
buf.append(e.toString()); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
449 |
e = e.getEnclosingElement(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
450 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
451 |
buf.append(jfo.getName()); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
452 |
return buf.toString(); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
453 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
454 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
455 |
@Override |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
456 |
public String toString() { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
457 |
return "Key{"+key+"}"; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
458 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
459 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
460 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
461 |
class DiagnosticHandler implements DiagnosticListener<JavaFileObject> { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
462 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
463 |
boolean shouldRecordDiags; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
464 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
465 |
DiagnosticHandler(boolean shouldRecordDiags) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
466 |
this.shouldRecordDiags = shouldRecordDiags; |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
467 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
468 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
469 |
public void report(Diagnostic<? extends JavaFileObject> diagnostic) { |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
470 |
if (shouldRecordDiags) |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
471 |
diags.add(diagnostic); |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
472 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
473 |
|
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
474 |
} |
ce8a7e9d8882
7098660: Write better overload resolution/inference tests
mcimadamore
parents:
diff
changeset
|
475 |
} |