Introduce 'coroutine'/'suspend' modifiers
This commit is contained in:
+2
@@ -135,6 +135,7 @@ public class SingleAbstractMethodUtils {
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
null, SourceElement.NO_SOURCE);
|
||||
|
||||
KotlinType returnType = typeParameters.substitutor.substitute(samInterface.getDefaultType(), Variance.OUT_VARIANCE);
|
||||
@@ -250,6 +251,7 @@ public class SingleAbstractMethodUtils {
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
null, SourceElement.NO_SOURCE
|
||||
);
|
||||
valueParameters.add(newParam);
|
||||
|
||||
+1
@@ -175,6 +175,7 @@ public class SignaturesPropagationData {
|
||||
originalParam.declaresDefaultValue(),
|
||||
originalParam.isCrossinline(),
|
||||
originalParam.isNoinline(),
|
||||
originalParam.isCoroutine(),
|
||||
varargCheckResult.isVararg ? DescriptorUtilsKt.getBuiltIns(originalParam).getArrayElementType(altType) : null,
|
||||
SourceElement.NO_SOURCE
|
||||
));
|
||||
|
||||
+2
-1
@@ -46,6 +46,7 @@ sealed class LocalVariableAccessorDescriptor(
|
||||
}
|
||||
|
||||
private fun createValueParameter(name: Name, type: KotlinType): ValueParameterDescriptorImpl {
|
||||
return ValueParameterDescriptorImpl(this, null, 0, Annotations.EMPTY, name, type, false, false, false, null, SourceElement.NO_SOURCE)
|
||||
return ValueParameterDescriptorImpl(this, null, 0, Annotations.EMPTY, name, type,
|
||||
false, false, false, false, null, SourceElement.NO_SOURCE)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,6 +187,9 @@ public interface KtTokens {
|
||||
|
||||
KtModifierKeywordToken CONST_KEYWORD = KtModifierKeywordToken.softKeywordModifier("const");
|
||||
|
||||
KtModifierKeywordToken COROUTINE_KEYWORD = KtModifierKeywordToken.softKeywordModifier("coroutine");
|
||||
KtModifierKeywordToken SUSPEND_KEYWORD = KtModifierKeywordToken.softKeywordModifier("suspend");
|
||||
|
||||
TokenSet KEYWORDS = TokenSet.create(PACKAGE_KEYWORD, AS_KEYWORD, TYPE_ALIAS_KEYWORD, CLASS_KEYWORD, INTERFACE_KEYWORD,
|
||||
THIS_KEYWORD, SUPER_KEYWORD, VAL_KEYWORD, VAR_KEYWORD, FUN_KEYWORD, FOR_KEYWORD,
|
||||
NULL_KEYWORD,
|
||||
@@ -207,7 +210,8 @@ public interface KtTokens {
|
||||
DELEGATE_KEYWORD,
|
||||
LATEINIT_KEYWORD,
|
||||
DATA_KEYWORD, INLINE_KEYWORD, NOINLINE_KEYWORD, TAILREC_KEYWORD, EXTERNAL_KEYWORD,
|
||||
ANNOTATION_KEYWORD, CROSSINLINE_KEYWORD, CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD
|
||||
ANNOTATION_KEYWORD, CROSSINLINE_KEYWORD, CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD,
|
||||
COROUTINE_KEYWORD, SUSPEND_KEYWORD
|
||||
);
|
||||
|
||||
/*
|
||||
@@ -221,7 +225,7 @@ public interface KtTokens {
|
||||
PUBLIC_KEYWORD, INTERNAL_KEYWORD, PROTECTED_KEYWORD, OUT_KEYWORD, IN_KEYWORD, FINAL_KEYWORD, VARARG_KEYWORD,
|
||||
REIFIED_KEYWORD, COMPANION_KEYWORD, SEALED_KEYWORD, LATEINIT_KEYWORD,
|
||||
DATA_KEYWORD, INLINE_KEYWORD, NOINLINE_KEYWORD, TAILREC_KEYWORD, EXTERNAL_KEYWORD, ANNOTATION_KEYWORD, CROSSINLINE_KEYWORD,
|
||||
CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD
|
||||
CONST_KEYWORD, OPERATOR_KEYWORD, INFIX_KEYWORD, COROUTINE_KEYWORD, SUSPEND_KEYWORD
|
||||
};
|
||||
|
||||
TokenSet MODIFIER_KEYWORDS = TokenSet.create(MODIFIER_KEYWORDS_ARRAY);
|
||||
|
||||
@@ -286,6 +286,7 @@ public class DescriptorResolver {
|
||||
declaresDefaultValue,
|
||||
parameter.isCrossinline(),
|
||||
parameter.isNoinline(),
|
||||
parameter.isCoroutine(),
|
||||
parameter.getVarargElementType(), parameter.getSource());
|
||||
parameterDescriptors.add(parameterDescriptor);
|
||||
if (declaresDefaultValue) {
|
||||
@@ -376,6 +377,7 @@ public class DescriptorResolver {
|
||||
valueParameter.hasDefaultValue(),
|
||||
valueParameter.hasModifier(CROSSINLINE_KEYWORD),
|
||||
valueParameter.hasModifier(NOINLINE_KEYWORD),
|
||||
valueParameter.hasModifier(COROUTINE_KEYWORD),
|
||||
varargElementType,
|
||||
KotlinSourceElementKt.toSourceElement(valueParameter)
|
||||
);
|
||||
|
||||
@@ -179,6 +179,7 @@ class FunctionDescriptorResolver(
|
||||
functionDescriptor.isExternal = function.hasModifier(KtTokens.EXTERNAL_KEYWORD)
|
||||
functionDescriptor.isInline = function.hasModifier(KtTokens.INLINE_KEYWORD)
|
||||
functionDescriptor.isTailrec = function.hasModifier(KtTokens.TAILREC_KEYWORD)
|
||||
functionDescriptor.isSuspend = function.hasModifier(KtTokens.SUSPEND_KEYWORD)
|
||||
receiverType?.let { ForceResolveUtil.forceResolveAllContents(it.annotations) }
|
||||
for (valueParameterDescriptor in valueParameterDescriptors) {
|
||||
ForceResolveUtil.forceResolveAllContents(valueParameterDescriptor.type.annotations)
|
||||
@@ -200,6 +201,7 @@ class FunctionDescriptorResolver(
|
||||
val it = ValueParameterDescriptorImpl(functionDescriptor, null, 0, Annotations.EMPTY, Name.identifier("it"),
|
||||
valueParameterDescriptor.type, valueParameterDescriptor.declaresDefaultValue(),
|
||||
valueParameterDescriptor.isCrossinline, valueParameterDescriptor.isNoinline,
|
||||
valueParameterDescriptor.isCoroutine,
|
||||
valueParameterDescriptor.varargElementType, SourceElement.NO_SOURCE)
|
||||
trace.record(BindingContext.AUTO_CREATED_IT, it)
|
||||
return listOf(it)
|
||||
|
||||
@@ -79,7 +79,9 @@ object ModifierCheckerCore {
|
||||
DATA_KEYWORD to EnumSet.of(CLASS_ONLY, INNER_CLASS, LOCAL_CLASS),
|
||||
INLINE_KEYWORD to EnumSet.of(FUNCTION),
|
||||
NOINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER),
|
||||
COROUTINE_KEYWORD to EnumSet.of(VALUE_PARAMETER),
|
||||
TAILREC_KEYWORD to EnumSet.of(FUNCTION),
|
||||
SUSPEND_KEYWORD to EnumSet.of(FUNCTION),
|
||||
EXTERNAL_KEYWORD to EnumSet.of(FUNCTION, PROPERTY_GETTER, PROPERTY_SETTER),
|
||||
ANNOTATION_KEYWORD to EnumSet.of(ANNOTATION_CLASS),
|
||||
CROSSINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER),
|
||||
|
||||
@@ -164,6 +164,7 @@ class DynamicCallableDescriptors(builtIns: KotlinBuiltIns) {
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
varargElementType,
|
||||
SourceElement.NO_SOURCE
|
||||
))
|
||||
|
||||
@@ -42,6 +42,7 @@ internal fun createValueParametersForInvokeInFunctionType(
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
null, SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
|
||||
+1
@@ -59,6 +59,7 @@ class LazyScriptClassMemberScope(
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
null, SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
|
||||
+2
-1
@@ -162,6 +162,7 @@ public class ControlStructureTypingUtils {
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
null, SourceElement.NO_SOURCE
|
||||
);
|
||||
valueParameters.add(valueParameter);
|
||||
@@ -473,7 +474,7 @@ public class ControlStructureTypingUtils {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
private abstract static class ThrowingOnErrorTracingStrategy implements TracingStrategy {
|
||||
private final String debugName;
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ private fun createSynthesizedFunctionWithFirstParameterAsReceiver(descriptor: Fu
|
||||
original.valueParameters.drop(1).map { p ->
|
||||
ValueParameterDescriptorImpl(
|
||||
result, null, p.index - 1, p.annotations, Name.identifier("p${p.index + 1}"), p.type,
|
||||
p.declaresDefaultValue(), p.isCrossinline, p.isNoinline, p.varargElementType, p.source
|
||||
p.declaresDefaultValue(), p.isCrossinline, p.isNoinline, p.isCoroutine, p.varargElementType, p.source
|
||||
)
|
||||
},
|
||||
original.returnType,
|
||||
|
||||
+2
-2
@@ -295,7 +295,7 @@ public class DescriptorSerializer {
|
||||
int flags = Flags.getFunctionFlags(
|
||||
hasAnnotations(descriptor), descriptor.getVisibility(), descriptor.getModality(), descriptor.getKind(),
|
||||
descriptor.isOperator(), descriptor.isInfix(), descriptor.isInline(), descriptor.isTailrec(),
|
||||
descriptor.isExternal()
|
||||
descriptor.isExternal(), descriptor.isSuspend()
|
||||
);
|
||||
if (flags != builder.getFlags()) {
|
||||
builder.setFlags(flags);
|
||||
@@ -419,7 +419,7 @@ public class DescriptorSerializer {
|
||||
ProtoBuf.ValueParameter.Builder builder = ProtoBuf.ValueParameter.newBuilder();
|
||||
|
||||
int flags = Flags.getValueParameterFlags(hasAnnotations(descriptor), descriptor.declaresDefaultValue(),
|
||||
descriptor.isCrossinline(), descriptor.isNoinline());
|
||||
descriptor.isCrossinline(), descriptor.isNoinline(), descriptor.isCoroutine());
|
||||
if (flags != builder.getFlags()) {
|
||||
builder.setFlags(flags);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
class Controller {
|
||||
suspend fun suspendFun(x: Continuation<String>) {}
|
||||
operator fun handleResult(x: Int, y: Continuation<Nothing>) {}
|
||||
}
|
||||
|
||||
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package test
|
||||
|
||||
public fun builder(/*0*/ coroutine c: test.Controller.() -> kotlin.coroutines.Continuation<kotlin.Unit>): kotlin.Unit
|
||||
|
||||
public final class Controller {
|
||||
/*primary*/ public constructor Controller()
|
||||
public final operator fun handleResult(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.coroutines.Continuation<kotlin.Nothing>): kotlin.Unit
|
||||
public final suspend fun suspendFun(/*0*/ x: kotlin.coroutines.Continuation<kotlin.String>): kotlin.Unit
|
||||
}
|
||||
+4
@@ -16,6 +16,8 @@ public
|
||||
internal
|
||||
in
|
||||
out
|
||||
suspend
|
||||
coroutine
|
||||
class Bar<abstract, abstract enum : T, out open,
|
||||
public protected private internal abstract
|
||||
open
|
||||
@@ -60,6 +62,8 @@ out
|
||||
val setparam
|
||||
val lateinit
|
||||
val const
|
||||
val suspend
|
||||
val coroutine
|
||||
get() = a
|
||||
set(S : s) {}
|
||||
|
||||
|
||||
+15
-1
@@ -55,6 +55,10 @@ JetFile: SoftKeywords.kt
|
||||
PsiElement(in)('in')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(out)('out')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(suspend)('suspend')
|
||||
PsiWhiteSpace('\n')
|
||||
PsiElement(coroutine)('coroutine')
|
||||
PsiWhiteSpace('\n ')
|
||||
PsiElement(class)('class')
|
||||
PsiWhiteSpace(' ')
|
||||
@@ -313,6 +317,16 @@ JetFile: SoftKeywords.kt
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('const')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('suspend')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('coroutine')
|
||||
PsiWhiteSpace('\n ')
|
||||
PROPERTY_ACCESSOR
|
||||
PsiElement(get)('get')
|
||||
@@ -1614,4 +1628,4 @@ JetFile: SoftKeywords.kt
|
||||
CLASS_BODY
|
||||
PsiElement(LBRACE)('{')
|
||||
PsiWhiteSpace('\n\n')
|
||||
PsiElement(RBRACE)('}')
|
||||
PsiElement(RBRACE)('}')
|
||||
|
||||
@@ -2804,6 +2804,21 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/coroutines")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Coroutines extends AbstractLoadJavaTest {
|
||||
public void testAllFilesPresentInCoroutines() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/loadJava/compiledKotlin/coroutines"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Basic.kt")
|
||||
public void testBasic() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/coroutines/Basic.kt");
|
||||
doTestCompiledKotlin(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/dataClass")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+15
@@ -1037,6 +1037,21 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/coroutines")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Coroutines extends AbstractLoadKotlinWithTypeTableTest {
|
||||
public void testAllFilesPresentInCoroutines() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/loadJava/compiledKotlin/coroutines"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Basic.kt")
|
||||
public void testBasic() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/coroutines/Basic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/dataClass")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
+15
@@ -1039,6 +1039,21 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/coroutines")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Coroutines extends AbstractJvmRuntimeDescriptorLoaderTest {
|
||||
public void testAllFilesPresentInCoroutines() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/loadJava/compiledKotlin/coroutines"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Basic.kt")
|
||||
public void testBasic() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/coroutines/Basic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/dataClass")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -50,6 +50,7 @@ fun copyValueParameters(
|
||||
oldParameter.declaresDefaultValue(),
|
||||
oldParameter.isCrossinline,
|
||||
oldParameter.isNoinline,
|
||||
oldParameter.isCoroutine,
|
||||
if (oldParameter.varargElementType != null) newOwner.module.builtIns.getArrayElementType(newType) else null,
|
||||
oldParameter.source
|
||||
)
|
||||
|
||||
+1
@@ -617,6 +617,7 @@ class LazyJavaClassMemberScope(
|
||||
method.hasAnnotationParameterDefaultValue,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
// Nulls are not allowed in annotation arguments in Java
|
||||
varargElementType?.let { TypeUtils.makeNotNullable(it) },
|
||||
c.components.sourceElementFactory.source(method)
|
||||
|
||||
+2
-1
@@ -206,6 +206,7 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
varargElementType,
|
||||
c.components.sourceElementFactory.source(javaParameter)
|
||||
)
|
||||
@@ -329,7 +330,7 @@ abstract class LazyJavaScope(protected val c: LazyJavaResolverContext) : MemberS
|
||||
protected abstract fun getClassNames(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean): Collection<Name>
|
||||
|
||||
override fun toString() = "Lazy scope for $ownerDescriptor"
|
||||
|
||||
|
||||
override fun printScopeStructure(p: Printer) {
|
||||
p.println(javaClass.simpleName, " {")
|
||||
p.pushIndent()
|
||||
|
||||
+1
@@ -101,6 +101,7 @@ class FunctionInvokeDescriptor private constructor(
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
/* varargElementType = */ null,
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
@@ -80,6 +80,8 @@ public interface FunctionDescriptor extends CallableMemberDescriptor {
|
||||
|
||||
boolean isHiddenForResolutionEverywhereBesideSupercalls();
|
||||
|
||||
boolean isSuspend();
|
||||
|
||||
@NotNull
|
||||
CopyBuilder<? extends FunctionDescriptor> newCopyBuilder();
|
||||
|
||||
|
||||
@@ -54,4 +54,6 @@ interface ValueParameterDescriptor : VariableDescriptor, ParameterDescriptor {
|
||||
val isCrossinline: Boolean
|
||||
|
||||
val isNoinline: Boolean
|
||||
|
||||
val isCoroutine: Boolean
|
||||
}
|
||||
|
||||
+12
@@ -48,6 +48,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
// 2. isHiddenForResolutionEverywhereBesideSupercalls propagates to it's overrides descriptors while isHiddenToOvercomeSignatureClash does not
|
||||
private boolean isHiddenToOvercomeSignatureClash = false;
|
||||
private boolean isHiddenForResolutionEverywhereBesideSupercalls = false;
|
||||
private boolean isSuspend = false;
|
||||
private boolean hasStableParameterNames = true;
|
||||
private boolean hasSynthesizedParameterNames = false;
|
||||
private Collection<? extends FunctionDescriptor> overriddenFunctions = null;
|
||||
@@ -139,6 +140,10 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
isHiddenForResolutionEverywhereBesideSupercalls = hiddenForResolutionEverywhereBesideSupercalls;
|
||||
}
|
||||
|
||||
public void setSuspend(boolean suspend) {
|
||||
isSuspend = suspend;
|
||||
}
|
||||
|
||||
public void setReturnType(@NotNull KotlinType unsubstitutedReturnType) {
|
||||
if (this.unsubstitutedReturnType != null) {
|
||||
// TODO: uncomment and fix tests
|
||||
@@ -235,6 +240,11 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
return isTailrec;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuspend() {
|
||||
return isSuspend;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHiddenToOvercomeSignatureClash() {
|
||||
return isHiddenToOvercomeSignatureClash;
|
||||
@@ -599,6 +609,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
substitutedDescriptor.setExternal(isExternal);
|
||||
substitutedDescriptor.setInline(isInline);
|
||||
substitutedDescriptor.setTailrec(isTailrec);
|
||||
substitutedDescriptor.setSuspend(isSuspend);
|
||||
substitutedDescriptor.setHasStableParameterNames(hasStableParameterNames);
|
||||
substitutedDescriptor.setHasSynthesizedParameterNames(hasSynthesizedParameterNames);
|
||||
substitutedDescriptor.setHiddenToOvercomeSignatureClash(configuration.isHiddenToOvercomeSignatureClash);
|
||||
@@ -685,6 +696,7 @@ public abstract class FunctionDescriptorImpl extends DeclarationDescriptorNonRoo
|
||||
unsubstitutedValueParameter.declaresDefaultValue(),
|
||||
unsubstitutedValueParameter.isCrossinline(),
|
||||
unsubstitutedValueParameter.isNoinline(),
|
||||
unsubstitutedValueParameter.isCoroutine(),
|
||||
substituteVarargElementType,
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
+5
@@ -94,6 +94,11 @@ public abstract class PropertyAccessorDescriptorImpl extends DeclarationDescript
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuspend() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FunctionDescriptor substitute(@NotNull TypeSubstitutor substitutor) {
|
||||
|
||||
+1
@@ -70,6 +70,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
null, SourceElement.NO_SOURCE
|
||||
);
|
||||
}
|
||||
|
||||
+2
-1
@@ -32,6 +32,7 @@ class ValueParameterDescriptorImpl(
|
||||
private val declaresDefaultValue: Boolean,
|
||||
override val isCrossinline: Boolean,
|
||||
override val isNoinline: Boolean,
|
||||
override val isCoroutine: Boolean,
|
||||
override val varargElementType: KotlinType?,
|
||||
source: SourceElement
|
||||
) : VariableDescriptorImpl(containingDeclaration, annotations, name, outType, source), ValueParameterDescriptor {
|
||||
@@ -61,7 +62,7 @@ class ValueParameterDescriptorImpl(
|
||||
override fun copy(newOwner: CallableDescriptor, newName: Name): ValueParameterDescriptor {
|
||||
return ValueParameterDescriptorImpl(
|
||||
newOwner, null, index, annotations, newName, type, declaresDefaultValue(),
|
||||
isCrossinline, isNoinline, varargElementType, SourceElement.NO_SOURCE
|
||||
isCrossinline, isNoinline, isCoroutine, varargElementType, SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -498,6 +498,9 @@ internal class DescriptorRendererImpl(
|
||||
if (functionDescriptor.isTailrec) {
|
||||
builder.append("tailrec ")
|
||||
}
|
||||
if (functionDescriptor.isSuspend) {
|
||||
builder.append("suspend ")
|
||||
}
|
||||
}
|
||||
|
||||
override fun render(declarationDescriptor: DeclarationDescriptor): String {
|
||||
@@ -724,10 +727,15 @@ internal class DescriptorRendererImpl(
|
||||
if (valueParameter.isCrossinline) {
|
||||
builder.append("crossinline ")
|
||||
}
|
||||
|
||||
if (valueParameter.isNoinline) {
|
||||
builder.append("noinline ")
|
||||
}
|
||||
|
||||
if (valueParameter.isCoroutine) {
|
||||
builder.append("coroutine ")
|
||||
}
|
||||
|
||||
renderVariable(valueParameter, includeName, builder, topLevel)
|
||||
|
||||
val withDefaultValue = renderDefaultValues && (if (debugMode) valueParameter.declaresDefaultValue() else valueParameter.hasDefaultValue())
|
||||
|
||||
@@ -140,6 +140,7 @@ public class DescriptorFactory {
|
||||
/* declaresDefaultValue = */ false,
|
||||
/* isCrossinline = */ false,
|
||||
/* isNoinline = */ false,
|
||||
/* isCoroutine = */ false,
|
||||
null,
|
||||
enumClass.getSource()
|
||||
);
|
||||
|
||||
+5
@@ -185,6 +185,11 @@ public class ErrorSimpleFunctionDescriptorImpl extends SimpleFunctionDescriptorI
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuspend() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverriddenDescriptors(@NotNull Collection<? extends CallableMemberDescriptor> overriddenDescriptors) {
|
||||
// nop
|
||||
|
||||
@@ -51,6 +51,7 @@ public class Flags {
|
||||
public static final BooleanFlagField IS_INLINE = FlagField.booleanAfter(IS_INFIX);
|
||||
public static final BooleanFlagField IS_TAILREC = FlagField.booleanAfter(IS_INLINE);
|
||||
public static final BooleanFlagField IS_EXTERNAL_FUNCTION = FlagField.booleanAfter(IS_TAILREC);
|
||||
public static final BooleanFlagField IS_SUSPEND = FlagField.booleanAfter(IS_EXTERNAL_FUNCTION);
|
||||
|
||||
// Properties
|
||||
|
||||
@@ -66,6 +67,7 @@ public class Flags {
|
||||
public static final BooleanFlagField DECLARES_DEFAULT_VALUE = FlagField.booleanAfter(HAS_ANNOTATIONS);
|
||||
public static final BooleanFlagField IS_CROSSINLINE = FlagField.booleanAfter(DECLARES_DEFAULT_VALUE);
|
||||
public static final BooleanFlagField IS_NOINLINE = FlagField.booleanAfter(IS_CROSSINLINE);
|
||||
public static final BooleanFlagField IS_COROUTINE = FlagField.booleanAfter(IS_NOINLINE);
|
||||
|
||||
// Accessors
|
||||
|
||||
@@ -132,7 +134,8 @@ public class Flags {
|
||||
boolean isInfix,
|
||||
boolean isInline,
|
||||
boolean isTailrec,
|
||||
boolean isExternal
|
||||
boolean isExternal,
|
||||
boolean isSuspend
|
||||
) {
|
||||
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||
| VISIBILITY.toFlags(visibility(visibility))
|
||||
@@ -143,6 +146,7 @@ public class Flags {
|
||||
| IS_INLINE.toFlags(isInline)
|
||||
| IS_TAILREC.toFlags(isTailrec)
|
||||
| IS_EXTERNAL_FUNCTION.toFlags(isExternal)
|
||||
| IS_SUSPEND.toFlags(isSuspend)
|
||||
;
|
||||
}
|
||||
|
||||
@@ -243,12 +247,14 @@ public class Flags {
|
||||
boolean hasAnnotations,
|
||||
boolean declaresDefaultValue,
|
||||
boolean isCrossinline,
|
||||
boolean isNoinline
|
||||
boolean isNoinline,
|
||||
boolean isCoroutine
|
||||
) {
|
||||
return HAS_ANNOTATIONS.toFlags(hasAnnotations)
|
||||
| DECLARES_DEFAULT_VALUE.toFlags(declaresDefaultValue)
|
||||
| IS_CROSSINLINE.toFlags(isCrossinline)
|
||||
| IS_NOINLINE.toFlags(isNoinline)
|
||||
| IS_COROUTINE.toFlags(isCoroutine)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -164,6 +164,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
function.isExternal = Flags.IS_EXTERNAL_FUNCTION.get(flags)
|
||||
function.isInline = Flags.IS_INLINE.get(flags)
|
||||
function.isTailrec = Flags.IS_TAILREC.get(flags)
|
||||
function.isSuspend = Flags.IS_SUSPEND.get(flags)
|
||||
return function
|
||||
}
|
||||
|
||||
@@ -252,6 +253,7 @@ class MemberDeserializer(private val c: DeserializationContext) {
|
||||
Flags.DECLARES_DEFAULT_VALUE.get(flags),
|
||||
Flags.IS_CROSSINLINE.get(flags),
|
||||
Flags.IS_NOINLINE.get(flags),
|
||||
Flags.IS_COROUTINE.get(flags),
|
||||
proto.varargElementType(c.typeTable)?.let { c.typeDeserializer.type(it) },
|
||||
SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
+2
@@ -134,6 +134,8 @@ class DeserializedConstructorDescriptor(
|
||||
override fun isInline(): Boolean = false
|
||||
|
||||
override fun isTailrec(): Boolean = false
|
||||
|
||||
override fun isSuspend(): Boolean = false
|
||||
}
|
||||
|
||||
class DeserializedTypeAliasDescriptor(
|
||||
|
||||
+1
-1
@@ -130,7 +130,7 @@ private class FunctionClsStubBuilder(
|
||||
val modalityModifier = if (isTopLevel) listOf() else listOf(MODALITY)
|
||||
val modifierListStubImpl = createModifierListStubForDeclaration(
|
||||
callableStub, functionProto.flags,
|
||||
listOf(VISIBILITY, OPERATOR, INFIX, EXTERNAL_FUN, INLINE, TAILREC) + modalityModifier
|
||||
listOf(VISIBILITY, OPERATOR, INFIX, EXTERNAL_FUN, INLINE, TAILREC, SUSPEND) + modalityModifier
|
||||
)
|
||||
|
||||
val annotationIds = c.components.annotationLoader.loadCallableAnnotations(
|
||||
|
||||
+3
@@ -171,6 +171,9 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) {
|
||||
if (varargElementType != null) { modifiers.add(KtTokens.VARARG_KEYWORD) }
|
||||
if (Flags.IS_CROSSINLINE.get(valueParameterProto.flags)) { modifiers.add(KtTokens.CROSSINLINE_KEYWORD) }
|
||||
if (Flags.IS_NOINLINE.get(valueParameterProto.flags)) { modifiers.add(KtTokens.NOINLINE_KEYWORD) }
|
||||
if (Flags.IS_COROUTINE.get(valueParameterProto.flags)) {
|
||||
modifiers.add(KtTokens.COROUTINE_KEYWORD)
|
||||
}
|
||||
|
||||
val modifierList = createModifierListStub(parameterStub, modifiers)
|
||||
val parameterAnnotations = c.components.annotationLoader.loadValueParameterAnnotations(
|
||||
|
||||
@@ -60,6 +60,7 @@ val DATA = createBooleanFlagToModifier(Flags.IS_DATA, KtTokens.DATA_KEYWORD)
|
||||
val EXTERNAL_FUN = createBooleanFlagToModifier(Flags.IS_EXTERNAL_FUNCTION, KtTokens.EXTERNAL_KEYWORD)
|
||||
val INLINE = createBooleanFlagToModifier(Flags.IS_INLINE, KtTokens.INLINE_KEYWORD)
|
||||
val TAILREC = createBooleanFlagToModifier(Flags.IS_TAILREC, KtTokens.TAILREC_KEYWORD)
|
||||
val SUSPEND = createBooleanFlagToModifier(Flags.IS_SUSPEND, KtTokens.SUSPEND_KEYWORD)
|
||||
|
||||
private fun createBooleanFlagToModifier(
|
||||
flagField: Flags.BooleanFlagField, ktModifierKeywordToken: KtModifierKeywordToken
|
||||
|
||||
@@ -40,4 +40,5 @@ class MouseMovedEventArgs
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -34,4 +34,5 @@ class B {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -39,4 +39,5 @@ class A {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -38,4 +38,5 @@ var a : Int
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -25,4 +25,5 @@ annotation class Test {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -37,4 +37,5 @@ public class Test {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -31,4 +31,5 @@ class TestClass {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -25,6 +25,7 @@ enum class Test {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// EXIST: fun
|
||||
|
||||
/* TODO: items below are not valid here */
|
||||
|
||||
@@ -27,4 +27,5 @@ interface Test {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -8,6 +8,7 @@ class TestSample() {
|
||||
// EXIST: vararg
|
||||
// EXIST: noinline
|
||||
// EXIST: crossinline
|
||||
// EXIST: coroutine
|
||||
/* TODO: val&var are not correct */
|
||||
// EXIST: val
|
||||
// EXIST: var
|
||||
|
||||
@@ -28,4 +28,5 @@ object Test {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ class TestSample(<caret>)
|
||||
// EXIST: private
|
||||
// EXIST: protected
|
||||
// EXIST: internal
|
||||
|
||||
// EXIST: coroutine
|
||||
/* TODO: keywords below should not be here*/
|
||||
// EXIST: abstract
|
||||
// EXIST: const
|
||||
|
||||
@@ -5,6 +5,7 @@ fun test(<caret>) {
|
||||
// EXIST: vararg
|
||||
// EXIST: noinline
|
||||
// EXIST: crossinline
|
||||
// EXIST: coroutine
|
||||
/* TODO: they all are not correct */
|
||||
// EXIST: val
|
||||
// EXIST: var
|
||||
|
||||
@@ -25,4 +25,5 @@ package Test
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -39,4 +39,5 @@ class Some {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -39,4 +39,5 @@ class Some {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -37,4 +37,5 @@ class Some {
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -24,4 +24,5 @@
|
||||
// EXIST: external
|
||||
// EXIST: annotation class
|
||||
// EXIST: const
|
||||
// EXIST: suspend
|
||||
// NOTHING_ELSE
|
||||
|
||||
@@ -206,7 +206,7 @@ class ChangeMemberFunctionSignatureFix private constructor(
|
||||
ValueParameterDescriptorImpl(
|
||||
descriptor, null, index,
|
||||
parameter.annotations, parameter.name, parameter.returnType!!, parameter.declaresDefaultValue(),
|
||||
parameter.isCrossinline, parameter.isNoinline, parameter.varargElementType, SourceElement.NO_SOURCE
|
||||
parameter.isCrossinline, parameter.isNoinline, parameter.isCoroutine, parameter.varargElementType, SourceElement.NO_SOURCE
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,4 +9,4 @@ data class Modifiers(val x: Int) {
|
||||
inline fun inlined(crossinline arg1: ()->Unit, noinline arg2: ()->Unit): Unit {}
|
||||
}
|
||||
|
||||
annotation class Ann
|
||||
annotation class Ann
|
||||
|
||||
@@ -17,4 +17,8 @@ data class Modifiers(val x: Int) {
|
||||
override operator fun equals(other: Any?) = false
|
||||
|
||||
annotation class Ann
|
||||
}
|
||||
|
||||
suspend fun suspend(x: Continuation<Int>) {}
|
||||
|
||||
fun builder(coroutine c: Any.() -> Continuation<Unit>) {}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,39 @@ PsiJetFileStubImpl[package=test]
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Int]
|
||||
FUN:[fqName=test.Modifiers.builder, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=builder]
|
||||
MODIFIER_LIST:[public final]
|
||||
VALUE_PARAMETER_LIST:
|
||||
VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=c]
|
||||
MODIFIER_LIST:[coroutine]
|
||||
TYPE_REFERENCE:
|
||||
FUNCTION_TYPE:
|
||||
FUNCTION_TYPE_RECEIVER:
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Any]
|
||||
VALUE_PARAMETER_LIST:
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=coroutines]
|
||||
REFERENCE_EXPRESSION:[referencedName=Continuation]
|
||||
TYPE_ARGUMENT_LIST:
|
||||
TYPE_PROJECTION:[projectionKind=NONE]
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Unit]
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Unit]
|
||||
FUN:[fqName=test.Modifiers.component1, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=component1]
|
||||
MODIFIER_LIST:[public final operator]
|
||||
VALUE_PARAMETER_LIST:
|
||||
@@ -107,6 +140,29 @@ PsiJetFileStubImpl[package=test]
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Long]
|
||||
FUN:[fqName=test.Modifiers.suspend, hasBlockBody=true, hasBody=true, hasTypeParameterListBeforeFunctionName=false, isExtension=false, isTopLevel=false, name=suspend]
|
||||
MODIFIER_LIST:[public final suspend]
|
||||
VALUE_PARAMETER_LIST:
|
||||
VALUE_PARAMETER:[fqName=null, hasDefaultValue=false, hasValOrVar=false, isMutable=false, name=x]
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=coroutines]
|
||||
REFERENCE_EXPRESSION:[referencedName=Continuation]
|
||||
TYPE_ARGUMENT_LIST:
|
||||
TYPE_PROJECTION:[projectionKind=NONE]
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Int]
|
||||
TYPE_REFERENCE:
|
||||
USER_TYPE:
|
||||
USER_TYPE:
|
||||
REFERENCE_EXPRESSION:[referencedName=kotlin]
|
||||
REFERENCE_EXPRESSION:[referencedName=Unit]
|
||||
CLASS:[fqName=test.Modifiers.Ann, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=Ann, superNames=[Annotation]]
|
||||
MODIFIER_LIST:[public final annotation]
|
||||
PRIMARY_CONSTRUCTOR:
|
||||
|
||||
@@ -1037,6 +1037,21 @@ public class ResolveByStubTestGenerated extends AbstractResolveByStubTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/coroutines")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Coroutines extends AbstractResolveByStubTest {
|
||||
public void testAllFilesPresentInCoroutines() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/loadJava/compiledKotlin/coroutines"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("Basic.kt")
|
||||
public void testBasic() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/loadJava/compiledKotlin/coroutines/Basic.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/loadJava/compiledKotlin/dataClass")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user