Use AnonymousFunctionDescriptor for suspend callable references

Also use it for local suspend functions, which allows us to remove hack
with dropSuspend.

Regenerate tests.
This commit is contained in:
Ilmir Usmanov
2018-07-03 16:06:41 +03:00
parent eea95441c5
commit 28ad498956
31 changed files with 259 additions and 292 deletions
@@ -1,25 +1,18 @@
/*
* Copyright 2010-2015 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.descriptors.impl;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.kotlin.descriptors.SourceElement;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.name.SpecialNames;
public class AnonymousFunctionDescriptor extends SimpleFunctionDescriptorImpl {
@@ -36,6 +29,38 @@ public class AnonymousFunctionDescriptor extends SimpleFunctionDescriptorImpl {
this.isSuspend = isSuspend;
}
private AnonymousFunctionDescriptor(
@NotNull DeclarationDescriptor declarationDescriptor,
@Nullable SimpleFunctionDescriptor original,
@NotNull Annotations annotations,
@NotNull Name name,
@NotNull Kind kind,
@NotNull SourceElement source
) {
super(declarationDescriptor, original, annotations, name, kind, source);
this.isSuspend = false;
}
@NotNull
@Override
protected FunctionDescriptorImpl createSubstitutedCopy(
@NotNull DeclarationDescriptor newOwner,
@Nullable FunctionDescriptor original,
@NotNull Kind kind,
@Nullable Name newName,
@NotNull Annotations annotations,
@NotNull SourceElement source
) {
return new AnonymousFunctionDescriptor(
newOwner,
(SimpleFunctionDescriptor) original,
annotations,
newName != null ? newName : getName(),
kind,
source
);
}
@Override
public boolean isSuspend() {
return isSuspend;
@@ -632,7 +632,7 @@ class DoubleColonExpressionResolver(
val descriptor =
if (resolutionResults?.isSingleResult == true) resolutionResults.resultingDescriptor else null
if (descriptor is PropertyDescriptor && descriptor.isBuiltInCoroutineContext(languageVersionSettings)) {
context.trace.report(UNSUPPORTED.on(expression.callableReference, "Callable references to suspend property"))
context.trace.report(UNSUPPORTED.on(expression.callableReference, "Callable reference to suspend property"))
}
val expressionResult = lhsResult as? DoubleColonLHS.Expression ?: return