Wrap diagnostic parameters to double quotes and split by comma instead of semicolon

This commit is contained in:
victor.petukhov
2018-12-28 14:51:55 +03:00
parent 46bd5ba107
commit 30762a450a
55 changed files with 242 additions and 254 deletions
@@ -6,12 +6,9 @@
package org.jetbrains.kotlin.checkers.diagnostics package org.jetbrains.kotlin.checkers.diagnostics
import com.intellij.openapi.util.text.StringUtil import com.intellij.openapi.util.text.StringUtil
import com.intellij.util.SmartList
import com.intellij.util.containers.ContainerUtil import com.intellij.util.containers.ContainerUtil
import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1 import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil.INDIVIDUAL_PARAMETER_PATTERN
import org.jetbrains.kotlin.checkers.utils.CheckerTestUtil.SHOULD_BE_ESCAPED
import org.jetbrains.kotlin.diagnostics.rendering.AbstractDiagnosticWithParametersRenderer import org.jetbrains.kotlin.diagnostics.rendering.AbstractDiagnosticWithParametersRenderer
import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages import org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticWithParameters1Renderer import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticWithParameters1Renderer
@@ -79,7 +76,7 @@ class TextDiagnostic(
result.append(name) result.append(name)
if (parameters != null) { if (parameters != null) {
result.append("(") result.append("(")
result.append(StringUtil.join(parameters, { escape(it) }, "; ")) result.append(StringUtil.join(parameters, { "\"$it\"" }, ", "))
result.append(")") result.append(")")
} }
return result.toString() return result.toString()
@@ -90,13 +87,6 @@ class TextDiagnostic(
} }
companion object { companion object {
private fun escape(s: String): String {
return s.replace("([$SHOULD_BE_ESCAPED])".toRegex(), "\\\\$1")
}
private fun unescape(s: String): String {
return s.replace("\\\\([$SHOULD_BE_ESCAPED])".toRegex(), "$1")
}
fun parseDiagnostic(text: String): TextDiagnostic { fun parseDiagnostic(text: String): TextDiagnostic {
val matcher = CheckerTestUtil.individualDiagnosticPattern.matcher(text) val matcher = CheckerTestUtil.individualDiagnosticPattern.matcher(text)
if (!matcher.find()) if (!matcher.find())
@@ -119,11 +109,12 @@ class TextDiagnostic(
inference inference
) )
val parsedParameters = SmartList<String>() return TextDiagnostic(
val parametersMatcher = INDIVIDUAL_PARAMETER_PATTERN.matcher(parameters) name,
while (parametersMatcher.find()) platform,
parsedParameters.add(unescape(parametersMatcher.group().trim({ it <= ' ' }))) parameters.trim('"').split(Regex("""",\s*"""")),
return TextDiagnostic(name, platform, parsedParameters, inference) inference
)
} }
private fun computeInferenceCompatibility(abbreviation: String?): InferenceCompatibility { private fun computeInferenceCompatibility(abbreviation: String?): InferenceCompatibility {
@@ -41,10 +41,7 @@ object CheckerTestUtil {
const val OLD_INFERENCE_PREFIX = "OI" const val OLD_INFERENCE_PREFIX = "OI"
private const val IGNORE_DIAGNOSTIC_PARAMETER = "IGNORE" private const val IGNORE_DIAGNOSTIC_PARAMETER = "IGNORE"
val SHOULD_BE_ESCAPED = "\\)\\(;" private const val INDIVIDUAL_DIAGNOSTIC = """(\w+;)?(\w+:)?(\w+)(?:\(((?:".*?")(?:,\s*".*?")*)\))?"""
private val DIAGNOSTIC_PARAMETER = "(?:(?:\\\\[" + SHOULD_BE_ESCAPED + "])|[^" + SHOULD_BE_ESCAPED + "])+"
private val INDIVIDUAL_DIAGNOSTIC = "(\\w+;)?(\\w+:)?(\\w+)(\\(" + DIAGNOSTIC_PARAMETER + "(;\\s*" + DIAGNOSTIC_PARAMETER + ")*\\))?"
val INDIVIDUAL_PARAMETER_PATTERN = Pattern.compile(DIAGNOSTIC_PARAMETER)
private val rangeStartOrEndPattern = Pattern.compile("(<!$INDIVIDUAL_DIAGNOSTIC(,\\s*$INDIVIDUAL_DIAGNOSTIC)*!>)|(<!>)") private val rangeStartOrEndPattern = Pattern.compile("(<!$INDIVIDUAL_DIAGNOSTIC(,\\s*$INDIVIDUAL_DIAGNOSTIC)*!>)|(<!>)")
val individualDiagnosticPattern: Pattern = Pattern.compile(INDIVIDUAL_DIAGNOSTIC) val individualDiagnosticPattern: Pattern = Pattern.compile(INDIVIDUAL_DIAGNOSTIC)
@@ -11,17 +11,17 @@ class OkTest {
} }
// Errors // Errors
<!INAPPLICABLE_INFIX_MODIFIER(must have a single value parameter)!>infix<!> fun String.e1(o: String, o2: String? = null) = o <!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun String.e1(o: String, o2: String? = null) = o
<!INAPPLICABLE_INFIX_MODIFIER(must have a single value parameter)!>infix<!> fun String.e2(o: String = "", o2: String? = null) = o <!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun String.e2(o: String = "", o2: String? = null) = o
<!INAPPLICABLE_INFIX_MODIFIER(must be a member or an extension function)!>infix<!> fun e3() {} <!INAPPLICABLE_INFIX_MODIFIER("must be a member or an extension function")!>infix<!> fun e3() {}
<!INAPPLICABLE_INFIX_MODIFIER(must be a member or an extension function)!>infix<!> fun e4(s: String) {} <!INAPPLICABLE_INFIX_MODIFIER("must be a member or an extension function")!>infix<!> fun e4(s: String) {}
<!INAPPLICABLE_INFIX_MODIFIER(must have a single value parameter)!>infix<!> fun String.e5() {} <!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun String.e5() {}
<!INAPPLICABLE_INFIX_MODIFIER(must have a single value parameter)!>infix<!> fun String.e6(a: Int, b: Int) {} <!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun String.e6(a: Int, b: Int) {}
<!INAPPLICABLE_INFIX_MODIFIER(must be a member or an extension function)!>infix<!> fun e7(a: Int, b: Int) {} <!INAPPLICABLE_INFIX_MODIFIER("must be a member or an extension function")!>infix<!> fun e7(a: Int, b: Int) {}
class Example { class Example {
<!INAPPLICABLE_INFIX_MODIFIER(must have a single value parameter)!>infix<!> fun e8(s: String, a: Int = 0) {} <!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun e8(s: String, a: Int = 0) {}
<!INAPPLICABLE_INFIX_MODIFIER(must have a single value parameter)!>infix<!> fun e9(s: String, a: Int) {} <!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun e9(s: String, a: Int) {}
<!INAPPLICABLE_INFIX_MODIFIER(must have a single value parameter)!>infix<!> fun e10() {} <!INAPPLICABLE_INFIX_MODIFIER("must have a single value parameter")!>infix<!> fun e10() {}
} }
@@ -2,7 +2,7 @@
class A { class A {
inner class B { inner class B {
companion <!NESTED_CLASS_NOT_ALLOWED(Companion object)!>object<!> { } companion <!NESTED_CLASS_NOT_ALLOWED("Companion object")!>object<!> { }
} }
} }
@@ -1,10 +1,10 @@
class A { class A {
inner class I { inner class I {
companion <!NESTED_CLASS_NOT_ALLOWED(Companion object)!>object A<!> companion <!NESTED_CLASS_NOT_ALLOWED("Companion object")!>object A<!>
<!MANY_COMPANION_OBJECTS!>companion<!> <!NESTED_CLASS_NOT_ALLOWED(Companion object)!>object B<!> <!MANY_COMPANION_OBJECTS!>companion<!> <!NESTED_CLASS_NOT_ALLOWED("Companion object")!>object B<!>
<!MANY_COMPANION_OBJECTS!>companion<!> <!NESTED_CLASS_NOT_ALLOWED(Companion object)!>object C<!> <!MANY_COMPANION_OBJECTS!>companion<!> <!NESTED_CLASS_NOT_ALLOWED("Companion object")!>object C<!>
} }
} }
@@ -1,21 +1,21 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNREACHABLE_CODE -UNUSED_PARAMETER -RETURN_NOT_ALLOWED // !DIAGNOSTICS: -UNUSED_EXPRESSION -UNREACHABLE_CODE -UNUSED_PARAMETER -RETURN_NOT_ALLOWED
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>test1<!>() = run { fun <!IMPLICIT_NOTHING_RETURN_TYPE!>test1<!>() = run {
return <!TYPE_MISMATCH(String; Nothing)!>"OK"<!> return <!TYPE_MISMATCH("String", "Nothing")!>"OK"<!>
} }
fun <!IMPLICIT_NOTHING_RETURN_TYPE!>test2<!>() = run { fun <!IMPLICIT_NOTHING_RETURN_TYPE!>test2<!>() = run {
fun local(): String { fun local(): String {
return "" return ""
} }
return <!TYPE_MISMATCH(String; Nothing)!>""<!> return <!TYPE_MISMATCH("String", "Nothing")!>""<!>
} }
inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> = null!! inline fun <T, R> Iterable<T>.map(transform: (T) -> R): List<R> = null!!
fun test3(a: List<String>, b: List<Int>) = a.map { fun test3(a: List<String>, b: List<Int>) = a.map {
if (it.length == 3) return <!TYPE_MISMATCH(Nothing?; List<Int>)!>null<!> if (it.length == 3) return <!TYPE_MISMATCH("Nothing?", "List<Int>")!>null<!>
if (it.length == 4) return <!TYPE_MISMATCH(String; List<Int>)!>""<!> if (it.length == 4) return <!TYPE_MISMATCH("String", "List<Int>")!>""<!>
if (it.length == 4) return <!TYPE_MISMATCH(Int; List<Int>)!>5<!> if (it.length == 4) return <!TYPE_MISMATCH("Int", "List<Int>")!>5<!>
if (it.length == 4) return b if (it.length == 4) return b
1 1
} }
@@ -7,7 +7,7 @@ fun test() {
val x = fun <!ANONYMOUS_FUNCTION_WITH_NAME!>named1<!>(x: Int): Int { return 1 } val x = fun <!ANONYMOUS_FUNCTION_WITH_NAME!>named1<!>(x: Int): Int { return 1 }
x checkType { _<Function1<Int, Int>>() } x checkType { _<Function1<Int, Int>>() }
foo { <!EXPECTED_TYPE_MISMATCH(\(\) -> Int)!>fun named2(): Int {return 1}<!> } foo { <!EXPECTED_TYPE_MISMATCH("() -> Int")!>fun named2(): Int {return 1}<!> }
foo({ <!EXPECTED_TYPE_MISMATCH!>fun named3() = 1<!> }) foo({ <!EXPECTED_TYPE_MISMATCH!>fun named3() = 1<!> })
val x1 = val x1 =
@@ -1,3 +1,3 @@
val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING(getValue\(Nothing?, KProperty<*>\); A)!>A()<!> val a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING("getValue(Nothing?, KProperty<*>)", "A")!>A()<!>
class A class A
@@ -2,7 +2,7 @@
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
var a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING(setValue\(Nothing?, KProperty<*>, Int\); A)!>A()<!> var a: Int by <!DELEGATE_SPECIAL_FUNCTION_MISSING("setValue(Nothing?, KProperty<*>, Int)", "A")!>A()<!>
class A { class A {
operator fun getValue(t: Any?, p: KProperty<*>): Int { operator fun getValue(t: Any?, p: KProperty<*>): Int {
@@ -8,7 +8,7 @@ fun test(bal: Array<Int>) {
val <!UNUSED_VARIABLE!>c<!>: () -> <!UNRESOLVED_REFERENCE!>UNRESOLVED<!> = { bal[2] = 3 } val <!UNUSED_VARIABLE!>c<!>: () -> <!UNRESOLVED_REFERENCE!>UNRESOLVED<!> = { bal[2] = 3 }
val <!UNUSED_VARIABLE!>d<!>: () -> Int = { <!ASSIGNMENT_TYPE_MISMATCH(Int)!>bar += 4<!> } val <!UNUSED_VARIABLE!>d<!>: () -> Int = { <!ASSIGNMENT_TYPE_MISMATCH("Int")!>bar += 4<!> }
val <!UNUSED_VARIABLE!>e<!>: Unit = run { bar += 4 } val <!UNUSED_VARIABLE!>e<!>: Unit = run { bar += 4 }
@@ -11,10 +11,10 @@ class Outer<E> {
} }
class Nested { class Nested {
fun bar(x: <!OUTER_CLASS_ARGUMENTS_REQUIRED(class 'Outer')!>Inner<!>) {} fun bar(x: <!OUTER_CLASS_ARGUMENTS_REQUIRED("class 'Outer'")!>Inner<!>) {}
} }
} }
class E class E
fun bar(x: <!OUTER_CLASS_ARGUMENTS_REQUIRED(class 'Outer')!>Inner<!>) {} fun bar(x: <!OUTER_CLASS_ARGUMENTS_REQUIRED("class 'Outer'")!>Inner<!>) {}
@@ -11,13 +11,13 @@ class A<T> {
} }
class Nested { class Nested {
val x: <!OUTER_CLASS_ARGUMENTS_REQUIRED(class 'A')!>B<!><String>? = null val x: <!OUTER_CLASS_ARGUMENTS_REQUIRED("class 'A'")!>B<!><String>? = null
val y: <!OUTER_CLASS_ARGUMENTS_REQUIRED(class 'A')!>B<!><String>.C<String>? = null val y: <!OUTER_CLASS_ARGUMENTS_REQUIRED("class 'A'")!>B<!><String>.C<String>? = null
val z: <!OUTER_CLASS_ARGUMENTS_REQUIRED(class 'A')!>B<!><String>.D? = null val z: <!OUTER_CLASS_ARGUMENTS_REQUIRED("class 'A'")!>B<!><String>.D? = null
val c: <!OUTER_CLASS_ARGUMENTS_REQUIRED(class 'B')!>C<!><Int>? = null val c: <!OUTER_CLASS_ARGUMENTS_REQUIRED("class 'B'")!>C<!><Int>? = null
val d: <!OUTER_CLASS_ARGUMENTS_REQUIRED(class 'B')!>D<!>? = null val d: <!OUTER_CLASS_ARGUMENTS_REQUIRED("class 'B'")!>D<!>? = null
val innerMost: <!OUTER_CLASS_ARGUMENTS_REQUIRED(class 'B')!>Innermost<!><String>? = null val innerMost: <!OUTER_CLASS_ARGUMENTS_REQUIRED("class 'B'")!>Innermost<!><String>? = null
} }
} }
@@ -1,10 +1,10 @@
<!NOTHING_TO_INLINE!>inline<!> fun inlineFun() { <!NOTHING_TO_INLINE!>inline<!> fun inlineFun() {
<!NOT_YET_SUPPORTED_IN_INLINE(Local functions)!>fun<!> localFun() {} <!NOT_YET_SUPPORTED_IN_INLINE("Local functions")!>fun<!> localFun() {}
<!NOT_YET_SUPPORTED_IN_INLINE(Local classes)!>class<!> LocalClass {} <!NOT_YET_SUPPORTED_IN_INLINE("Local classes")!>class<!> LocalClass {}
} }
fun outerFun() { fun outerFun() {
<!NOT_YET_SUPPORTED_IN_INLINE(Local inline functions)!>inline<!> fun localInlineFun() {} <!NOT_YET_SUPPORTED_IN_INLINE("Local inline functions")!>inline<!> fun localInlineFun() {}
} }
abstract class Base { abstract class Base {
@@ -13,6 +13,6 @@ abstract class Base {
class Derived : Base() { class Derived : Base() {
<!OVERRIDE_BY_INLINE!>override final inline fun withDefault( <!OVERRIDE_BY_INLINE!>override final inline fun withDefault(
<!NOT_YET_SUPPORTED_IN_INLINE(Functional parameters with inherited default values)!>f: () -> Unit<!> <!NOT_YET_SUPPORTED_IN_INLINE("Functional parameters with inherited default values")!>f: () -> Unit<!>
)<!> {} )<!> {}
} }
@@ -1,5 +1,5 @@
class Outer { class Outer {
inner class Inner { inner class Inner {
annotation <!NESTED_CLASS_NOT_ALLOWED(Annotation class)!>class TestNestedAnnotation<!> annotation <!NESTED_CLASS_NOT_ALLOWED("Annotation class")!>class TestNestedAnnotation<!>
} }
} }
@@ -1,5 +1,5 @@
class Outer { class Outer {
inner class Inner { inner class Inner {
<!NESTED_CLASS_NOT_ALLOWED(Enum class)!>enum class TestNestedEnum<!> <!NESTED_CLASS_NOT_ALLOWED("Enum class")!>enum class TestNestedEnum<!>
} }
} }
@@ -1,5 +1,5 @@
class Outer { class Outer {
inner class Inner { inner class Inner {
<!NESTED_CLASS_NOT_ALLOWED(Interface)!>interface TestNestedInterface<!> <!NESTED_CLASS_NOT_ALLOWED("Interface")!>interface TestNestedInterface<!>
} }
} }
+3 -3
View File
@@ -1,12 +1,12 @@
// SKIP_TXT // SKIP_TXT
class Outer { class Outer {
inner class Inner1 { inner class Inner1 {
<!NESTED_CLASS_NOT_ALLOWED(Object)!>object Obj1<!> <!NESTED_CLASS_NOT_ALLOWED("Object")!>object Obj1<!>
companion <!NESTED_CLASS_NOT_ALLOWED(Companion object)!>object Obj2<!> companion <!NESTED_CLASS_NOT_ALLOWED("Companion object")!>object Obj2<!>
inner class Inner2 { inner class Inner2 {
<!NESTED_CLASS_NOT_ALLOWED(Object)!>object Obj3<!> <!NESTED_CLASS_NOT_ALLOWED("Object")!>object Obj3<!>
} }
} }
} }
+1 -1
View File
@@ -3,5 +3,5 @@ fun Any.foo1() : (i : Int) -> Unit {
} }
fun test(a : Any) { fun test(a : Any) {
a.foo1()(<!NO_VALUE_FOR_PARAMETER(i)!>)<!> a.foo1()(<!NO_VALUE_FOR_PARAMETER("i")!>)<!>
} }
@@ -61,7 +61,7 @@ enum class MyEnum {
class Outer { class Outer {
inner class Inner { inner class Inner {
<!NESTED_CLASS_NOT_ALLOWED(Object)!>object C<!> { <!NESTED_CLASS_NOT_ALLOWED("Object")!>object C<!> {
const val a = 18 const val a = 18
} }
} }
@@ -9,11 +9,11 @@ private val a = 1
package p package p
val b = <!INVISIBLE_MEMBER(a; private; file)!>a<!> // same package, same module val b = <!INVISIBLE_MEMBER("a", "private", "file")!>a<!> // same package, same module
// MODULE: m2(m1) // MODULE: m2(m1)
// FILE: c.kt // FILE: c.kt
package p package p
val c = <!INVISIBLE_MEMBER(a; private; file)!>a<!> // same package, another module val c = <!INVISIBLE_MEMBER("a", "private", "file")!>a<!> // same package, another module
@@ -30,5 +30,5 @@ val strList: List<String> = null!!
fun main() { fun main() {
val rawB = Test.rawAField.b; val rawB = Test.rawAField.b;
// Raw(A).b is not erased because it have no type parameters // Raw(A).b is not erased because it have no type parameters
var rawInner = rawB.bar(<!TYPE_MISMATCH(\(Mutable\)List<Double!>!; List<String>)!>strList<!>) var rawInner = rawB.bar(<!TYPE_MISMATCH("(Mutable)List<Double!>!", "List<String>")!>strList<!>)
} }
@@ -29,21 +29,21 @@ package a
fun test() { fun test() {
val y = makeA() val y = makeA()
y.<!INVISIBLE_MEMBER(A; private; file)!>bar<!>() y.<!INVISIBLE_MEMBER("A", "private", "file")!>bar<!>()
<!INVISIBLE_MEMBER(foo; private; file)!>foo<!>() <!INVISIBLE_MEMBER("foo", "private", "file")!>foo<!>()
val u : <!INVISIBLE_REFERENCE(A; private; file)!>A<!> = <!INVISIBLE_MEMBER(A; private; file)!>A<!>() val u : <!INVISIBLE_REFERENCE("A", "private", "file")!>A<!> = <!INVISIBLE_MEMBER("A", "private", "file")!>A<!>()
val z = <!INVISIBLE_MEMBER(x; private; file)!>x<!> val z = <!INVISIBLE_MEMBER("x", "private", "file")!>x<!>
<!INVISIBLE_MEMBER(x; private; file)!>x<!> = 30 <!INVISIBLE_MEMBER("x", "private", "file")!>x<!> = 30
val po = <!INVISIBLE_MEMBER(PO; private; file)!>PO<!> val po = <!INVISIBLE_MEMBER("PO", "private", "file")!>PO<!>
val v = xx val v = xx
<!INVISIBLE_SETTER(xx; private; file)!>xx<!> = 40 <!INVISIBLE_SETTER("xx", "private", "file")!>xx<!> = 40
} }
class B : <!EXPOSED_SUPER_CLASS!><!INVISIBLE_MEMBER(A; private; file), INVISIBLE_REFERENCE(A; private; file)!>A<!>()<!> {} class B : <!EXPOSED_SUPER_CLASS!><!INVISIBLE_MEMBER("A", "private", "file"), INVISIBLE_REFERENCE("A", "private", "file")!>A<!>()<!> {}
class Q { class Q {
class W { class W {
+1 -1
View File
@@ -6,7 +6,7 @@ class A() {
field = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>value<!> field = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>value<!>
} }
val y: Int val y: Int
get(): <!WRONG_GETTER_RETURN_TYPE(Int; String)!>String<!> = "s" get(): <!WRONG_GETTER_RETURN_TYPE("Int", "String")!>String<!> = "s"
val z: Int val z: Int
get() { get() {
return <!TYPE_MISMATCH!>"s"<!> return <!TYPE_MISMATCH!>"s"<!>
+5 -5
View File
@@ -40,8 +40,8 @@ class B {
} }
fun test3(a: A) { fun test3(a: A) {
a.<!INVISIBLE_MEMBER(v; private; 'A')!>v<!> //todo .bMethod() a.<!INVISIBLE_MEMBER("v", "private", "'A'")!>v<!> //todo .bMethod()
a.<!INVISIBLE_MEMBER(f; private; 'A')!>f<!>(0, <!TOO_MANY_ARGUMENTS!>1<!>) //todo .bMethod() a.<!INVISIBLE_MEMBER("f", "private", "'A'")!>f<!>(0, <!TOO_MANY_ARGUMENTS!>1<!>) //todo .bMethod()
} }
interface T interface T
@@ -54,7 +54,7 @@ open class C : T {
} }
fun test4(c: C) { fun test4(c: C) {
c.<!INVISIBLE_MEMBER(i; protected; 'C')!>i<!>++ c.<!INVISIBLE_MEMBER("i", "protected", "'C'")!>i<!>++
} }
class D : C() { class D : C() {
@@ -78,7 +78,7 @@ class F : C() {
class G : T { class G : T {
fun test8(c: C) { fun test8(c: C) {
doSmth(c.<!INVISIBLE_MEMBER(i; protected; 'C')!>i<!>) doSmth(c.<!INVISIBLE_MEMBER("i", "protected", "'C'")!>i<!>)
} }
} }
@@ -91,5 +91,5 @@ import test_visibility.*
fun test() { fun test() {
internal_fun() internal_fun()
<!INVISIBLE_MEMBER(private_fun; private; file)!>private_fun<!>() <!INVISIBLE_MEMBER("private_fun", "private", "file")!>private_fun<!>()
} }
+9 -9
View File
@@ -17,23 +17,23 @@ private object PO {}
//+JDK //+JDK
package b package b
import a.<!INVISIBLE_REFERENCE(A; private; file)!>A<!> import a.<!INVISIBLE_REFERENCE("A", "private", "file")!>A<!>
import a.<!INVISIBLE_REFERENCE(foo; private; file)!>foo<!> import a.<!INVISIBLE_REFERENCE("foo", "private", "file")!>foo<!>
import a.makeA import a.makeA
import a.<!INVISIBLE_REFERENCE(PO; private; file)!>PO<!> import a.<!INVISIBLE_REFERENCE("PO", "private", "file")!>PO<!>
fun test() { fun test() {
val y = makeA() val y = makeA()
y.<!INVISIBLE_MEMBER(A; private; file)!>bar<!>() y.<!INVISIBLE_MEMBER("A", "private", "file")!>bar<!>()
<!INVISIBLE_MEMBER(foo; private; file)!>foo<!>() <!INVISIBLE_MEMBER("foo", "private", "file")!>foo<!>()
val u : <!INVISIBLE_REFERENCE(A; private; file)!>A<!> = <!INVISIBLE_MEMBER(A; private; file)!>A<!>() val u : <!INVISIBLE_REFERENCE("A", "private", "file")!>A<!> = <!INVISIBLE_MEMBER("A", "private", "file")!>A<!>()
val a : java.util.Arrays.<!INVISIBLE_REFERENCE(ArrayList; private; 'Arrays')!>ArrayList<!><Int>; val a : java.util.Arrays.<!INVISIBLE_REFERENCE("ArrayList", "private", "'Arrays'")!>ArrayList<!><Int>;
val po = <!INVISIBLE_MEMBER(PO; private; file)!>PO<!> val po = <!INVISIBLE_MEMBER("PO", "private", "file")!>PO<!>
} }
class B : <!EXPOSED_SUPER_CLASS!><!INVISIBLE_MEMBER(A; private; file), INVISIBLE_REFERENCE(A; private; file)!>A<!>()<!> {} class B : <!EXPOSED_SUPER_CLASS!><!INVISIBLE_MEMBER("A", "private", "file"), INVISIBLE_REFERENCE("A", "private", "file")!>A<!>()<!> {}
class Q { class Q {
class W { class W {
+7 -7
View File
@@ -25,18 +25,18 @@ package a
fun test() { fun test() {
val y = makeA() val y = makeA()
y.<!INVISIBLE_MEMBER(A; private; file)!>bar<!>() y.<!INVISIBLE_MEMBER("A", "private", "file")!>bar<!>()
<!INVISIBLE_MEMBER(foo; private; file)!>foo<!>() <!INVISIBLE_MEMBER("foo", "private", "file")!>foo<!>()
val u : <!INVISIBLE_REFERENCE(A; private; file)!>A<!> = <!INVISIBLE_MEMBER(A; private; file)!>A<!>() val u : <!INVISIBLE_REFERENCE("A", "private", "file")!>A<!> = <!INVISIBLE_MEMBER("A", "private", "file")!>A<!>()
val z = <!INVISIBLE_MEMBER(x; private; file)!>x<!> val z = <!INVISIBLE_MEMBER("x", "private", "file")!>x<!>
<!INVISIBLE_MEMBER(x; private; file)!>x<!> = 30 <!INVISIBLE_MEMBER("x", "private", "file")!>x<!> = 30
val po = <!INVISIBLE_MEMBER(PO; private; file)!>PO<!> val po = <!INVISIBLE_MEMBER("PO", "private", "file")!>PO<!>
} }
class B : <!EXPOSED_SUPER_CLASS!><!INVISIBLE_MEMBER(A; private; file), INVISIBLE_REFERENCE(A; private; file)!>A<!>()<!> {} class B : <!EXPOSED_SUPER_CLASS!><!INVISIBLE_MEMBER("A", "private", "file"), INVISIBLE_REFERENCE("A", "private", "file")!>A<!>()<!> {}
class Q { class Q {
class W { class W {
@@ -14,14 +14,14 @@ class A0<T1, T2> {
class A1<T1, T2> : B<T1, T2> { class A1<T1, T2> : B<T1, T2> {
constructor(x: T1, y: T2): super(x, y) constructor(x: T1, y: T2): super(x, y)
constructor(x: T1, y: Int): super(x, <!TYPE_MISMATCH(T2; Int)!>y<!>) constructor(x: T1, y: Int): super(x, <!TYPE_MISMATCH("T2", "Int")!>y<!>)
constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH(T2; T1)!>y<!>) constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH("T2", "T1")!>y<!>)
} }
class A2<T1, T2> : B<T1, Int> { class A2<T1, T2> : B<T1, Int> {
constructor(x: T1, y: T2): super(x, <!TYPE_MISMATCH(Int; T2)!>y<!>) constructor(x: T1, y: T2): super(x, <!TYPE_MISMATCH("Int", "T2")!>y<!>)
constructor(x: T1, y: Int): super(x, y) constructor(x: T1, y: Int): super(x, y)
constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH(Int; T1)!>y<!>) constructor(x: T1, y: T1, z: T1): super(x, <!TYPE_MISMATCH("Int", "T1")!>y<!>)
constructor(x: T1, y: T2, z: String): super(<!TYPE_MISMATCH(T1; T2)!>y<!>, 1) constructor(x: T1, y: T2, z: String): super(<!TYPE_MISMATCH("T1", "T2")!>y<!>, 1)
} }
@@ -6,7 +6,7 @@ typealias Array2D<T> = Array<Array<T>>
fun foo1(a: Array2D<out Number>) = a fun foo1(a: Array2D<out Number>) = a
fun bar1(a: Array2D<Int>) = fun bar1(a: Array2D<Int>) =
foo1(<!TYPE_MISMATCH(Array2D<out Number> /* = Array<Array<out Number>> */; Array2D<Int> /* = Array<Array<Int>> */)!>a<!>) foo1(<!TYPE_MISMATCH("Array2D<out Number> /* = Array<Array<out Number>> */", "Array2D<Int> /* = Array<Array<Int>> */")!>a<!>)
typealias TMap<T> = Map<T, T> typealias TMap<T> = Map<T, T>
+8 -8
View File
@@ -2,22 +2,22 @@ interface In<in T>
interface Out<out T> interface Out<out T>
interface Inv<T> interface Inv<T>
interface TypeBounds1<in I, out O, P, X : <!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>I<!>> interface TypeBounds1<in I, out O, P, X : <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>I<!>>
interface TypeBounds2<in I, out O, P, X : O> interface TypeBounds2<in I, out O, P, X : O>
interface TypeBounds3<in I, out O, P, X : P> interface TypeBounds3<in I, out O, P, X : P>
interface TypeBounds4<in I, out O, P, X : In<I>> interface TypeBounds4<in I, out O, P, X : In<I>>
interface TypeBounds5<in I, out O, P, X : In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>O<!>>> interface TypeBounds5<in I, out O, P, X : In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>O<!>>>
interface WhereTypeBounds1<in I, out O, P, X> where X : <!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>I<!> interface WhereTypeBounds1<in I, out O, P, X> where X : <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>I<!>
interface WhereTypeBounds2<in I, out O, P, X> where X : O interface WhereTypeBounds2<in I, out O, P, X> where X : O
interface WhereTypeBounds3<in I, out O, P, X> where X : P interface WhereTypeBounds3<in I, out O, P, X> where X : P
interface WhereTypeBounds4<in I, out O, P, X> where X : In<I> interface WhereTypeBounds4<in I, out O, P, X> where X : In<I>
interface WhereTypeBounds5<in I, out O, P, X> where X : In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>O<!>> interface WhereTypeBounds5<in I, out O, P, X> where X : In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>O<!>>
class SubClass1<in I, out O, P> : Out<<!TYPE_VARIANCE_CONFLICT(I; in; out; Out<I>)!>I<!>> class SubClass1<in I, out O, P> : Out<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "Out<I>")!>I<!>>
class SubClass2<in I, out O, P> : Out<O> class SubClass2<in I, out O, P> : Out<O>
class SubClass3<in I, out O, P> : Out<P> class SubClass3<in I, out O, P> : Out<P>
class SubClass4<in I, out O, P> : In<I> class SubClass4<in I, out O, P> : In<I>
class SubClass5<in I, out O, P> : In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>O<!>> class SubClass5<in I, out O, P> : In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>O<!>>
class SubClass6<in I, out O, P> : Inv<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; Inv<O>)!>O<!>> class SubClass6<in I, out O, P> : Inv<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Inv<O>")!>O<!>>
class SubClass7<in I, out O, P> : Inv<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Inv<I>)!>I<!>> class SubClass7<in I, out O, P> : Inv<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Inv<I>")!>I<!>>
+10 -10
View File
@@ -4,31 +4,31 @@ interface Inv<T>
fun <T> getT(): T = null!! fun <T> getT(): T = null!!
interface Test<in I, out O, P> { interface Test<in I, out O, P> {
fun parameters1(i: I, o: <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!>, p: P) fun parameters1(i: I, o: <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!>, p: P)
fun parameters2(i: In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>>) fun parameters2(i: In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>>)
fun parameters3(i: In<O>) fun parameters3(i: In<O>)
fun explicitReturnType1() : <!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>I<!> fun explicitReturnType1() : <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>I<!>
fun explicitReturnType2() : O fun explicitReturnType2() : O
fun explicitReturnType3() : P fun explicitReturnType3() : P
fun explicitReturnType4() : In<I> fun explicitReturnType4() : In<I>
fun explicitReturnType5() : In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>O<!>> fun explicitReturnType5() : In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>O<!>>
<!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>fun imlicitReturnType1()<!> = getT<I>() <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>fun imlicitReturnType1()<!> = getT<I>()
fun imlicitReturnType2() = getT<O>() fun imlicitReturnType2() = getT<O>()
fun imlicitReturnType3() = getT<P>() fun imlicitReturnType3() = getT<P>()
fun imlicitReturnType4() = getT<In<I>>() fun imlicitReturnType4() = getT<In<I>>()
<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>fun imlicitReturnType5()<!> = getT<In<O>>() <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>fun imlicitReturnType5()<!> = getT<In<O>>()
fun I.receiver1() fun I.receiver1()
fun <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!>.receiver2() fun <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!>.receiver2()
fun P.receiver3() fun P.receiver3()
fun In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>>.receiver4() fun In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>>.receiver4()
fun In<O>.receiver5() fun In<O>.receiver5()
fun <X : I> typeParameter1() fun <X : I> typeParameter1()
fun <X : <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!>> typeParameter2() fun <X : <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!>> typeParameter2()
fun <X : P> typeParameter3() fun <X : P> typeParameter3()
fun <X : In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>>> typeParameter4() fun <X : In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>>> typeParameter4()
fun <X : In<O>> typeParameter5() fun <X : In<O>> typeParameter5()
} }
+13 -13
View File
@@ -25,22 +25,22 @@ interface Test<in I, out O, P> {
fun Ok22(i: Inv<out I>) fun Ok22(i: Inv<out I>)
fun Ok23(i: Inv<out P>) fun Ok23(i: Inv<out P>)
fun neOk1(i: <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!>) fun neOk1(i: <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!>)
fun neOk2(i: In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>>) fun neOk2(i: In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>>)
fun neOk3(i: In<In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<In<O>>)!>O<!>>>) fun neOk3(i: In<In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<In<O>>")!>O<!>>>)
fun neOk4(i: Inv<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Inv<I>)!>I<!>>) fun neOk4(i: Inv<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Inv<I>")!>I<!>>)
fun neOk5(i: Inv<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; Inv<O>)!>O<!>>) fun neOk5(i: Inv<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Inv<O>")!>O<!>>)
fun neOk6(i: In<In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<In<O>>)!>O<!>>>) fun neOk6(i: In<In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<In<O>>")!>O<!>>>)
fun neOk7(i: Pair<In<<!TYPE_VARIANCE_CONFLICT(I; in; out; Pair<In<I>, O>)!>I<!>>, <!TYPE_VARIANCE_CONFLICT(O; out; in; Pair<In<I>, O>)!>O<!>>) fun neOk7(i: Pair<In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "Pair<In<I>, O>")!>I<!>>, <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Pair<In<I>, O>")!>O<!>>)
fun neOk8(i: Inv<out <!TYPE_VARIANCE_CONFLICT(O; out; in; Inv<out O>)!>O<!>>) fun neOk8(i: Inv<out <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Inv<out O>")!>O<!>>)
fun neOk9(i: In<<!CONFLICTING_PROJECTION!>out<!> P>) fun neOk9(i: In<<!CONFLICTING_PROJECTION!>out<!> P>)
fun neOk10(i: Out<<!TYPE_VARIANCE_CONFLICT(O; out; in; Out<O>)!>O<!>>) fun neOk10(i: Out<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Out<O>")!>O<!>>)
fun neOk11(i: Inv<in <!TYPE_VARIANCE_CONFLICT(I; in; out; Inv<in I>)!>I<!>>) fun neOk11(i: Inv<in <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "Inv<in I>")!>I<!>>)
fun neOk12(i: Inv<out <!TYPE_VARIANCE_CONFLICT(O; out; in; Inv<out O>)!>O<!>>) fun neOk12(i: Inv<out <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Inv<out O>")!>O<!>>)
fun neOk30(i: Pair<<!TYPE_VARIANCE_CONFLICT(O; out; in; Pair<O, [ERROR : No type element]>)!>O<!>, <!SYNTAX!><!>>) fun neOk30(i: Pair<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Pair<O, [ERROR : No type element]>")!>O<!>, <!SYNTAX!><!>>)
fun neOk31(i: Pair<<!TYPE_VARIANCE_CONFLICT(O; out; in; Pair<O, [ERROR : Inv]>)!>O<!>, <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>>) fun neOk31(i: Pair<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Pair<O, [ERROR : Inv]>")!>O<!>, <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>>)
fun neOk32(i: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>) fun neOk32(i: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>)
fun neOk33(i: Inv<<!SYNTAX!><!>>) fun neOk33(i: Inv<<!SYNTAX!><!>>)
fun neOk34(i: Inv<<!UNRESOLVED_REFERENCE!>C<!>>) fun neOk34(i: Inv<<!UNRESOLVED_REFERENCE!>C<!>>)
@@ -12,32 +12,32 @@ interface Test<in I, out O, P> {
var ok6: Inv<in P> var ok6: Inv<in P>
var ok7: Inv<out P> var ok7: Inv<out P>
var neOk1: <!TYPE_VARIANCE_CONFLICT(O; out; invariant; O)!>O<!> var neOk1: <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "O")!>O<!>
var neOk2: In<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; In<I>)!>I<!>> var neOk2: In<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "In<I>")!>I<!>>
var neOk3: In<In<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; In<In<O>>)!>O<!>>> var neOk3: In<In<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "In<In<O>>")!>O<!>>>
var neOk4: Inv<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Inv<I>)!>I<!>> var neOk4: Inv<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Inv<I>")!>I<!>>
var neOk5: Inv<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; Inv<O>)!>O<!>> var neOk5: Inv<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Inv<O>")!>O<!>>
var neOk6: In<In<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; In<In<O>>)!>O<!>>> var neOk6: In<In<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "In<In<O>>")!>O<!>>>
var neOk7: Pair<In<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Pair<In<I>, O>)!>I<!>>, <!TYPE_VARIANCE_CONFLICT(O; out; invariant; Pair<In<I>, O>)!>O<!>> var neOk7: Pair<In<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Pair<In<I>, O>")!>I<!>>, <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Pair<In<I>, O>")!>O<!>>
var neOk8: Inv<in <!TYPE_VARIANCE_CONFLICT(O; out; invariant; Inv<in O>)!>O<!>> var neOk8: Inv<in <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Inv<in O>")!>O<!>>
var neOk9: Inv<in <!TYPE_VARIANCE_CONFLICT(I; in; invariant; Inv<in I>)!>I<!>> var neOk9: Inv<in <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Inv<in I>")!>I<!>>
var neOk10: In<<!CONFLICTING_PROJECTION!>out<!> I> var neOk10: In<<!CONFLICTING_PROJECTION!>out<!> I>
var neOk11: <!TYPE_VARIANCE_CONFLICT(I; in; invariant; I)!>I<!> var neOk11: <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "I")!>I<!>
var neOk12: In<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; In<O>)!>O<!>> var neOk12: In<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "In<O>")!>O<!>>
var neOk13: In<In<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; In<In<I>>)!>I<!>>> var neOk13: In<In<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "In<In<I>>")!>I<!>>>
var neOk14: Out<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Out<I>)!>I<!>> var neOk14: Out<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Out<I>")!>I<!>>
var neOk15: Out<Out<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Out<Out<I>>)!>I<!>>> var neOk15: Out<Out<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Out<Out<I>>")!>I<!>>>
var neOk16: Out<In<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; Out<In<O>>)!>O<!>>> var neOk16: Out<In<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Out<In<O>>")!>O<!>>>
var neOk17: Pair<In<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; Pair<In<O>, I>)!>O<!>>, <!TYPE_VARIANCE_CONFLICT(I; in; invariant; Pair<In<O>, I>)!>I<!>> var neOk17: Pair<In<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Pair<In<O>, I>")!>O<!>>, <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Pair<In<O>, I>")!>I<!>>
var neOk20: Inv<in <!TYPE_VARIANCE_CONFLICT(O; out; invariant; Inv<in O>)!>O<!>> var neOk20: Inv<in <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Inv<in O>")!>O<!>>
var neOk21: Inv<in <!TYPE_VARIANCE_CONFLICT(I; in; invariant; Inv<in I>)!>I<!>> var neOk21: Inv<in <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Inv<in I>")!>I<!>>
var neOk22: Inv<out <!TYPE_VARIANCE_CONFLICT(O; out; invariant; Inv<out O>)!>O<!>> var neOk22: Inv<out <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Inv<out O>")!>O<!>>
var neOk23: Inv<out <!TYPE_VARIANCE_CONFLICT(I; in; invariant; Inv<out I>)!>I<!>> var neOk23: Inv<out <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Inv<out I>")!>I<!>>
var neOk30: Pair<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Pair<I, [ERROR : No type element]>)!>I<!>, <!SYNTAX!><!>> var neOk30: Pair<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Pair<I, [ERROR : No type element]>")!>I<!>, <!SYNTAX!><!>>
var neOk31: Pair<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Pair<I, [ERROR : Inv]>)!>I<!>, <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>> var neOk31: Pair<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Pair<I, [ERROR : Inv]>")!>I<!>, <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>>
var neOk32: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!> var neOk32: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>
var neOk33: Inv<<!SYNTAX!><!>> var neOk33: Inv<<!SYNTAX!><!>>
var neOk34: Inv<<!UNRESOLVED_REFERENCE!>C<!>> var neOk34: Inv<<!UNRESOLVED_REFERENCE!>C<!>>
@@ -9,8 +9,8 @@ interface Test<in I : Any, out O : Any, P : Any> {
fun ok2(i: In<O?>?) : Out<O?>? fun ok2(i: In<O?>?) : Out<O?>?
fun ok3(i: Inv<in O?>) = getT<Inv<in I?>>() fun ok3(i: Inv<in O?>) = getT<Inv<in I?>>()
fun neOk1(i: <!TYPE_VARIANCE_CONFLICT(O; out; in; O?)!>O?<!>) : <!TYPE_VARIANCE_CONFLICT(I; in; out; I?)!>I?<!> fun neOk1(i: <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O?")!>O?<!>) : <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I?")!>I?<!>
fun neOk(i: Out<<!TYPE_VARIANCE_CONFLICT(O; out; in; Out<O?>?)!>O?<!>>?) : In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O?>?)!>O?<!>>? fun neOk(i: Out<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Out<O?>?")!>O?<!>>?) : In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O?>?")!>O?<!>>?
fun neOk3(i: Inv<in <!TYPE_VARIANCE_CONFLICT(I; in; out; Inv<in I?>)!>I?<!>>) fun neOk3(i: Inv<in <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "Inv<in I?>")!>I?<!>>)
<!TYPE_VARIANCE_CONFLICT(O; out; in; Inv<in O?>?)!>fun neOk4()<!> = getT<Inv<in O?>?>() <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Inv<in O?>?")!>fun neOk4()<!> = getT<Inv<in O?>?>()
} }
+12 -12
View File
@@ -19,20 +19,20 @@ interface Test<in I, out O, P> {
fun ok12(): Inv<in P> fun ok12(): Inv<in P>
fun ok13(): Inv<out P> fun ok13(): Inv<out P>
fun neOk1(): <!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>I<!> fun neOk1(): <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>I<!>
fun neOk2(): In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>O<!>> fun neOk2(): In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>O<!>>
fun neOk3(): In<In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<In<I>>)!>I<!>>> fun neOk3(): In<In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<In<I>>")!>I<!>>>
fun neOk4(): Inv<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; Inv<I>)!>I<!>> fun neOk4(): Inv<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "Inv<I>")!>I<!>>
fun neOk5(): Inv<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; Inv<O>)!>O<!>> fun neOk5(): Inv<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "Inv<O>")!>O<!>>
fun neOk6(): Pair<In<<!TYPE_VARIANCE_CONFLICT(O; out; in; Pair<In<O>, I>)!>O<!>>, <!TYPE_VARIANCE_CONFLICT(I; in; out; Pair<In<O>, I>)!>I<!>> fun neOk6(): Pair<In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Pair<In<O>, I>")!>O<!>>, <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "Pair<In<O>, I>")!>I<!>>
fun neOk7(): Inv<in <!TYPE_VARIANCE_CONFLICT(O; out; in; Inv<in O>)!>O<!>> fun neOk7(): Inv<in <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Inv<in O>")!>O<!>>
fun neOk8(): Out<<!CONFLICTING_PROJECTION(Out)!>in<!> I> fun neOk8(): Out<<!CONFLICTING_PROJECTION("Out")!>in<!> I>
fun neOk10(): Inv<in <!TYPE_VARIANCE_CONFLICT(O; out; in; Inv<in O>)!>O<!>> fun neOk10(): Inv<in <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "Inv<in O>")!>O<!>>
fun neOk11(): Inv<out <!TYPE_VARIANCE_CONFLICT(I; in; out; Inv<out I>)!>I<!>> fun neOk11(): Inv<out <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "Inv<out I>")!>I<!>>
fun neOk30(): Pair<<!TYPE_VARIANCE_CONFLICT(I; in; out; Pair<I, [ERROR : No type element]>)!>I<!>, <!SYNTAX!><!>> fun neOk30(): Pair<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "Pair<I, [ERROR : No type element]>")!>I<!>, <!SYNTAX!><!>>
fun neOk31(): Pair<<!TYPE_VARIANCE_CONFLICT(I; in; out; Pair<I, [ERROR : Inv]>)!>I<!>, <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>> fun neOk31(): Pair<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "Pair<I, [ERROR : Inv]>")!>I<!>, <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>>
fun neOk32(): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!> fun neOk32(): <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Inv<!>
fun neOk33(): Inv<<!SYNTAX!><!>> fun neOk33(): Inv<<!SYNTAX!><!>>
fun neOk34(): Inv<<!UNRESOLVED_REFERENCE!>C<!>> fun neOk34(): Inv<<!UNRESOLVED_REFERENCE!>C<!>>
@@ -5,17 +5,17 @@ interface Inv<T>
fun <T> getT(): T = null!! fun <T> getT(): T = null!!
class Test<in I, out O, P>( class Test<in I, out O, P>(
val type1: <!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>I<!>, val type1: <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>I<!>,
val type2: O, val type2: O,
val type3: P, val type3: P,
val type4: In<I>, val type4: In<I>,
val type5: In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>O<!>>, val type5: In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>O<!>>,
var type6: <!TYPE_VARIANCE_CONFLICT(I; in; invariant; I)!>I<!>, var type6: <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "I")!>I<!>,
var type7: <!TYPE_VARIANCE_CONFLICT(O; out; invariant; O)!>O<!>, var type7: <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "O")!>O<!>,
var type8: P, var type8: P,
var type9: In<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; In<I>)!>I<!>>, var type9: In<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "In<I>")!>I<!>>,
var type0: In<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; In<O>)!>O<!>>, var type0: In<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "In<O>")!>O<!>>,
<!UNUSED_PARAMETER!>type11<!>: I, <!UNUSED_PARAMETER!>type11<!>: I,
<!UNUSED_PARAMETER!>type12<!>: O, <!UNUSED_PARAMETER!>type12<!>: O,
+12 -12
View File
@@ -12,39 +12,39 @@ class Delegate<T> {
fun <T> getT(): T = null!! fun <T> getT(): T = null!!
abstract class Test<in I, out O, P> { abstract class Test<in I, out O, P> {
abstract val type1: <!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>I<!> abstract val type1: <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>I<!>
abstract val type2: O abstract val type2: O
abstract val type3: P abstract val type3: P
abstract val type4: In<I> abstract val type4: In<I>
abstract val type5: In<<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>O<!>> abstract val type5: In<<!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>O<!>>
<!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>val implicitType1<!> = getT<I>() <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>val implicitType1<!> = getT<I>()
val implicitType2 = getT<O>() val implicitType2 = getT<O>()
val implicitType3 = getT<P>() val implicitType3 = getT<P>()
val implicitType4 = getT<In<I>>() val implicitType4 = getT<In<I>>()
<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>val implicitType5<!> = getT<In<O>>() <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>val implicitType5<!> = getT<In<O>>()
<!TYPE_VARIANCE_CONFLICT(I; in; out; I)!>val delegateType1<!> by Delegate<I>() <!TYPE_VARIANCE_CONFLICT("I", "in", "out", "I")!>val delegateType1<!> by Delegate<I>()
val delegateType2 by Delegate<O>() val delegateType2 by Delegate<O>()
val delegateType3 by Delegate<P>() val delegateType3 by Delegate<P>()
val delegateType4 by Delegate<In<I>>() val delegateType4 by Delegate<In<I>>()
<!TYPE_VARIANCE_CONFLICT(O; out; in; In<O>)!>val delegateType5<!> by Delegate<In<O>>() <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "In<O>")!>val delegateType5<!> by Delegate<In<O>>()
abstract val I.receiver1: Int abstract val I.receiver1: Int
abstract val <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!>.receiver2: Int abstract val <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!>.receiver2: Int
abstract val P.receiver3: Int abstract val P.receiver3: Int
abstract val In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>>.receiver4: Int abstract val In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>>.receiver4: Int
abstract val In<O>.receiver5: Int abstract val In<O>.receiver5: Int
val <X : I> X.typeParameter1: Int get() = 0 val <X : I> X.typeParameter1: Int get() = 0
val <X : <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!>> X.typeParameter2: Int get() = 0 val <X : <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!>> X.typeParameter2: Int get() = 0
val <X : P> X.typeParameter3: Int get() = 0 val <X : P> X.typeParameter3: Int get() = 0
val <X : In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>>> X.typeParameter4: Int get() = 0 val <X : In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>>> X.typeParameter4: Int get() = 0
val <X : In<O>> X.typeParameter5: Int get() = 0 val <X : In<O>> X.typeParameter5: Int get() = 0
val <X> X.typeParameter6: Int where X : I get() = 0 val <X> X.typeParameter6: Int where X : I get() = 0
val <X> X.typeParameter7: Int where X : <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!> get() = 0 val <X> X.typeParameter7: Int where X : <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!> get() = 0
val <X> X.typeParameter8: Int where X : P get() = 0 val <X> X.typeParameter8: Int where X : P get() = 0
val <X> X.typeParameter9: Int where X : In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>> get() = 0 val <X> X.typeParameter9: Int where X : In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>> get() = 0
val <X> X.typeParameter0: Int where X : In<O> get() = 0 val <X> X.typeParameter0: Int where X : In<O> get() = 0
} }
+18 -18
View File
@@ -12,39 +12,39 @@ class Delegate<T> {
fun <T> getT(): T = null!! fun <T> getT(): T = null!!
abstract class Test<in I, out O, P> { abstract class Test<in I, out O, P> {
abstract var type1: <!TYPE_VARIANCE_CONFLICT(I; in; invariant; I)!>I<!> abstract var type1: <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "I")!>I<!>
abstract var type2: <!TYPE_VARIANCE_CONFLICT(O; out; invariant; O)!>O<!> abstract var type2: <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "O")!>O<!>
abstract var type3: P abstract var type3: P
abstract var type4: In<<!TYPE_VARIANCE_CONFLICT(I; in; invariant; In<I>)!>I<!>> abstract var type4: In<<!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "In<I>")!>I<!>>
abstract var type5: In<<!TYPE_VARIANCE_CONFLICT(O; out; invariant; In<O>)!>O<!>> abstract var type5: In<<!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "In<O>")!>O<!>>
<!TYPE_VARIANCE_CONFLICT(I; in; invariant; I)!>var implicitType1<!> = getT<I>() <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "I")!>var implicitType1<!> = getT<I>()
<!TYPE_VARIANCE_CONFLICT(O; out; invariant; O)!>var implicitType2<!> = getT<O>() <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "O")!>var implicitType2<!> = getT<O>()
var implicitType3 = getT<P>() var implicitType3 = getT<P>()
<!TYPE_VARIANCE_CONFLICT(I; in; invariant; In<I>)!>var implicitType4<!> = getT<In<I>>() <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "In<I>")!>var implicitType4<!> = getT<In<I>>()
<!TYPE_VARIANCE_CONFLICT(O; out; invariant; In<O>)!>var implicitType5<!> = getT<In<O>>() <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "In<O>")!>var implicitType5<!> = getT<In<O>>()
<!TYPE_VARIANCE_CONFLICT(I; in; invariant; I)!>var delegateType1<!> by Delegate<I>() <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "I")!>var delegateType1<!> by Delegate<I>()
<!TYPE_VARIANCE_CONFLICT(O; out; invariant; O)!>var delegateType2<!> by Delegate<O>() <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "O")!>var delegateType2<!> by Delegate<O>()
var delegateType3 by Delegate<P>() var delegateType3 by Delegate<P>()
<!TYPE_VARIANCE_CONFLICT(I; in; invariant; In<I>)!>var delegateType4<!> by Delegate<In<I>>() <!TYPE_VARIANCE_CONFLICT("I", "in", "invariant", "In<I>")!>var delegateType4<!> by Delegate<In<I>>()
<!TYPE_VARIANCE_CONFLICT(O; out; invariant; In<O>)!>var delegateType5<!> by Delegate<In<O>>() <!TYPE_VARIANCE_CONFLICT("O", "out", "invariant", "In<O>")!>var delegateType5<!> by Delegate<In<O>>()
abstract var I.receiver1: Int abstract var I.receiver1: Int
abstract var <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!>.receiver2: Int abstract var <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!>.receiver2: Int
abstract var P.receiver3: Int abstract var P.receiver3: Int
abstract var In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>>.receiver4: Int abstract var In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>>.receiver4: Int
abstract var In<O>.receiver5: Int abstract var In<O>.receiver5: Int
var <X : I> X.typeParameter1: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X : I> X.typeParameter1: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X : <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!>> X.typeParameter2: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X : <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!>> X.typeParameter2: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X : P> X.typeParameter3: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X : P> X.typeParameter3: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X : In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>>> X.typeParameter4: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X : In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>>> X.typeParameter4: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X : In<O>> X.typeParameter5: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X : In<O>> X.typeParameter5: Int get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X> X.typeParameter6: Int where X : I get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X> X.typeParameter6: Int where X : I get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X> X.typeParameter7: Int where X : <!TYPE_VARIANCE_CONFLICT(O; out; in; O)!>O<!> get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X> X.typeParameter7: Int where X : <!TYPE_VARIANCE_CONFLICT("O", "out", "in", "O")!>O<!> get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X> X.typeParameter8: Int where X : P get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X> X.typeParameter8: Int where X : P get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X> X.typeParameter9: Int where X : In<<!TYPE_VARIANCE_CONFLICT(I; in; out; In<I>)!>I<!>> get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X> X.typeParameter9: Int where X : In<<!TYPE_VARIANCE_CONFLICT("I", "in", "out", "In<I>")!>I<!>> get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
var <X> X.typeParameter0: Int where X : In<O> get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {} var <X> X.typeParameter0: Int where X : In<O> get() = 0; set(<!UNUSED_PARAMETER!>i<!>) {}
} }
@@ -15,23 +15,23 @@ class Test<in I> {
apply(this.foo()) apply(this.foo())
with(Test<I>()) { with(Test<I>()) {
apply(foo()) // resolved to this@Test.foo apply(foo()) // resolved to this@Test.foo
apply(this.<!INVISIBLE_MEMBER(foo; private/*private to this*/; 'Test')!>foo<!>()) apply(this.<!INVISIBLE_MEMBER("foo", "private/*private to this*/", "'Test'")!>foo<!>())
apply(this@with.<!INVISIBLE_MEMBER(foo; private/*private to this*/; 'Test')!>foo<!>()) apply(this@with.<!INVISIBLE_MEMBER("foo", "private/*private to this*/", "'Test'")!>foo<!>())
apply(this@Test.foo()) apply(this@Test.foo())
} }
} }
fun <I> test(t: Test<I>) { fun <I> test(t: Test<I>) {
t.apply(t.<!INVISIBLE_MEMBER(foo; private/*private to this*/; 'Test')!>foo<!>()) t.apply(t.<!INVISIBLE_MEMBER("foo", "private/*private to this*/", "'Test'")!>foo<!>())
} }
companion object { companion object {
fun <I> test(t: Test<I>) { fun <I> test(t: Test<I>) {
t.apply(t.<!INVISIBLE_MEMBER(foo; private/*private to this*/; 'Test')!>foo<!>()) t.apply(t.<!INVISIBLE_MEMBER("foo", "private/*private to this*/", "'Test'")!>foo<!>())
} }
} }
} }
fun <I> test(t: Test<I>) { fun <I> test(t: Test<I>) {
t.apply(t.<!INVISIBLE_MEMBER(foo; private/*private to this*/; 'Test')!>foo<!>()) t.apply(t.<!INVISIBLE_MEMBER("foo", "private/*private to this*/", "'Test'")!>foo<!>())
} }
@@ -15,23 +15,23 @@ class Test<in I, out O> {
apply(this.i) apply(this.i)
with(Test<I, O>()) { with(Test<I, O>()) {
apply(i) // resolved to this@Test.i apply(i) // resolved to this@Test.i
apply(this.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!>) apply(this.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!>)
apply(this@with.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!>) apply(this@with.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!>)
apply(this@Test.i) apply(this@Test.i)
} }
} }
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
t.apply(t.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!>) t.apply(t.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!>)
} }
companion object { companion object {
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
t.apply(t.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!>) t.apply(t.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!>)
} }
} }
} }
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
t.apply(t.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!>) t.apply(t.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!>)
} }
@@ -15,23 +15,23 @@ class Test<in I, out O> {
this.i = getT() this.i = getT()
with(Test<I, O>()) { with(Test<I, O>()) {
i = getT() // resolved to this@Test.i i = getT() // resolved to this@Test.i
this.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!> = getT() this.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!> = getT()
this@with.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!> = getT() this@with.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!> = getT()
this@Test.i = getT() this@Test.i = getT()
} }
} }
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
t.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!> = getT() t.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!> = getT()
} }
companion object { companion object {
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
t.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!> = getT() t.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!> = getT()
} }
} }
} }
fun <I, O> test(t: Test<I, O>) { fun <I, O> test(t: Test<I, O>) {
t.<!INVISIBLE_MEMBER(i; private/*private to this*/; 'Test')!>i<!> = getT() t.<!INVISIBLE_MEMBER("i", "private/*private to this*/", "'Test'")!>i<!> = getT()
} }
@@ -6,6 +6,6 @@ public @interface A {
} }
// FILE: b.kt // FILE: b.kt
@A(*<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf(<!NI;CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, "b")<!>) @A(*<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH("Array<out String>", "IGNORE")!>arrayOf(1, "b")<!>)
fun test() { fun test() {
} }
@@ -2,6 +2,6 @@
annotation class B(vararg val args: String) annotation class B(vararg val args: String)
@B(*<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf(<!NI;CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, "b")<!>) @B(*<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH("Array<out String>", "IGNORE")!>arrayOf(1, "b")<!>)
fun test() { fun test() {
} }
@@ -7,7 +7,7 @@ import kotlin.contracts.*
fun foo(b: Boolean): Boolean { fun foo(b: Boolean): Boolean {
contract { contract {
// pointless, can be reduced to just "b" // pointless, can be reduced to just "b"
returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION(only equality comparisons with 'null' allowed)!>b == true<!>) returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION("only equality comparisons with 'null' allowed")!>b == true<!>)
} }
return b return b
@@ -16,7 +16,7 @@ fun foo(b: Boolean): Boolean {
fun bar(b: Boolean?): Boolean { fun bar(b: Boolean?): Boolean {
contract { contract {
// not pointless, but not supported yet // not pointless, but not supported yet
returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION(only equality comparisons with 'null' allowed)!>b == true<!>) returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION("only equality comparisons with 'null' allowed")!>b == true<!>)
} }
if (b == null) throw java.lang.IllegalArgumentException("") if (b == null) throw java.lang.IllegalArgumentException("")
return <!DEBUG_INFO_SMARTCAST!>b<!> return <!DEBUG_INFO_SMARTCAST!>b<!>
@@ -8,7 +8,7 @@ fun bar(x: Int): Boolean = x == 0
fun foo(x: Int): Boolean { fun foo(x: Int): Boolean {
contract { contract {
returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION(call-expressions are not supported yet)!>bar(x)<!>) returns(true) implies (<!ERROR_IN_CONTRACT_DESCRIPTION("call-expressions are not supported yet")!>bar(x)<!>)
} }
return x == 0 return x == 0
} }
@@ -5,5 +5,5 @@
import kotlin.contracts.* import kotlin.contracts.*
fun emptyContract() { fun emptyContract() {
<!ERROR_IN_CONTRACT_DESCRIPTION(Error in contract description)!>contract<!> { } <!ERROR_IN_CONTRACT_DESCRIPTION("Error in contract description")!>contract<!> { }
} }
@@ -6,7 +6,7 @@ import kotlin.contracts.*
fun ifInContract(x: Any?, boolean: Boolean) { fun ifInContract(x: Any?, boolean: Boolean) {
contract { contract {
<!ERROR_IN_CONTRACT_DESCRIPTION(unexpected construction in contract description)!>if (boolean) { <!ERROR_IN_CONTRACT_DESCRIPTION("unexpected construction in contract description")!>if (boolean) {
returns() implies (x is String) returns() implies (x is String)
} else { } else {
returns() implies (x is Int) returns() implies (x is Int)
@@ -16,7 +16,7 @@ fun ifInContract(x: Any?, boolean: Boolean) {
fun whenInContract(x: Any?, boolean: Boolean) { fun whenInContract(x: Any?, boolean: Boolean) {
contract { contract {
<!ERROR_IN_CONTRACT_DESCRIPTION(unexpected construction in contract description)!>when (boolean) { <!ERROR_IN_CONTRACT_DESCRIPTION("unexpected construction in contract description")!>when (boolean) {
true -> returns() implies (x is String) true -> returns() implies (x is String)
else -> returns() implies (x is Int) else -> returns() implies (x is Int)
}<!> }<!>
@@ -25,7 +25,7 @@ fun whenInContract(x: Any?, boolean: Boolean) {
fun forInContract(x: Any?) { fun forInContract(x: Any?) {
contract { contract {
<!ERROR_IN_CONTRACT_DESCRIPTION(unexpected construction in contract description)!>for (i in 0..1) { <!ERROR_IN_CONTRACT_DESCRIPTION("unexpected construction in contract description")!>for (i in 0..1) {
returns() implies (x is String) returns() implies (x is String)
}<!> }<!>
} }
@@ -33,7 +33,7 @@ fun forInContract(x: Any?) {
fun whileInContract(x: Any?) { fun whileInContract(x: Any?) {
contract { contract {
<!ERROR_IN_CONTRACT_DESCRIPTION(unexpected construction in contract description)!>while (false) { <!ERROR_IN_CONTRACT_DESCRIPTION("unexpected construction in contract description")!>while (false) {
returns() implies (x is String) returns() implies (x is String)
}<!> }<!>
} }
@@ -41,7 +41,7 @@ fun whileInContract(x: Any?) {
fun doWhileInContract(x: Any?) { fun doWhileInContract(x: Any?) {
contract { contract {
<!ERROR_IN_CONTRACT_DESCRIPTION(unexpected construction in contract description)!>do { <!ERROR_IN_CONTRACT_DESCRIPTION("unexpected construction in contract description")!>do {
returns() implies (x is String) returns() implies (x is String)
} while (false)<!> } while (false)<!>
} }
@@ -49,7 +49,7 @@ fun doWhileInContract(x: Any?) {
fun localValInContract(x: Any?) { fun localValInContract(x: Any?) {
contract { contract {
<!ERROR_IN_CONTRACT_DESCRIPTION(unexpected construction in contract description)!>val y: Int = 42<!> <!ERROR_IN_CONTRACT_DESCRIPTION("unexpected construction in contract description")!>val y: Int = 42<!>
returns() implies (x is String) returns() implies (x is String)
} }
} }
@@ -6,25 +6,25 @@ import kotlin.contracts.*
fun equalsWithVariables(x: Any?, y: Any?) { fun equalsWithVariables(x: Any?, y: Any?) {
contract { contract {
returns() implies (<!ERROR_IN_CONTRACT_DESCRIPTION(only equality comparisons with 'null' allowed)!>x == y<!>) returns() implies (<!ERROR_IN_CONTRACT_DESCRIPTION("only equality comparisons with 'null' allowed")!>x == y<!>)
} }
} }
fun identityEqualsWithVariables(x: Any?, y: Any?) { fun identityEqualsWithVariables(x: Any?, y: Any?) {
contract { contract {
returns() implies (<!ERROR_IN_CONTRACT_DESCRIPTION(only equality comparisons with 'null' allowed)!>x === y<!>) returns() implies (<!ERROR_IN_CONTRACT_DESCRIPTION("only equality comparisons with 'null' allowed")!>x === y<!>)
} }
} }
fun equalConstants() { fun equalConstants() {
contract { contract {
returns() implies (<!SENSELESS_COMPARISON, ERROR_IN_CONTRACT_DESCRIPTION(only equality comparisons with 'null' allowed)!>null == null<!>) returns() implies (<!ERROR_IN_CONTRACT_DESCRIPTION("only equality comparisons with 'null' allowed"), SENSELESS_COMPARISON!>null == null<!>)
} }
} }
fun get(): Int? = null fun get(): Int? = null
fun equalNullWithCall() { fun equalNullWithCall() {
contract { contract {
returns() implies (<!ERROR_IN_CONTRACT_DESCRIPTION(only references to parameters are allowed in contract description)!>get()<!> == null) returns() implies (<!ERROR_IN_CONTRACT_DESCRIPTION("only references to parameters are allowed in contract description")!>get()<!> == null)
} }
} }
@@ -5,7 +5,7 @@
import kotlin.contracts.* import kotlin.contracts.*
fun foo(boolean: Boolean) { fun foo(boolean: Boolean) {
<!ERROR_IN_CONTRACT_DESCRIPTION(Error in contract description)!>contract<!> { <!ERROR_IN_CONTRACT_DESCRIPTION("Error in contract description")!>contract<!> {
(returns() implies (boolean)) <!UNRESOLVED_REFERENCE!>implies<!> (!boolean) (returns() implies (boolean)) <!UNRESOLVED_REFERENCE!>implies<!> (!boolean)
} }
} }
@@ -5,11 +5,11 @@
import kotlin.contracts.* import kotlin.contracts.*
fun passLambdaValue(l: ContractBuilder.() -> Unit) { fun passLambdaValue(l: ContractBuilder.() -> Unit) {
contract(<!ERROR_IN_CONTRACT_DESCRIPTION(first argument of 'contract'-call should be a lambda expression)!>l<!>) contract(<!ERROR_IN_CONTRACT_DESCRIPTION("first argument of 'contract'-call should be a lambda expression")!>l<!>)
} }
fun passAnonymousFunction(x: Boolean) { fun passAnonymousFunction(x: Boolean) {
contract(<!ERROR_IN_CONTRACT_DESCRIPTION(first argument of 'contract'-call should be a lambda expression)!>fun ContractBuilder.() { contract(<!ERROR_IN_CONTRACT_DESCRIPTION("first argument of 'contract'-call should be a lambda expression")!>fun ContractBuilder.() {
returns() implies x returns() implies x
}<!>) }<!>)
} }
@@ -6,7 +6,7 @@ import kotlin.contracts.*
fun foo(y: Boolean) { fun foo(y: Boolean) {
val <!UNUSED_VARIABLE!>x<!>: Int = 42 val <!UNUSED_VARIABLE!>x<!>: Int = 42
<!CONTRACT_NOT_ALLOWED(Contract should be the first statement)!>contract<!> { <!CONTRACT_NOT_ALLOWED("Contract should be the first statement")!>contract<!> {
returns() implies y returns() implies y
} }
} }
@@ -6,20 +6,20 @@ import kotlin.contracts.*
inline fun <reified T> referToReifiedGeneric(x: Any?) { inline fun <reified T> referToReifiedGeneric(x: Any?) {
contract { contract {
returns() implies (x is <!ERROR_IN_CONTRACT_DESCRIPTION(references to type parameters are forbidden in contracts)!>T<!>) returns() implies (x is <!ERROR_IN_CONTRACT_DESCRIPTION("references to type parameters are forbidden in contracts")!>T<!>)
} }
} }
class Generic<T> { class Generic<T> {
fun referToCaptured(x: Any?) { fun referToCaptured(x: Any?) {
<!CONTRACT_NOT_ALLOWED(Contracts are allowed only for top-level functions)!>contract<!> { <!CONTRACT_NOT_ALLOWED("Contracts are allowed only for top-level functions")!>contract<!> {
returns() implies (x is <!CANNOT_CHECK_FOR_ERASED!>T<!>) returns() implies (x is <!CANNOT_CHECK_FOR_ERASED!>T<!>)
} }
} }
} }
fun referToSubstituted(x: Any?) { fun referToSubstituted(x: Any?) {
<!ERROR_IN_CONTRACT_DESCRIPTION(Error in contract description)!>contract<!> { <!ERROR_IN_CONTRACT_DESCRIPTION("Error in contract description")!>contract<!> {
returns() implies (x is <!CANNOT_CHECK_FOR_ERASED!>Generic<String><!>) returns() implies (x is <!CANNOT_CHECK_FOR_ERASED!>Generic<String><!>)
} }
} }
@@ -35,13 +35,13 @@ typealias FunctionalType = () -> Unit
typealias SimpleType = Int typealias SimpleType = Int
fun referToAliasedGeneric(x: Any?) { fun referToAliasedGeneric(x: Any?) {
<!ERROR_IN_CONTRACT_DESCRIPTION(Error in contract description)!>contract<!> { <!ERROR_IN_CONTRACT_DESCRIPTION("Error in contract description")!>contract<!> {
returns() implies (x is <!CANNOT_CHECK_FOR_ERASED!>GenericString<!>) returns() implies (x is <!CANNOT_CHECK_FOR_ERASED!>GenericString<!>)
} }
} }
fun referToAliasedFunctionType(x: Any?) { fun referToAliasedFunctionType(x: Any?) {
<!ERROR_IN_CONTRACT_DESCRIPTION(Error in contract description)!>contract<!> { <!ERROR_IN_CONTRACT_DESCRIPTION("Error in contract description")!>contract<!> {
returns() implies (x is <!CANNOT_CHECK_FOR_ERASED!>FunctionalType<!>) returns() implies (x is <!CANNOT_CHECK_FOR_ERASED!>FunctionalType<!>)
} }
} }
@@ -6,7 +6,7 @@ import kotlin.contracts.*
fun Any?.foo(): Boolean { fun Any?.foo(): Boolean {
contract { contract {
returns(true) implies (<!SENSELESS_COMPARISON!><!ERROR_IN_CONTRACT_DESCRIPTION(only references to parameters are allowed. Did you miss label on <this>?)!>this<!> != null<!>) returns(true) implies (<!SENSELESS_COMPARISON!><!ERROR_IN_CONTRACT_DESCRIPTION("only references to parameters are allowed. Did you miss label on <this>?")!>this<!> != null<!>)
} }
return this != null return this != null
} }
@@ -9,8 +9,8 @@ public class A {
// FILE: main.kt // FILE: main.kt
class <!UNSUPPORTED(Inheritance of a Java member referencing 'kotlin.jvm.functions.FunctionN': fun foo\(w: FunctionN<*>!\): Unit defined in A)!>B<!> : A() class <!UNSUPPORTED("Inheritance of a Java member referencing 'kotlin.jvm.functions.FunctionN': fun foo(w: FunctionN<*>!): Unit defined in A")!>B<!> : A()
fun foo() { fun foo() {
<!UNSUPPORTED(Inheritance of a Java member referencing 'kotlin.jvm.functions.FunctionN': fun foo\(w: FunctionN<*>!\): Unit defined in A)!>object<!> : A() {} <!UNSUPPORTED("Inheritance of a Java member referencing 'kotlin.jvm.functions.FunctionN': fun foo(w: FunctionN<*>!): Unit defined in A")!>object<!> : A() {}
} }
@@ -27,8 +27,8 @@ public class A<T> {
fun main(a: A<String>, a1: A<String?>) { fun main(a: A<String>, a1: A<String?>) {
a.foo("", null)?.length a.foo("", null)?.length
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS(String?)!>a.foo("", null)<!>.length <!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS("String?")!>a.foo("", null)<!>.length
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS(String; Nothing?)!>null<!>, "")<!>.length <!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>a.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS("String", "Nothing?")!>null<!>, "")<!>.length
a.bar().length a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
@@ -69,7 +69,7 @@ public class A {
fun main(a: A) { fun main(a: A) {
a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length a.foo("", null)<!UNNECESSARY_SAFE_CALL!>?.<!>length
a.foo("", null).length a.foo("", null).length
a.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS(String; Nothing?)!>null<!>, "").length a.foo(<!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS("String", "Nothing?")!>null<!>, "").length
a.bar().length a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
@@ -77,7 +77,7 @@ fun main(a: A) {
a.field?.length a.field?.length
a.field.length a.field.length
<!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS(MutableList<String!>?)!>a.baz()<!>.get(0) <!RECEIVER_NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS("MutableList<String!>?")!>a.baz()<!>.get(0)
a.baz()!!.get(0).get(0) a.baz()!!.get(0).get(0)
a.baz()!!.get(0)?.get(0) a.baz()!!.get(0)?.get(0)
} }