[NI] Fix substitutor for anonymous types with captured type parameters
This commit is contained in:
@@ -574,7 +574,7 @@ class DelegatedPropertyResolver(
|
||||
|
||||
val resolvedDelegateType = extractResolvedDelegateType(delegateExpression, trace)
|
||||
|
||||
return AnonymousTypeSubstitutor.safeSubstitute(resolvedDelegateType.unwrap())
|
||||
return TypeSubstitutor.create(AnonymousTypeSubstitutor).safeSubstitute(resolvedDelegateType, Variance.INVARIANT).unwrap()
|
||||
}
|
||||
|
||||
private fun extractResolvedDelegateType(delegateExpression: KtExpression, trace: BindingTrace): KotlinType {
|
||||
@@ -703,11 +703,11 @@ class DelegatedPropertyResolver(
|
||||
}
|
||||
}
|
||||
|
||||
private object AnonymousTypeSubstitutor : NewTypeSubstitutor {
|
||||
override fun substituteNotNullTypeWithConstructor(constructor: TypeConstructor): UnwrappedType? {
|
||||
val declarationDescriptor = constructor.declarationDescriptor
|
||||
private object AnonymousTypeSubstitutor : TypeConstructorSubstitution() {
|
||||
override fun get(key: TypeConstructor): TypeProjection? {
|
||||
val declarationDescriptor = key.declarationDescriptor
|
||||
if (declarationDescriptor is ClassifierDescriptor && DescriptorUtils.isAnonymousObject(declarationDescriptor)) {
|
||||
return constructor.supertypes.firstOrNull()?.unwrap()
|
||||
return key.supertypes.firstOrNull()?.let(::TypeProjectionImpl)
|
||||
}
|
||||
|
||||
return null
|
||||
|
||||
+6
@@ -14,6 +14,12 @@ private val withTwoSupertypes by lazy {
|
||||
object : First, Second { }
|
||||
}
|
||||
|
||||
class A<T> {
|
||||
val a: First by lazy {
|
||||
object : First { }
|
||||
}
|
||||
}
|
||||
|
||||
interface First
|
||||
interface Second
|
||||
|
||||
|
||||
+8
@@ -5,6 +5,14 @@ private val withTwoSupertypes: withTwoSupertypes.<anonymous>.<no name provided>
|
||||
private val withoutType: withoutType.<anonymous>.<no name provided>
|
||||
public fun </*0*/ T> lazy(/*0*/ initializer: () -> T): Lazy<T>
|
||||
|
||||
public final class A</*0*/ T> {
|
||||
public constructor A</*0*/ T>()
|
||||
public final val a: First
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface First {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
|
||||
Reference in New Issue
Block a user