Allow references to nested class constructors in objects in LV = 1.0
#KT-16598 Fixed
This commit is contained in:
+15
-13
@@ -57,7 +57,6 @@ import org.jetbrains.kotlin.types.typeUtil.builtIns
|
|||||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
|
||||||
import org.jetbrains.kotlin.utils.yieldIfNotNull
|
import org.jetbrains.kotlin.utils.yieldIfNotNull
|
||||||
import java.lang.UnsupportedOperationException
|
import java.lang.UnsupportedOperationException
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -605,27 +604,30 @@ class DoubleColonExpressionResolver(
|
|||||||
if (expression.isEmptyLHS) null
|
if (expression.isEmptyLHS) null
|
||||||
else resolveDoubleColonLHS(expression, context)
|
else resolveDoubleColonLHS(expression, context)
|
||||||
|
|
||||||
if (lhsResult is DoubleColonLHS.Expression) {
|
val resolutionResults = resolveCallableReferenceRHS(expression, lhsResult, context, resolveArgumentsMode)
|
||||||
reportUnsupportedIfNeeded(expression, context)
|
|
||||||
}
|
|
||||||
|
|
||||||
val resolutionResults =
|
reportUnsupportedCallableReferenceIfNeeded(expression, context, lhsResult, resolutionResults)
|
||||||
resolveCallableReferenceRHS(expression, lhsResult, context, resolveArgumentsMode)
|
|
||||||
|
|
||||||
reportUnsupportedReferenceToSuspendFunction(resolutionResults, expression, context)
|
|
||||||
|
|
||||||
return lhsResult to resolutionResults
|
return lhsResult to resolutionResults
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reportUnsupportedReferenceToSuspendFunction(
|
private fun reportUnsupportedCallableReferenceIfNeeded(
|
||||||
resolutionResults: OverloadResolutionResults<CallableDescriptor>?,
|
|
||||||
expression: KtCallableReferenceExpression,
|
expression: KtCallableReferenceExpression,
|
||||||
context: ExpressionTypingContext
|
context: ExpressionTypingContext,
|
||||||
|
lhsResult: DoubleColonLHS?,
|
||||||
|
resolutionResults: OverloadResolutionResults<CallableDescriptor>?
|
||||||
) {
|
) {
|
||||||
if (resolutionResults?.isSingleResult == true &&
|
val descriptor =
|
||||||
resolutionResults.resultingDescriptor.safeAs<FunctionDescriptor>()?.isSuspend == true) {
|
if (resolutionResults?.isSingleResult == true) resolutionResults.resultingDescriptor as? FunctionDescriptor else null
|
||||||
|
if (descriptor?.isSuspend == true) {
|
||||||
context.trace.report(UNSUPPORTED.on(expression.callableReference, "Callable references to suspend functions"))
|
context.trace.report(UNSUPPORTED.on(expression.callableReference, "Callable references to suspend functions"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val expressionResult = lhsResult as? DoubleColonLHS.Expression ?: return
|
||||||
|
// "<expr>::foo" was not supported without bound callable references, except the case of a nested class constructor in an object
|
||||||
|
if (!expressionResult.isObjectQualifier || descriptor !is ConstructorDescriptor) {
|
||||||
|
reportUnsupportedIfNeeded(expression, context)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ResolutionResultsAndTraceCommitCallback(
|
private class ResolutionResultsAndTraceCommitCallback(
|
||||||
|
|||||||
+7
-1
@@ -4,8 +4,14 @@ class C { companion object }
|
|||||||
val ok1 = C::hashCode
|
val ok1 = C::hashCode
|
||||||
val fail1 = <!UNSUPPORTED_FEATURE!>C.Companion<!>::hashCode
|
val fail1 = <!UNSUPPORTED_FEATURE!>C.Companion<!>::hashCode
|
||||||
|
|
||||||
object O
|
object O {
|
||||||
|
class Y {
|
||||||
|
companion object
|
||||||
|
}
|
||||||
|
}
|
||||||
val fail2 = <!UNSUPPORTED_FEATURE!>O<!>::hashCode
|
val fail2 = <!UNSUPPORTED_FEATURE!>O<!>::hashCode
|
||||||
|
val ok2 = O::Y
|
||||||
|
val ok3 = O.Y::hashCode
|
||||||
|
|
||||||
fun hashCode() {}
|
fun hashCode() {}
|
||||||
|
|
||||||
|
|||||||
+16
@@ -6,6 +6,8 @@ public val fail3: kotlin.reflect.KFunction0<kotlin.Int>
|
|||||||
public val fail4: kotlin.reflect.KFunction0<kotlin.Int>
|
public val fail4: kotlin.reflect.KFunction0<kotlin.Int>
|
||||||
public val fail5: kotlin.reflect.KFunction0<kotlin.Int>
|
public val fail5: kotlin.reflect.KFunction0<kotlin.Int>
|
||||||
public val ok1: kotlin.reflect.KFunction1<C, kotlin.Int>
|
public val ok1: kotlin.reflect.KFunction1<C, kotlin.Int>
|
||||||
|
public val ok2: kotlin.reflect.KFunction0<O.Y>
|
||||||
|
public val ok3: kotlin.reflect.KFunction1<O.Y, kotlin.Int>
|
||||||
public fun hashCode(): kotlin.Unit
|
public fun hashCode(): kotlin.Unit
|
||||||
|
|
||||||
public final class C {
|
public final class C {
|
||||||
@@ -27,4 +29,18 @@ public object O {
|
|||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
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 hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final class Y {
|
||||||
|
public constructor Y()
|
||||||
|
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 companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user