JS: refactor generation of property callable references
This commit is contained in:
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.callUtil
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
@@ -200,6 +201,15 @@ fun KtExpression.getFunctionResolvedCallWithAssert(context: BindingContext): Res
|
||||
return resolvedCall as ResolvedCall<out FunctionDescriptor>
|
||||
}
|
||||
|
||||
fun KtExpression.getPropertyResolvedCallWithAssert(context: BindingContext): ResolvedCall<out PropertyDescriptor> {
|
||||
val resolvedCall = getResolvedCallWithAssert(context)
|
||||
assert(resolvedCall.resultingDescriptor is PropertyDescriptor) {
|
||||
"ResolvedCall for this expression must be ResolvedCall<? extends PropertyDescriptor>: ${this.getTextWithLocation()}"
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return resolvedCall as ResolvedCall<out PropertyDescriptor>
|
||||
}
|
||||
|
||||
fun KtExpression.getType(context: BindingContext): KotlinType? {
|
||||
val type = context.getType(this)
|
||||
if (type != null) return type
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// Enable when callable references to builtin members are supported.
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
fun box(): String {
|
||||
val f = "kotlin"::length
|
||||
val result = f.get()
|
||||
|
||||
-3
@@ -1,6 +1,3 @@
|
||||
// TODO: muted automatically, investigate should it be ran for JS or not
|
||||
// IGNORE_BACKEND: JS
|
||||
|
||||
// WITH_RUNTIME
|
||||
|
||||
fun box(): String =
|
||||
|
||||
Reference in New Issue
Block a user