Use default render to check are all errors mentioned in tests. It's far more easier to read.

This commit is contained in:
Nikolay Krasko
2015-10-26 18:34:07 +03:00
parent b8c72ec4e9
commit 911432c99c
65 changed files with 109 additions and 75 deletions
@@ -22,6 +22,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.editor.Document;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.ShutDownTracker;
@@ -481,6 +482,13 @@ public class JetTestUtils {
LazyResolveTestUtil.resolve(environment.getProject(), jetFiles, environment);
}
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull Editor editor) {
String actualText = editor.getDocument().getText();
String afterText = new StringBuilder(actualText).insert(editor.getCaretModel().getOffset(), "<caret>").toString();
assertEqualsToFile(expectedFile, afterText);
}
public static void assertEqualsToFile(@NotNull File expectedFile, @NotNull String actual) {
assertEqualsToFile(expectedFile, actual, new Function1<String, String>() {
@Override
@@ -20,8 +20,8 @@ import com.intellij.codeInsight.intention.IntentionAction
import com.intellij.psi.PsiFile
import com.intellij.testFramework.UsefulTestCase
import org.jetbrains.kotlin.diagnostics.Severity
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFully
import org.jetbrains.kotlin.idea.highlighter.IdeErrorMessages
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.test.InTextDirectivesUtils
@@ -35,7 +35,7 @@ public object DirectiveBasedActionUtils {
val actualErrors = file.analyzeFully().getDiagnostics()
.filter { it.getSeverity() == Severity.ERROR }
.map { IdeErrorMessages.render(it) }
.map { DefaultErrorMessages.render(it).replace("\n", "<br>") }
.sorted()
UsefulTestCase.assertOrderedEquals("All actual errors should be mentioned in test data with // ERROR: directive. But no unnecessary errors should be me mentioned",
@@ -1,5 +1,5 @@
// IS_APPLICABLE: false
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li>foo(String, Boolean, <font color=red><b>Char</b></font>) <i>defined in</i> root package</li><li>foo(String, Boolean, <font color=red><b>Int</b></font>) <i>defined in</i> root package</li></ul></html>
// ERROR: None of the following functions can be called with the arguments supplied: <br>public fun foo(s: kotlin.String, b: kotlin.Boolean, c: kotlin.Char): kotlin.Unit defined in root package<br>public fun foo(s: kotlin.String, b: kotlin.Boolean, p: kotlin.Int): kotlin.Unit defined in root package
fun foo(s: String, b: Boolean, p: Int){}
fun foo(s: String, b: Boolean, c: Char){}
@@ -1,6 +1,6 @@
// WITH_RUNTIME
// IS_APPLICABLE: false
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Boolean</td></tr><tr><td>Found:</td><td>kotlin.Int</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.Int but kotlin.Boolean was expected
// ERROR: Condition must be of type kotlin.Boolean, but is of type kotlin.Int
// ERROR: Infix call corresponds to a dot-qualified call 'foo.times(10)' which is not allowed on a nullable receiver 'foo'. Use ?.-qualified call instead
@@ -1,5 +1,5 @@
// IS_APPLICABLE: false
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Boolean</td></tr><tr><td>Found:</td><td>kotlin.Int</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.Int but kotlin.Boolean was expected
// ERROR: Condition must be of type kotlin.Boolean, but is of type kotlin.Int
// ERROR: Infix call corresponds to a dot-qualified call 'foo.times(10)' which is not allowed on a nullable receiver 'foo'. Use ?.-qualified call instead
@@ -1,6 +1,6 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li>assert(<font color=red><b>Boolean</b></font>) <i>defined in</i> kotlin</li><li>assert(<font color=red><b>Boolean</b></font>, <font color=red><b>() &rarr; Any</b></font>) <i>defined in</i> kotlin</li><li>assert(<font color=red><b>Boolean</b></font>, Any = ...) <i>defined in</i> kotlin</li></ul></html>
// ERROR: None of the following functions can be called with the arguments supplied: <br>public fun assert(value: kotlin.Boolean): kotlin.Unit defined in kotlin<br>public inline fun assert(value: kotlin.Boolean, lazyMessage: () -> kotlin.Any): kotlin.Unit defined in kotlin<br>@kotlin.Deprecated public fun assert(value: kotlin.Boolean, message: kotlin.Any = ...): kotlin.Unit defined in kotlin
fun foo() {
<caret>assert()
@@ -1,5 +1,5 @@
// IS_APPLICABLE: false
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
fun foo(a: Boolean, b: Boolean) : Boolean {
return !<caret>(!a + b)
}
@@ -1,5 +1,5 @@
// IS_AVAILABLE: true
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li>bar(<font color=red><b>Int = ...</b></font>, <font color=red><b>(Int) &rarr; Int</b></font>) <i>defined in</i> root package</li><li>bar(<font color=red><b>Int</b></font>, <font color=red><b>Int</b></font>, <font color=red><b>(Int) &rarr; Int</b></font>) <i>defined in</i> root package</li></ul></html>
// ERROR: None of the following functions can be called with the arguments supplied: <br>public fun bar(a: kotlin.Int = ..., f: (kotlin.Int) -> kotlin.Int): kotlin.Unit defined in root package<br>public fun bar(a: kotlin.Int, b: kotlin.Int, f: (kotlin.Int) -> kotlin.Int): kotlin.Unit defined in root package
// ERROR: Unresolved reference: it
fun foo() {
@@ -1,5 +1,5 @@
// IS_AVAILABLE: true
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li>bar(<font color=red><b>Int = ...</b></font>, <font color=red><b>(Int) &rarr; Int</b></font>) <i>defined in</i> root package</li><li>bar(<font color=red><b>Int</b></font>, <font color=red><b>Int</b></font>, <font color=red><b>(Int) &rarr; Int</b></font>) <i>defined in</i> root package</li></ul></html>
// ERROR: None of the following functions can be called with the arguments supplied: <br>public fun bar(a: kotlin.Int = ..., f: (kotlin.Int) -> kotlin.Int): kotlin.Unit defined in root package<br>public fun bar(a: kotlin.Int, b: kotlin.Int, f: (kotlin.Int) -> kotlin.Int): kotlin.Unit defined in root package
// ERROR: Unresolved reference: it
fun foo() {
@@ -1,5 +1,5 @@
// IS_APPLICABLE: true
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>() &rarr; ???</td></tr></table></html>
// ERROR: Type mismatch: inferred type is () -> ??? but kotlin.Int was expected
// ERROR: No value passed for parameter b
// ERROR: Unresolved reference: it
fun foo() {
@@ -1,9 +1,9 @@
// IS_APPLICABLE: true
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>() &rarr; ???</td></tr></table></html>
// ERROR: Type mismatch: inferred type is () -> ??? but kotlin.Int was expected
// ERROR: No value passed for parameter b
// ERROR: Unresolved reference: it
fun foo() {
bar { it }
bar<caret> { it }
}
fun bar(a: Int, b: (Int) -> Int) {
@@ -1,5 +1,5 @@
// IS_APPLICABLE: false
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li>foo(<font color=red><b>Int</b></font>) <i>defined in</i> B</li><li>foo(<font color=red><b>String</b></font>) <i>defined in</i> B</li></ul></html>
// ERROR: None of the following functions can be called with the arguments supplied: <br>public final fun foo(p: kotlin.Int): kotlin.Unit defined in B<br>public open fun foo(p: kotlin.String): kotlin.Unit defined in B
open class B {
open fun foo(p: String){}
@@ -1,6 +1,6 @@
// IS_APPLICABLE: false
// WITH_RUNTIME
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Unit</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but kotlin.Unit was expected
class A {
public fun <caret>foo() {
+1 -1
View File
@@ -1,5 +1,5 @@
// "Make 'A' abstract" "false"
// ERROR: <html>Class 'X' must override <b>public</b> <b>open</b> <b>fun</b> foo(): kotlin.Unit <i>defined in</i> X<br />because it inherits many implementations of it</html>
// ERROR: Class 'X' must override public open fun foo(): kotlin.Unit defined in X because it inherits many implementations of it
// ACTION: Create test
// ACTION: Make internal
// ACTION: Make private
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.AddGenericUpperBoundFix" "false"
// ERROR: <html>Type argument is not within its bounds.<table><tr><td>Expected:</td><td>kotlin.Any</td></tr><tr><td>Found:</td><td>E</td></tr></table></html>
// ERROR: Type argument is not within its bounds: should be subtype of 'kotlin.Any'
fun <T : Any> foo() = 1
@@ -1,5 +1,5 @@
// "Add 'kotlin.Any' as upper bound for E" "true"
// ERROR: <html>Type parameter bound for <b>U</b> in <table><tr><td width="10%"></td><td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;"><b>fun</b> &lt;T : kotlin.Any, U : kotlin.Any&gt; foo</td><td style="white-space:nowrap;font-weight:bold;">(</td><td align="right" style="white-space:nowrap;font-weight:bold;">x: T,</td><td align="right" style="white-space:nowrap;font-weight:bold;">y: U</td><td style="white-space:nowrap;font-weight:bold;">)</td><td style="white-space:nowrap;font-weight:bold;">: kotlin.Int</td></tr></table> is not satisfied: inferred type <font color=red><b>F</b></font> is not a subtype of <b>kotlin.Any</b></html>
// ERROR: Type parameter bound for U in fun <T : kotlin.Any, U : kotlin.Any> foo(x: T, y: U): kotlin.Int<br> is not satisfied: inferred type F is not a subtype of kotlin.Any
fun <T : Any, U: Any> foo(x: T, y: U) = 1
@@ -1,5 +1,5 @@
// "Add 'kotlin.Any' as upper bound for E" "true"
// ERROR: <html>Type parameter bound for <b>U</b> in <table><tr><td width="10%"></td><td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;"><b>fun</b> &lt;T : kotlin.Any, U : kotlin.Any&gt; foo</td><td style="white-space:nowrap;font-weight:bold;">(</td><td align="right" style="white-space:nowrap;font-weight:bold;">x: T,</td><td align="right" style="white-space:nowrap;font-weight:bold;">y: U</td><td style="white-space:nowrap;font-weight:bold;">)</td><td style="white-space:nowrap;font-weight:bold;">: kotlin.Int</td></tr></table> is not satisfied: inferred type <font color=red><b>F</b></font> is not a subtype of <b>kotlin.Any</b></html>
// ERROR: Type parameter bound for U in fun <T : kotlin.Any, U : kotlin.Any> foo(x: T, y: U): kotlin.Int<br> is not satisfied: inferred type F is not a subtype of kotlin.Any
fun <T : Any, U: Any> foo(x: T, y: U) = 1
+1 -1
View File
@@ -1,7 +1,7 @@
// "Make 'object : T {}' abstract" "false"
// ACTION: Implement members
// ACTION: Split property declaration
// ERROR: <html>Object must be declared abstract or implement abstract member<br/><b>public</b> <b>abstract</b> <b>fun</b> foo(): kotlin.Unit <i>defined in</i> T</html>
// ERROR: Object must be declared abstract or implement abstract member public abstract fun foo(): kotlin.Unit defined in T
interface T {
fun foo()
}
+2 -2
View File
@@ -1,5 +1,5 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> <b>fun</b> kotlin.String.minus(i: java.lang.Integer): kotlin.String <i>defined in</i> h</li><li><b>public</b> <b>fun</b> kotlin.String.minus(str: kotlin.String): kotlin.String <i>defined in</i> h</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public fun kotlin.String.minus(i: java.lang.Integer): kotlin.String defined in h<br>public fun kotlin.String.minus(str: kotlin.String): kotlin.String defined in h
package h
@@ -8,7 +8,7 @@ import util.minus
interface H
fun f(h: H?) {
h - "other"
h <caret>- "other"
}
@@ -1,5 +1,5 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> <b>fun</b> kotlin.String.minus(i: java.lang.Integer): kotlin.String <i>defined in</i> h</li><li><b>public</b> <b>fun</b> kotlin.String.minus(str: kotlin.String): kotlin.String <i>defined in</i> h</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public fun kotlin.String.minus(i: java.lang.Integer): kotlin.String defined in h<br>public fun kotlin.String.minus(str: kotlin.String): kotlin.String defined in h
package h
+2 -2
View File
@@ -1,6 +1,6 @@
// FILE: first.before.kt
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
package testing
@@ -23,7 +23,7 @@ operator fun Some.plus(i: Int) : Some = this
// FILE: first.after.kt
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
package testing
@@ -1,6 +1,6 @@
// FILE: first.before.kt
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
package testing
@@ -23,7 +23,7 @@ operator fun Some.plusAssign(i: Int) {}
// FILE: first.after.kt
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
package testing
@@ -1,6 +1,6 @@
// FILE: first.before.kt
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
package testing
@@ -31,7 +31,7 @@ operator fun Some.plus(i: Int) : Some = this
// FILE: first.after.kt
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
package testing
+2 -2
View File
@@ -1,5 +1,5 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
package h
@@ -8,5 +8,5 @@ import util.plus
interface H
fun f(h: H?) {
h + "other"
h <caret>+ "other"
}
@@ -1,5 +1,5 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> kotlin.String?.plus(other: kotlin.Any?): kotlin.String <i>defined in</i> kotlin</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin
package h
@@ -1,5 +1,5 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> h.A.unaryPlus(): kotlin.Int <i>defined in</i> h</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun h.A.unaryPlus(): kotlin.Int defined in h
package h
@@ -8,7 +8,7 @@ import util.unaryPlus
interface H
fun f(h: H?) {
+h
<caret>+h
}
class A()
@@ -1,5 +1,5 @@
// "Import" "true"
// ERROR: <html>Unresolved reference. <br/> None of the following candidates is applicable because of receiver type mismatch: <ul><li><b>public</b> operator <b>fun</b> h.A.unaryPlus(): kotlin.Int <i>defined in</i> h</li></ul></html>
// ERROR: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: <br>public operator fun h.A.unaryPlus(): kotlin.Int defined in h
package h
@@ -1,5 +1,5 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Class 'Foo' must be declared abstract or implement abstract member<br/><b>public</b> <b>abstract</b> operator <b>fun</b> getValue(thisRef: A&lt;T&gt;, property: kotlin.reflect.KProperty&lt;*&gt;): B <i>defined in</i> kotlin.properties.ReadOnlyProperty</html>
// ERROR: Class 'Foo' must be declared abstract or implement abstract member public abstract operator fun getValue(thisRef: A<T>, property: kotlin.reflect.KProperty<*>): B defined in kotlin.properties.ReadOnlyProperty
open class B
@@ -1,7 +1,7 @@
import kotlin.properties.ReadOnlyProperty
// "Create class 'Foo'" "true"
// ERROR: <html>Class 'Foo' must be declared abstract or implement abstract member<br/><b>public</b> <b>abstract</b> operator <b>fun</b> getValue(thisRef: A&lt;T&gt;, property: kotlin.reflect.KProperty&lt;*&gt;): B <i>defined in</i> kotlin.properties.ReadOnlyProperty</html>
// ERROR: Class 'Foo' must be declared abstract or implement abstract member public abstract operator fun getValue(thisRef: A<T>, property: kotlin.reflect.KProperty<*>): B defined in kotlin.properties.ReadOnlyProperty
open class B
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Type inference failed: <table><tr><td width="10%"></td><td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;"><b>constructor</b> Foo&lt;U&gt;</td><td style="white-space:nowrap;font-weight:bold;">(</td><td align="right" style="white-space:nowrap;font-weight:bold;">u: U</td><td style="white-space:nowrap;font-weight:bold;">)</td><td style="white-space:nowrap;font-weight:bold;"></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>U</b></font></td><td style="white-space:nowrap;"><b>)</b></td></tr></table></html>
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>U</td></tr><tr><td>Found:</td><td>U</td></tr></table></html>
// ERROR: Type inference failed: constructor Foo<U>(u: U)<br>cannot be applied to<br>(U)<br>
// ERROR: Type mismatch: inferred type is U but U was expected
class A<T>(val n: T) {
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Type inference failed: <table><tr><td width="10%"></td><td align="right" colspan="2" style="white-space:nowrap;font-weight:bold;"><b>constructor</b> Foo&lt;U&gt;</td><td style="white-space:nowrap;font-weight:bold;">(</td><td align="right" style="white-space:nowrap;font-weight:bold;">u: U</td><td style="white-space:nowrap;font-weight:bold;">)</td><td style="white-space:nowrap;font-weight:bold;"></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>U</b></font></td><td style="white-space:nowrap;"><b>)</b></td></tr></table></html>
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>U</td></tr><tr><td>Found:</td><td>U</td></tr></table></html>
// ERROR: Type inference failed: constructor Foo<U>(u: U)<br>cannot be applied to<br>(U)<br>
// ERROR: Type mismatch: inferred type is U but U was expected
class A<T>(val n: T) {
inner class Foo<U>(u: U) {
@@ -1,5 +1,5 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>V</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but V was expected
// ERROR: The integer literal does not conform to the expected type U
class B<T>(val t: T) {
@@ -1,5 +1,5 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>V</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but V was expected
// ERROR: The integer literal does not conform to the expected type U
class B<T>(val t: T) {
@@ -1,5 +1,5 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>U</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but U was expected
class B<T>(val t: T) {
@@ -1,5 +1,5 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>U</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but U was expected
class B<T>(val t: T) {
inner class Foo<U>(i: Int, u: U) {
@@ -1,5 +1,5 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>W</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but W was expected
// ERROR: The integer literal does not conform to the expected type V
class B<T>(val t: T) {
@@ -1,5 +1,5 @@
// "Create class 'Foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>W</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but W was expected
// ERROR: The integer literal does not conform to the expected type V
class B<T>(val t: T) {
@@ -1,5 +1,5 @@
// "Create member function 'foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>A&lt;kotlin.Int&gt;</td></tr></table></html>
// ERROR: Type mismatch: inferred type is A<kotlin.Int> but kotlin.Int was expected
class A<T>(val n: T)
@@ -1,5 +1,5 @@
// "Create member function 'foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>A&lt;kotlin.Int&gt;</td></tr></table></html>
// ERROR: Type mismatch: inferred type is A<kotlin.Int> but kotlin.Int was expected
class A<T>(val n: T) {
fun foo(s: String, t: T): Any {
@@ -2,7 +2,7 @@
// ACTION: Add parameter to constructor 'A'
// ACTION: Change 'b' type to 'A'
// ACTION: Create function 'A'
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>B</td></tr><tr><td>Found:</td><td>A</td></tr></table></html>
// ERROR: Type mismatch: inferred type is A but B was expected
// ERROR: Too many arguments for public constructor A() defined in A
class A
@@ -1,5 +1,5 @@
// "Create member property 'foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>A&lt;kotlin.Int&gt;</td></tr></table></html>
// ERROR: Type mismatch: inferred type is A<kotlin.Int> but kotlin.Int was expected
// ERROR: Property must be initialized or be abstract
class A<T>(val n: T)
@@ -1,5 +1,5 @@
// "Create member property 'foo'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>A&lt;kotlin.Int&gt;</td></tr></table></html>
// ERROR: Type mismatch: inferred type is A<kotlin.Int> but kotlin.Int was expected
// ERROR: Property must be initialized or be abstract
class A<T>(val n: T) {
@@ -1,5 +1,5 @@
// "Insert 'this()' call" "true"
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li><init>(<font color=red><b>Int</b></font>) <i>defined in</i> A</li><li><init>(<font color=red><b>String</b></font>) <i>defined in</i> A</li></ul></html>
// ERROR: None of the following functions can be called with the arguments supplied: <br>public constructor A(x: kotlin.Int) defined in A<br>public constructor A(x: kotlin.String) defined in A
class A(val x: Int) {
constructor(x: String)<caret>
@@ -1,5 +1,5 @@
// "Insert 'this()' call" "true"
// ERROR: <html>None of the following functions can be called with the arguments supplied. <ul><li><init>(<font color=red><b>Int</b></font>) <i>defined in</i> A</li><li><init>(<font color=red><b>String</b></font>) <i>defined in</i> A</li></ul></html>
// ERROR: None of the following functions can be called with the arguments supplied: <br>public constructor A(x: kotlin.Int) defined in A<br>public constructor A(x: kotlin.String) defined in A
class A(val x: Int) {
constructor(x: String) : this(<caret>)
@@ -1,5 +1,5 @@
// "Change function signature..." "true"
// ERROR: <html>Class 'B' must be declared abstract or implement abstract member<br/><b>public</b> <b>abstract</b> <b>fun</b> f(a: kotlin.String): kotlin.Unit <i>defined in</i> A</html>
// ERROR: Class 'B' must be declared abstract or implement abstract member public abstract fun f(a: kotlin.String): kotlin.Unit defined in A
interface A {
fun f(a: Int)
fun f(a: String)
@@ -1,5 +1,5 @@
// "Change function signature..." "true"
// ERROR: <html>Class 'B' must be declared abstract or implement abstract member<br/><b>public</b> <b>abstract</b> <b>fun</b> f(a: kotlin.String): kotlin.Unit <i>defined in</i> A</html>
// ERROR: Class 'B' must be declared abstract or implement abstract member public abstract fun f(a: kotlin.String): kotlin.Unit defined in A
interface A {
fun f(a: Int)
fun f(a: String)
@@ -1,5 +1,5 @@
// "Change function signature to 'fun f(a: Int): Int'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but kotlin.Int was expected
open class A {
open fun f(a: Int): Int = 0
}
@@ -1,5 +1,5 @@
// "Change function signature to 'fun f(a: Int): Int'" "true"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but kotlin.Int was expected
open class A {
open fun f(a: Int): Int = 0
}
@@ -1,6 +1,6 @@
// "Change 'A.x' type to '(Int) -> Int'" "false"
// ACTION: Change 'C.x' type to '(String) -> Int'
// ERROR: <html>Return type is '(kotlin.Int) &rarr; kotlin.Int', which is not a subtype of overridden<br/><b>public</b> <b>abstract</b> <b>val</b> x: (kotlin.String) &rarr; kotlin.Int <i>defined in</i> A</html>
// ERROR: Return type of 'x' is not a subtype of the return type of the overridden member 'public abstract val x: (kotlin.String) -> kotlin.Int defined in A'
interface A {
val x: (String) -> Int
}
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.ChangeVariableTypeFix" "false"
// ERROR: <html>Var-property type is 'kotlin.String', which is not a type of overridden<br/><b>public</b> <b>abstract</b> <b>var</b> x: kotlin.Int <i>defined in</i> A</html>
// ERROR: Type of 'x' doesn't match the type of the overridden var-property 'public abstract var x: kotlin.Int defined in A'
interface A {
var x: Int
}
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.ChangeVariableTypeFix" "false"
// ERROR: <html>Var-property type is 'kotlin.Int', which is not a type of overridden<br/><b>public</b> <b>abstract</b> <b>var</b> x: kotlin.String <i>defined in</i> A</html>
// ERROR: Type of 'x' doesn't match the type of the overridden var-property 'public abstract var x: kotlin.String defined in A'
interface A {
var x: String
}
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.ChangeFunctionReturnTypeFix" "false"
// ERROR: <html>Return type is 'kotlin.Long', which is not a subtype of overridden<br/><b>public</b> <b>abstract</b> <b>fun</b> foo(): kotlin.Int <i>defined in</i> A</html>
// ERROR: Return type of 'foo' is not a subtype of the return type of the overridden member 'public abstract fun foo(): kotlin.Int defined in A'
interface A {
fun foo(): Int
}
@@ -1,7 +1,7 @@
// "Change 'B.foo' function return type to 'Int'" "false"
// "Change 'B.foo' function return type to 'Long'" "false"
// "Remove explicitly specified return type" "false"
// ERROR: <html>Return type is 'kotlin.String', which is not a subtype of overridden<br/><b>public</b> <b>abstract</b> <b>fun</b> foo(): kotlin.Int <i>defined in</i> A</html>
// ERROR: Return type of 'foo' is not a subtype of the return type of the overridden member 'public abstract fun foo(): kotlin.Int defined in A'
abstract class A {
abstract fun foo() : Int;
}
@@ -1,6 +1,6 @@
// "Add non-null asserted (!!) call" "false"
// ACTION: Change parameter 's' type of function 'other' to 'String?'
// ERROR: <html>ype mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>kotlin.String?</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String? but kotlin.Int was expected
fun test() {
val s: String? = ""
other(<caret>s)
+1 -1
View File
@@ -1,6 +1,6 @@
// "Cast expression 'Foo<Number>()' to 'Foo<Int>'" "false"
// ACTION: Create test
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>Foo&lt;kotlin.Int&gt;</td></tr><tr><td>Found:</td><td>Foo&lt;kotlin.Number&gt;</td></tr></table></html>
// ERROR: Type mismatch: inferred type is Foo<kotlin.Number> but Foo<kotlin.Int> was expected
class Foo<T>
fun foo(): Foo<Int> {
+1 -1
View File
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.CastExpressionFix" "false"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>B</td></tr><tr><td>Found:</td><td>A</td></tr></table></html>
// ERROR: Type mismatch: inferred type is A but B was expected
open class A
class B : A()
@@ -1,6 +1,6 @@
// "Change 'B.x' type to '(String) -> [ERROR : Ay]'" "false"
// ACTION: Change 'A.x' type to '(Int) -> Int'
// ERROR: <html>Return type is '(kotlin.Int) &rarr; kotlin.Int', which is not a subtype of overridden<br/><b>public</b> <b>abstract</b> <b>val</b> x: (kotlin.String) &rarr; [ERROR : Ay] <i>defined in</i> A</html>
// ERROR: Return type of 'x' is not a subtype of the return type of the overridden member 'public abstract val x: (kotlin.String) -> [ERROR : Ay] defined in A'
// ERROR: Unresolved reference: Ay
interface A {
val x: (String) -> Ay
@@ -1,5 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.ChangeParameterTypeFix" "false"
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>kotlin.String</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.String but kotlin.Int was expected
interface A {
fun f(i: Int): Boolean
}
@@ -1,5 +1,5 @@
// "???" "false"
//ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Array&lt;out kotlin.String&gt;</td></tr><tr><td>Found:</td><td>kotlin.Array&lt;out kotlin.Int&gt;</td></tr></table></html>
//ERROR: Type mismatch: inferred type is kotlin.Array<out kotlin.Int> but kotlin.Array<out kotlin.String> was expected
//this test checks that there is no ArrayIndexOutOfBoundsException when there are more arguments than parameters
fun <T> array1(vararg a : T) = a
@@ -4,7 +4,7 @@
// ACTION: Create enum 'NoSuchType'
// ACTION: Create interface 'NoSuchType'
// ACTION: Remove explicit lambda parameter types (may break code)
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>([ERROR : NoSuchType]) &rarr; kotlin.Int</td></tr></table></html>
// ERROR: Type mismatch: inferred type is ([ERROR : NoSuchType]) -> kotlin.Int but kotlin.Int was expected
// ERROR: Unresolved reference: NoSuchType
fun foo(): Int {
@@ -1,7 +1,7 @@
// "Change 'AA.f' function return type to 'Boolean'" "false"
// ACTION: Change 'AAA.g' function return type to 'Int'
// ACTION: Convert to expression body
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Boolean</td></tr><tr><td>Found:</td><td>kotlin.Int</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.Int but kotlin.Boolean was expected
interface A {
fun f(): Int
}
@@ -2,7 +2,7 @@
// ACTION: Change 'AAA.g' function return type to 'Boolean'
// ACTION: Convert to expression body
// ACTION: Replace overloaded operator with function call
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.Int</td></tr><tr><td>Found:</td><td>kotlin.Boolean</td></tr></table></html>
// ERROR: Type mismatch: inferred type is kotlin.Boolean but kotlin.Int was expected
interface A {
fun contains(i: Int): Boolean
}
@@ -37,7 +37,9 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase;
import org.jetbrains.kotlin.idea.util.application.ApplicationUtilsKt;
import org.jetbrains.kotlin.psi.KtFile;
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
import org.jetbrains.kotlin.test.JetTestUtils;
import org.junit.Assert;
import org.junit.ComparisonFailure;
import java.io.File;
import java.util.ArrayList;
@@ -172,7 +174,12 @@ public abstract class AbstractIntentionTest extends KotlinCodeInsightTestCase {
myFile = entry.getValue();
String canonicalPathToExpectedFile = PathUtil.getCanonicalPath(entry.getKey() + ".after");
checkResultByFile(canonicalPathToExpectedFile);
try {
checkResultByFile(canonicalPathToExpectedFile);
}
catch (ComparisonFailure e) {
JetTestUtils.assertEqualsToFile(new File(canonicalPathToExpectedFile), getEditor());
}
}
}
}
@@ -276,7 +276,13 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
doAction(text, actionShouldBeAvailable, beforeFileName);
if (actionShouldBeAvailable) {
checkResultByFile(beforeFileName.replace(".before.Main.", ".after."));
String afterFilePath = beforeFileName.replace(".before.Main.", ".after.");
try {
checkResultByFile(afterFilePath);
}
catch (ComparisonFailure e) {
JetTestUtils.assertEqualsToFile(new File(afterFilePath), getEditor());
}
PsiFile mainFile = myFile;
String mainFileName = mainFile.getName();
@@ -293,7 +299,9 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
if (e.getMessage().startsWith("Cannot find file")) {
checkResultByFile(extraFileFullPath);
}
else throw e;
else {
throw e;
}
}
}
}
@@ -301,6 +309,9 @@ public abstract class AbstractQuickFixMultiFileTest extends KotlinDaemonAnalyzer
catch (ComparisonFailure e) {
throw e;
}
catch (AssertionError e) {
throw e;
}
catch (Throwable e) {
e.printStackTrace();
fail(getTestName(true));
@@ -32,6 +32,7 @@ import com.intellij.refactoring.util.CanonicalTypes;
import com.intellij.refactoring.util.CommonRefactoringUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.VisibilityUtil;
import junit.framework.ComparisonFailure;
import kotlin.ArraysKt;
import kotlin.CollectionsKt;
import kotlin.SetsKt;
@@ -55,6 +56,7 @@ import org.jetbrains.kotlin.resolve.dataClassUtils.DataClassUtilsKt;
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform;
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode;
import org.jetbrains.kotlin.test.InTextDirectivesUtils;
import org.jetbrains.kotlin.test.JetTestUtils;
import java.io.File;
import java.util.*;
@@ -1479,7 +1481,13 @@ public class JetChangeSignatureTest extends KotlinCodeInsightTestCase {
for (Editor editor : editors) {
setActiveEditor(editor);
PsiFile currentFile = getFile();
checkResultByFile(currentFile.getName().replace("Before.", "After."));
String afterFilePath = currentFile.getName().replace("Before.", "After.");
try {
checkResultByFile(afterFilePath);
}
catch (ComparisonFailure e) {
JetTestUtils.assertEqualsToFile(new File(afterFilePath), getEditor());
}
if (checkErrorsAfter && currentFile instanceof KtFile) {
DirectiveBasedActionUtils.INSTANCE$.checkForUnexpectedErrors((KtFile) currentFile);
}