Minor: add test to call callable references from Java

This commit is contained in:
Ilmir Usmanov
2018-07-04 15:38:09 +03:00
parent 4e8cc53962
commit 4ec82cad90
11 changed files with 111 additions and 29 deletions
@@ -1124,7 +1124,9 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (!isCrossinlineLambda) {
v.aconst(null);
}
} else if (DescriptorUtilsKt.isCallableReferenceToSuspend(classDescriptor, state.getJvmRuntimeTypes().getFunctionReference())) {
}
else if (classDescriptor instanceof SyntheticClassDescriptorForLambda &&
((SyntheticClassDescriptorForLambda) classDescriptor).isCallableReference()) {
// Constructor of callable reference to suspend function does not accept continuation:
// do nothing.
}
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen
@@ -21,8 +10,10 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.impl.ClassDescriptorImpl
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.resolve.source.getPsi
import org.jetbrains.kotlin.resolve.source.toSourceElement
import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.types.KotlinType
@@ -37,4 +28,6 @@ class SyntheticClassDescriptorForLambda(
init {
initialize(MemberScope.Empty, emptySet(), null)
}
fun isCallableReference(): Boolean = source.getPsi() is KtCallableReferenceExpression
}