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)
|
||||
|
||||
Reference in New Issue
Block a user