[FIR] Handle fully qualified expressions separately in tower resolver

This commit is contained in:
Mikhail Glukhikh
2020-01-10 17:11:43 +03:00
parent 587430ff90
commit 5c6341b4e4
36 changed files with 204 additions and 47 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNREACHABLE_CODE
fun TODO(): Nothing = throw java.lang.<!UNRESOLVED_REFERENCE!>IllegalStateException<!>()
fun TODO(): Nothing = throw java.lang.IllegalStateException()
open class OpenClass
class FinalClass : OpenClass()
@@ -151,7 +151,7 @@ fun foo(a : Nothing) : Unit {
}
fun fail() : Nothing {
throw java.lang.<!UNRESOLVED_REFERENCE!>RuntimeException<!>()
throw java.lang.RuntimeException()
}
fun nullIsNotNothing() : Unit {
@@ -140,7 +140,7 @@ fun testCoercionToAny() {
fun fooWithAnuNullableResult(s: String?, name: String, optional: Boolean): Any? {
return if (s == null) {
if (!optional) {
throw java.lang.<!UNRESOLVED_REFERENCE!>IllegalArgumentException<!>("Parameter '$name' was not found in the request")
throw java.lang.IllegalArgumentException("Parameter '$name' was not found in the request")
}
null
} else {
@@ -23,7 +23,7 @@ operator fun <T : Any> T?.iterator() = object : MyIterator<T> {
hasNext = false
return this@iterator!!
}
throw java.util.<!UNRESOLVED_REFERENCE!>NoSuchElementException<!>()
throw java.util.NoSuchElementException()
}
}
@@ -11,6 +11,6 @@ public class Clazz<Psi> {
public fun <T, C : MutableCollection<in T>> Iterable<T>.filterTo(destination: C, predicate: (T) -> Boolean) {}
fun test(clazz: Clazz<out Any>) {
val result = java.util.<!UNRESOLVED_REFERENCE!>ArrayList<!><Any>()
clazz.foo().<!INAPPLICABLE_CANDIDATE!>filterTo<!>(result) { x -> true }
val result = java.util.ArrayList<Any>()
clazz.foo().filterTo(result) { x -> true }
}
@@ -10,7 +10,7 @@ fun test1() {
}
fun test2() {
val m0 = java.util.<!UNRESOLVED_REFERENCE!>HashMap<!>()
val m1 = java.util.<!UNRESOLVED_REFERENCE!>HashMap<!><String, String, String>()
val m2 = java.util.<!UNRESOLVED_REFERENCE!>HashMap<!><String>()
val m0 = java.util.HashMap()
val m1 = java.util.HashMap<String, String, String>()
val m2 = java.util.HashMap<String>()
}
@@ -28,7 +28,7 @@ fun test() {
fun <T> arrayList(vararg values: T) : ArrayList<T> = values.toCollection(ArrayList<T>(values.size))
fun <T, R> Collection<T>.map(transform : (T) -> R) : List<R> {
return <!INAPPLICABLE_CANDIDATE!>mapTo<!>(java.util.<!UNRESOLVED_REFERENCE!>ArrayList<!><R>(this.size), transform)
return mapTo(java.util.ArrayList<R>(this.size), transform)
}
fun <T, R, C: MutableCollection<in R>> Collection<T>.mapTo(result: C, transform : (T) -> R) : C {
@@ -9,5 +9,5 @@ package a
fun foo() {
// If this fails, it means that we have broken the rule that Java returns are always nullable
a.<!UNRESOLVED_REFERENCE!>Test<!><Int>().<!UNRESOLVED_REFERENCE!>t<!>() + 1
a.Test<Int>().t() + 1
}
@@ -4,8 +4,8 @@
package kt1270
fun foo() {
val sc = <!UNRESOLVED_REFERENCE!>java.util.<!UNRESOLVED_REFERENCE!>HashMap<!><String, SomeClass>()[""]<!>
val value = sc.<!UNRESOLVED_REFERENCE!>value<!>
val sc = java.util.HashMap<String, SomeClass>()[""]
val value = sc.<!INAPPLICABLE_CANDIDATE!>value<!>
}
private class SomeClass() {
@@ -1,7 +1,7 @@
// KT-459 Type argument inference fails when class names are fully qualified
fun test() {
val attributes : java.util.HashMap<String, String> = java.util.<!UNRESOLVED_REFERENCE!>HashMap<!>() // failure!
val attributes : java.util.HashMap<String, String> = java.util.HashMap() // failure!
attributes["href"] = "1" // inference fails, but it shouldn't
}
@@ -3,9 +3,9 @@
package demo
fun <T> filter(list : Array<T>, filter : (T) -> Boolean) : List<T> {
val answer = java.util.<!UNRESOLVED_REFERENCE!>ArrayList<!><T>();
val answer = java.util.ArrayList<T>();
for (l in list) {
if (filter(l)) answer.<!UNRESOLVED_REFERENCE!>add<!>(l)
if (filter(l)) answer.add(l)
}
return answer;
}