Use known type substitutor if it exists
This commit is contained in:
@@ -112,7 +112,10 @@ class CandidateResolver(
|
|||||||
|
|
||||||
private fun CallCandidateResolutionContext<*>.processTypeArguments() = check {
|
private fun CallCandidateResolutionContext<*>.processTypeArguments() = check {
|
||||||
val jetTypeArguments = call.getTypeArguments()
|
val jetTypeArguments = call.getTypeArguments()
|
||||||
if (!jetTypeArguments.isEmpty()) {
|
if (candidateCall.knownTypeParametersSubstitutor != null) {
|
||||||
|
candidateCall.setResultingSubstitutor(candidateCall.knownTypeParametersSubstitutor!!)
|
||||||
|
}
|
||||||
|
else if (!jetTypeArguments.isEmpty()) {
|
||||||
// Explicit type arguments passed
|
// Explicit type arguments passed
|
||||||
|
|
||||||
val typeArguments = ArrayList<KotlinType>()
|
val typeArguments = ArrayList<KotlinType>()
|
||||||
@@ -140,9 +143,6 @@ class CandidateResolver(
|
|||||||
|
|
||||||
candidateCall.setResultingSubstitutor(substitutor)
|
candidateCall.setResultingSubstitutor(substitutor)
|
||||||
}
|
}
|
||||||
else if (candidateCall.getKnownTypeParametersSubstitutor() != null) {
|
|
||||||
candidateCall.setResultingSubstitutor(candidateCall.getKnownTypeParametersSubstitutor()!!)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <D : CallableDescriptor, F : D> CallCandidateResolutionContext<D>.mapArguments()
|
private fun <D : CallableDescriptor, F : D> CallCandidateResolutionContext<D>.mapArguments()
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ package boundsWithSubstitutors
|
|||||||
|
|
||||||
class Pair<A, B>
|
class Pair<A, B>
|
||||||
|
|
||||||
abstract class C<T : B<<!UPPER_BOUND_VIOLATED!>Int<!>>, X : (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) -> Pair<B<<!UPPER_BOUND_VIOLATED!>Any<!>>, B<A>>>() : B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() { // 2 errors
|
abstract class C<T : B<<!UPPER_BOUND_VIOLATED!>Int<!>>, X : (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) -> Pair<B<<!UPPER_BOUND_VIOLATED!>Any<!>>, B<A>>>() : B<<!UPPER_BOUND_VIOLATED!>Any<!>>() { // 2 errors
|
||||||
val a = B<<!UPPER_BOUND_VIOLATED!>Char<!>>() // error
|
val a = B<<!UPPER_BOUND_VIOLATED!>Char<!>>() // error
|
||||||
|
|
||||||
abstract val x : (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) -> B<<!UPPER_BOUND_VIOLATED!>Any<!>>
|
abstract val x : (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) -> B<<!UPPER_BOUND_VIOLATED!>Any<!>>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
open class C<T : C<T>>
|
open class C<T : C<T>>
|
||||||
class TestOK : C<TestOK>()
|
class TestOK : C<TestOK>()
|
||||||
class TestFail : C<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>C<<!UPPER_BOUND_VIOLATED!>TestFail<!>><!>>()
|
class TestFail : C<<!UPPER_BOUND_VIOLATED!>C<<!UPPER_BOUND_VIOLATED!>TestFail<!>><!>>()
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ abstract class Wrapper<T: A>(protected val t: T)
|
|||||||
class MyWrapper(a: A): Wrapper<A>(a)
|
class MyWrapper(a: A): Wrapper<A>(a)
|
||||||
|
|
||||||
// This wrapper is not legal
|
// This wrapper is not legal
|
||||||
class TheirWrapper(e: E): Wrapper<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>E<!>>(e)
|
class TheirWrapper(e: E): Wrapper<<!UPPER_BOUND_VIOLATED!>E<!>>(e)
|
||||||
|
|
||||||
data class Pair<out T>(val a: T, val b: T)
|
data class Pair<out T>(val a: T, val b: T)
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class E
|
|||||||
class MyWrapper(a: A): Wrapper<A>(a)
|
class MyWrapper(a: A): Wrapper<A>(a)
|
||||||
|
|
||||||
// This wrapper is not legal
|
// This wrapper is not legal
|
||||||
class TheirWrapper(e: E): Wrapper<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>E<!>>(e)
|
class TheirWrapper(e: E): Wrapper<<!UPPER_BOUND_VIOLATED!>E<!>>(e)
|
||||||
|
|
||||||
data class Pair<out T>(val a: T, val b: T)
|
data class Pair<out T>(val a: T, val b: T)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user