diff --git a/idea/testData/htmlTabledRenderer/diagnostic1.html b/idea/testData/htmlTabledRenderer/diagnostic1.html new file mode 100644 index 00000000000..bf758c7d08b --- /dev/null +++ b/idea/testData/htmlTabledRenderer/diagnostic1.html @@ -0,0 +1,169 @@ + +Type inference failed: Cannot infer type parameter +T + in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +fun + <T, E> + writeToMyList
+
+
+(
+
+
+l : MyList<in T>,
+
+
+t : T
+
+
+)
+
+
+ : Unit +where + E : java.lang.Cloneable, E : java.io.Closeable
+
+
+None of the following substitutions
+
+ +
+
+
+
+
+
+
+ +( +
+
+
+ + +MyList<in jet.Any> + + +, +
+
+
+ +jet.Any +
+
+
+ +) +
+
+ +
+
+
+
+
+
+
+ +( +
+
+
+ +MyList<in jet.Int> + +, +
+
+
+ + +jet.Int + +
+
+
+ +) +
+
+
+can be applied to
+
+ +
+
+
+
+
+
+
+ +( +
+
+
+ +MyList<jet.Int> + +, +
+
+
+ +jet.Any +
+
+
+ +) +
+
+ diff --git a/idea/testData/htmlTabledRenderer/diagnostic2.html b/idea/testData/htmlTabledRenderer/diagnostic2.html new file mode 100644 index 00000000000..d334375751b --- /dev/null +++ b/idea/testData/htmlTabledRenderer/diagnostic2.html @@ -0,0 +1,167 @@ + +Type inference failed: Cannot infer type parameter +T + in + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +ctor + Cons<T, E : java.lang.Cloneable> +
+
+
+(
+
+
+l : MyList<in T>,
+
+
+t : T
+
+
+)
+
+
+
+
+
+None of the following substitutions
+
+ +
+
+
+
+
+
+
+ +( +
+
+
+ + +MyList<in jet.Any> + + +, +
+
+
+ +jet.Any +
+
+
+ +) +
+
+ +
+
+
+
+
+
+
+ +( +
+
+
+ +MyList<in jet.Int> + +, +
+
+
+ + +jet.Int + +
+
+
+ +) +
+
+
+can be applied to
+
+ +
+
+
+
+
+
+
+ +( +
+
+
+ +MyList<jet.Int> + +, +
+
+
+ +jet.Any +
+
+
+ +) +
+
+ diff --git a/idea/testData/htmlTabledRenderer/htmlTabledRenderer.kt b/idea/testData/htmlTabledRenderer/htmlTabledRenderer.kt new file mode 100644 index 00000000000..feb4d86f5df --- /dev/null +++ b/idea/testData/htmlTabledRenderer/htmlTabledRenderer.kt @@ -0,0 +1,14 @@ +// see org.jetbrains.jet.plugin.highlighter.HtmlTabledDescriptorRendererTest + +import java.io.Closeable + +class MyList(t: T) {} + +fun getMyList(t: T): MyList = MyList(t) +fun writeToMyList (l: MyList< in T>, t: T) where E: Closeable {} +class Cons(l: MyList, t: T) + +fun test1(int: Int, any: Any) { + writeToMyList(getMyList(int), any) + Cons(getMyList(int), any) +} diff --git a/idea/tests/org/jetbrains/jet/plugin/highlighter/HtmlTabledDescriptorRendererTest.java b/idea/tests/org/jetbrains/jet/plugin/highlighter/HtmlTabledDescriptorRendererTest.java new file mode 100644 index 00000000000..7bcac5fa4e5 --- /dev/null +++ b/idea/tests/org/jetbrains/jet/plugin/highlighter/HtmlTabledDescriptorRendererTest.java @@ -0,0 +1,71 @@ +/* + * Copyright 2010-2012 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.plugin.highlighter; + +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.Diagnostic; +import org.jetbrains.jet.lang.diagnostics.Errors; +import org.jetbrains.jet.lang.psi.JetFile; +import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter; +import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM; +import org.jetbrains.jet.plugin.PluginTestCaseBase; + +import java.util.Collections; +import java.util.List; + +public class HtmlTabledDescriptorRendererTest extends JetLiteFixture { + @Override + protected JetCoreEnvironment createEnvironment() { + return createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY); + } + + @Override + protected String getTestDataPath() { + return PluginTestCaseBase.getTestDataPathBase() + "/htmlTabledRenderer/"; + } + + public void testHtmlTabledRenderer() throws Exception { + String fileName = "htmlTabledRenderer.kt"; + JetFile psiFile = createPsiFile(null, fileName, loadFile(fileName)); + + AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, Collections.emptyList()); + BindingContext bindingContext = analyzeExhaust.getBindingContext(); + + List diagnostics = ContainerUtil.filter(bindingContext.getDiagnostics(), new Condition() { + @Override + public boolean value(Diagnostic diagnostic) { + return diagnostic.getFactory() == Errors.TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS; + } + }); + + assertEquals(diagnostics.size(), 2); + + int index = 1; + for (Diagnostic diagnostic : diagnostics) { + String readableDiagnosticHtml = IdeErrorMessages.RENDERER.render(diagnostic).replaceAll(">", ">\n"); + assertSameLinesWithFile(getTestDataPath() + "/diagnostic" + index + ".html", readableDiagnosticHtml); + + index++; + } + } +}