Do not parse !! as part of annotation type
^KT-26245 Related
This commit is contained in:
committed by
TeamCityServer
parent
37f923a98f
commit
16ca8ddbbd
@@ -833,7 +833,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
|||||||
|
|
||||||
PsiBuilder.Marker reference = mark();
|
PsiBuilder.Marker reference = mark();
|
||||||
PsiBuilder.Marker typeReference = mark();
|
PsiBuilder.Marker typeReference = mark();
|
||||||
parseUserType();
|
parseUserType(/* forAnnotation */ true);
|
||||||
typeReference.done(TYPE_REFERENCE);
|
typeReference.done(TYPE_REFERENCE);
|
||||||
reference.done(CONSTRUCTOR_CALLEE);
|
reference.done(CONSTRUCTOR_CALLEE);
|
||||||
|
|
||||||
@@ -2078,7 +2078,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
|||||||
dynamicType.done(DYNAMIC_TYPE);
|
dynamicType.done(DYNAMIC_TYPE);
|
||||||
}
|
}
|
||||||
else if (at(IDENTIFIER) || at(PACKAGE_KEYWORD) || atParenthesizedMutableForPlatformTypes(0)) {
|
else if (at(IDENTIFIER) || at(PACKAGE_KEYWORD) || atParenthesizedMutableForPlatformTypes(0)) {
|
||||||
parseUserType();
|
parseUserType(/* forAnnotation */ false);
|
||||||
}
|
}
|
||||||
else if (at(LPAR)) {
|
else if (at(LPAR)) {
|
||||||
PsiBuilder.Marker functionOrParenthesizedType = mark();
|
PsiBuilder.Marker functionOrParenthesizedType = mark();
|
||||||
@@ -2175,7 +2175,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
|||||||
* - (Mutable)List<Foo>!
|
* - (Mutable)List<Foo>!
|
||||||
* - Array<(out) Foo>!
|
* - Array<(out) Foo>!
|
||||||
*/
|
*/
|
||||||
private void parseUserType() {
|
private void parseUserType(boolean forAnnotation) {
|
||||||
PsiBuilder.Marker userType = mark();
|
PsiBuilder.Marker userType = mark();
|
||||||
|
|
||||||
if (at(PACKAGE_KEYWORD)) {
|
if (at(PACKAGE_KEYWORD)) {
|
||||||
@@ -2221,7 +2221,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
|
|||||||
|
|
||||||
userType.done(USER_TYPE);
|
userType.done(USER_TYPE);
|
||||||
|
|
||||||
if (at(EXCLEXCL)) {
|
if (!forAnnotation && at(EXCLEXCL)) {
|
||||||
PsiBuilder.Marker definitelyNotNull = userType.precede();
|
PsiBuilder.Marker definitelyNotNull = userType.precede();
|
||||||
advance(); // !!
|
advance(); // !!
|
||||||
definitelyNotNull.done(DEFINITELY_NOT_NULL_TYPE);
|
definitelyNotNull.done(DEFINITELY_NOT_NULL_TYPE);
|
||||||
|
|||||||
@@ -3,3 +3,7 @@ fun <T> foo1(x: T!!, y: List<T!!>, z: T!!.(T!!) -> T!!): T!! {}
|
|||||||
|
|
||||||
// should be prohibited on type-resolution level
|
// should be prohibited on type-resolution level
|
||||||
fun <T> foo2(x: T!!?, y: List<T!!?>, z: T!!?.(T!!?) -> T!!?, w: String!!): T!! {}
|
fun <T> foo2(x: T!!?, y: List<T!!?>, z: T!!?.(T!!?) -> T!!?, w: String!!): T!! {}
|
||||||
|
|
||||||
|
fun foo3() {
|
||||||
|
if (@RetentionSourceAndTargetExpression !!(x == y)) {}
|
||||||
|
}
|
||||||
|
|||||||
+53
-1
@@ -207,4 +207,56 @@ KtFile: DefinitelyNotNullType.kt
|
|||||||
PsiWhiteSpace(' ')
|
PsiWhiteSpace(' ')
|
||||||
BLOCK
|
BLOCK
|
||||||
PsiElement(LBRACE)('{')
|
PsiElement(LBRACE)('{')
|
||||||
PsiElement(RBRACE)('}')
|
PsiElement(RBRACE)('}')
|
||||||
|
PsiWhiteSpace('\n\n')
|
||||||
|
FUN
|
||||||
|
PsiElement(fun)('fun')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(IDENTIFIER)('foo3')
|
||||||
|
VALUE_PARAMETER_LIST
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
BLOCK
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiWhiteSpace('\n ')
|
||||||
|
IF
|
||||||
|
PsiElement(if)('if')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
CONDITION
|
||||||
|
ANNOTATED_EXPRESSION
|
||||||
|
ANNOTATION_ENTRY
|
||||||
|
PsiElement(AT)('@')
|
||||||
|
CONSTRUCTOR_CALLEE
|
||||||
|
TYPE_REFERENCE
|
||||||
|
USER_TYPE
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('RetentionSourceAndTargetExpression')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
PREFIX_EXPRESSION
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(EXCL)('!')
|
||||||
|
PREFIX_EXPRESSION
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(EXCL)('!')
|
||||||
|
PARENTHESIZED
|
||||||
|
PsiElement(LPAR)('(')
|
||||||
|
BINARY_EXPRESSION
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('x')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
OPERATION_REFERENCE
|
||||||
|
PsiElement(EQEQ)('==')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
REFERENCE_EXPRESSION
|
||||||
|
PsiElement(IDENTIFIER)('y')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiElement(RPAR)(')')
|
||||||
|
PsiWhiteSpace(' ')
|
||||||
|
THEN
|
||||||
|
BLOCK
|
||||||
|
PsiElement(LBRACE)('{')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
|
PsiWhiteSpace('\n')
|
||||||
|
PsiElement(RBRACE)('}')
|
||||||
|
|||||||
Reference in New Issue
Block a user