FIR: Fix scope intersection types

Otherwise overload resolution ambiguity is reported in the test
This commit is contained in:
Denis Zharkov
2020-01-29 17:35:47 +03:00
parent d28e1f156a
commit 47ecaa5b06
24 changed files with 114 additions and 61 deletions
@@ -8,6 +8,6 @@ interface B {
fun test(c: Any) {
if (c is B && c is A) {
c.<!AMBIGUITY!>foo<!><String, Int>()
c.foo<String, Int>()
}
}
@@ -10,6 +10,6 @@ interface B {
fun test(c: Any) {
if (c is B && c is A) {
c.<!AMBIGUITY!>foo<!>()
c.foo()
}
}
@@ -17,37 +17,37 @@ interface C {
fun foo(x: Any?) {
if (x is A && x is B) {
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
x.foo().checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
x.foo().checkType { _<String?>() }
}
if (x is B && x is A) {
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
x.foo().checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
x.foo().checkType { _<String?>() }
}
if (x is A && x is C) {
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
x.foo().checkType { _<String>() }
x.foo().checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String?>() }
}
if (x is C && x is A) {
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
x.foo().checkType { _<String>() }
x.foo().checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String?>() }
}
if (x is A && x is B && x is C) {
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
x.foo().checkType { _<String>() }
x.foo().checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String?>() }
}
if (x is B && x is A && x is C) {
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
x.foo().checkType { _<String>() }
x.foo().checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String?>() }
}
if (x is B && x is C && x is A) {
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String?>() }
x.foo().checkType { _<String>() }
x.foo().checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String?>() }
}
}
@@ -14,6 +14,6 @@ interface B : Common {
fun test(c: Common) {
if (c is B && c is A) {
c.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
c.foo().checkType { _<String>() }
}
}
@@ -10,6 +10,6 @@ interface B {
fun test(c: Any) {
if (c is B && c is A) {
c.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
c.foo().checkType { _<String>() }
}
}
@@ -13,9 +13,9 @@ interface B: A {
fun test(a: A) {
if (a is B && a is C) {
a.<!AMBIGUITY!>foo<!> = ""
a.<!AMBIGUITY!>foo<!> = null
a.foo = ""
a.foo = null
a.<!AMBIGUITY!>foo<!>.<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
a.foo.checkType { _<String>() }
}
}
@@ -13,8 +13,8 @@ interface B: A {
fun test(a: A) {
if (a is B && a is C) {
a.<!AMBIGUITY!>foo<!> = ""
a.<!AMBIGUITY!>foo<!> = null
a.<!AMBIGUITY!>foo<!>
a.foo = ""
a.foo = null
a.foo
}
}
@@ -28,11 +28,11 @@ fun test() {
x.foo().checkType { _<CharSequence?>() }
if (x is B && x is C) {
x.<!AMBIGUITY!>foo<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><CharSequence?>() }
x.foo().checkType { <!INAPPLICABLE_CANDIDATE!>_<!><CharSequence?>() }
x.baz("")
x.<!AMBIGUITY!>baz<!>(1).<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Unit>() }
x.<!AMBIGUITY!>baz<!>(1, 2)
x.baz(1).checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Unit>() }
x.baz(1, 2)
x.<!AMBIGUITY!>foobar<!>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
x.foobar().checkType { _<String>() }
}
}
@@ -10,6 +10,6 @@ interface B {
fun test(c: Any) {
if (c is B && c is A) {
c.<!AMBIGUITY!>foo<!><String, Int>().<!INAPPLICABLE_CANDIDATE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
c.foo<String, Int>().checkType { _<Int>() }
}
}