added PLACEHOLDER_FUNCTION_TYPE tests
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
//For testing error messages text see HtmlTabledDescriptorRendererTest.testFunctionPlaceholder
|
||||
package a
|
||||
|
||||
class A<T, R>
|
||||
fun <T, R> foo(a: A<T, R>) = a
|
||||
fun <T, R> bar(f: (T) -> R) = f
|
||||
|
||||
fun test() {
|
||||
<!TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH!>foo<!> <!TYPE_MISMATCH!>{ <!UNRESOLVED_REFERENCE!>it<!> }<!>
|
||||
<!TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH!>foo<!> <!TYPE_MISMATCH!>{ <!CANNOT_INFER_PARAMETER_TYPE!>x<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>}<!>
|
||||
<!TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH!>foo<!> <!TYPE_MISMATCH!>{ (x: Int) -> x}<!>
|
||||
|
||||
bar { <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>it<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>+<!> 1 }
|
||||
bar { <!CANNOT_INFER_PARAMETER_TYPE!>x<!> -> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>+<!> 1}
|
||||
bar { (x: Int) -> x + 1}
|
||||
}
|
||||
@@ -2275,6 +2275,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/ErrorTypeAsGenericParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("FunctionPlaceholder.kt")
|
||||
public void testFunctionPlaceholder() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/FunctionPlaceholder.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoAmbiguityForDifferentFunctionTypes.kt")
|
||||
public void testNoAmbiguityForDifferentFunctionTypes() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/NoAmbiguityForDifferentFunctionTypes.kt");
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
<!-- conflictingSubstitutions1 -->
|
||||
<html>
|
||||
Type inference failed: Cannot infer type parameter <b>
|
||||
T</b>
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
<!-- conflictingSubstitutions2 -->
|
||||
<html>
|
||||
Type inference failed: Cannot infer type parameter <b>
|
||||
T</b>
|
||||
@@ -0,0 +1,8 @@
|
||||
class A<T, R>
|
||||
fun <T, R> foo(a: A<T, R>) = a
|
||||
|
||||
fun test() {
|
||||
foo { it }
|
||||
foo { x -> x}
|
||||
foo { (x: Int) -> x}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<!-- functionPlaceholder1 -->
|
||||
<html>
|
||||
Type inference failed: <table>
|
||||
<tr>
|
||||
<td width="10%">
|
||||
</td>
|
||||
<td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;">
|
||||
<b>
|
||||
fun</b>
|
||||
<T, R>
|
||||
foo</td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
(</td>
|
||||
<td align="right" style="white-space:nowrap;font-weight:bold;">
|
||||
a : A<T, R></td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
)</td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
: A<T, R></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7" style="white-space:nowrap;">
|
||||
cannot be applied to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="10%">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
<b>
|
||||
(</b>
|
||||
</td>
|
||||
<td align="right" style="white-space:nowrap;">
|
||||
<font color=red>
|
||||
<b>
|
||||
??? -> ???</b>
|
||||
</font>
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
<b>
|
||||
)</b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html>
|
||||
@@ -0,0 +1,48 @@
|
||||
<!-- functionPlaceholder2 -->
|
||||
<html>
|
||||
Type inference failed: <table>
|
||||
<tr>
|
||||
<td width="10%">
|
||||
</td>
|
||||
<td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;">
|
||||
<b>
|
||||
fun</b>
|
||||
<T, R>
|
||||
foo</td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
(</td>
|
||||
<td align="right" style="white-space:nowrap;font-weight:bold;">
|
||||
a : A<T, R></td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
)</td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
: A<T, R></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7" style="white-space:nowrap;">
|
||||
cannot be applied to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="10%">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
<b>
|
||||
(</b>
|
||||
</td>
|
||||
<td align="right" style="white-space:nowrap;">
|
||||
<font color=red>
|
||||
<b>
|
||||
(???) -> ???</b>
|
||||
</font>
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
<b>
|
||||
)</b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html>
|
||||
@@ -0,0 +1,48 @@
|
||||
<!-- functionPlaceholder3 -->
|
||||
<html>
|
||||
Type inference failed: <table>
|
||||
<tr>
|
||||
<td width="10%">
|
||||
</td>
|
||||
<td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;">
|
||||
<b>
|
||||
fun</b>
|
||||
<T, R>
|
||||
foo</td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
(</td>
|
||||
<td align="right" style="white-space:nowrap;font-weight:bold;">
|
||||
a : A<T, R></td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
)</td>
|
||||
<td style="white-space:nowrap;font-weight:bold;">
|
||||
: A<T, R></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7" style="white-space:nowrap;">
|
||||
cannot be applied to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="10%">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
<b>
|
||||
(</b>
|
||||
</td>
|
||||
<td align="right" style="white-space:nowrap;">
|
||||
<font color=red>
|
||||
<b>
|
||||
(jet.Int) -> ???</b>
|
||||
</font>
|
||||
</td>
|
||||
<td style="white-space:nowrap;">
|
||||
<b>
|
||||
)</b>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</html>
|
||||
+19
-6
@@ -16,12 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.highlighter;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.lang.diagnostics.AbstractDiagnosticFactory;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
@@ -31,7 +33,9 @@ import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.plugin.PluginTestCaseBase;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class HtmlTabledDescriptorRendererTest extends JetLiteFixture {
|
||||
@Override
|
||||
@@ -44,28 +48,37 @@ public class HtmlTabledDescriptorRendererTest extends JetLiteFixture {
|
||||
return PluginTestCaseBase.getTestDataPathBase() + "/htmlTabledRenderer/";
|
||||
}
|
||||
|
||||
public void testHtmlTabledRenderer() throws Exception {
|
||||
String fileName = "htmlTabledRenderer.kt";
|
||||
public void doTest(String name, int diagnosticNumber, AbstractDiagnosticFactory... diagnosticFactories) throws Exception {
|
||||
String fileName = name + ".kt";
|
||||
JetFile psiFile = createPsiFile(null, fileName, loadFile(fileName));
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, Collections.<AnalyzerScriptParameter>emptyList());
|
||||
BindingContext bindingContext = analyzeExhaust.getBindingContext();
|
||||
|
||||
final Set<AbstractDiagnosticFactory> factoriesSet = Sets.newHashSet(diagnosticFactories);
|
||||
List<Diagnostic> diagnostics = ContainerUtil.filter(bindingContext.getDiagnostics(), new Condition<Diagnostic>() {
|
||||
@Override
|
||||
public boolean value(Diagnostic diagnostic) {
|
||||
return diagnostic.getFactory() == Errors.TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS;
|
||||
return factoriesSet.contains(diagnostic.getFactory());
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(diagnostics.size(), 2);
|
||||
assertEquals("Expected diagnostics number mismatch:", diagnosticNumber, diagnostics.size());
|
||||
|
||||
int index = 1;
|
||||
for (Diagnostic diagnostic : diagnostics) {
|
||||
String readableDiagnosticHtml = IdeErrorMessages.RENDERER.render(diagnostic).replaceAll(">", ">\n");
|
||||
assertSameLinesWithFile(getTestDataPath() + "/diagnostic" + index + ".html", readableDiagnosticHtml);
|
||||
String readableDiagnosticHtml = "<!-- " + name + index + " -->\n" + IdeErrorMessages.RENDERER.render(diagnostic).replaceAll(">", ">\n");
|
||||
assertSameLinesWithFile(getTestDataPath() + "/" + name + index + ".html", readableDiagnosticHtml);
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
public void testConflictingSubstitutions() throws Exception {
|
||||
doTest("conflictingSubstitutions", 2, Errors.TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS);
|
||||
}
|
||||
|
||||
public void testFunctionPlaceholder() throws Exception {
|
||||
doTest("functionPlaceholder", 3, Errors.TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user