[FIR] Fix calculating of source of TypeArgumentList, add source to FirQualifierPart

Fix positioning for TYPE_ARGUMENTS_NOT_ALLOWED
This commit is contained in:
Ivan Kochurkin
2021-07-06 22:21:33 +03:00
committed by TeamCityServer
parent 28a6928873
commit 0c25d280ee
8 changed files with 34 additions and 19 deletions
@@ -1,14 +1,14 @@
package rest
abstract class Foo<T> {
abstract val x: <!TYPE_ARGUMENTS_NOT_ALLOWED!>T<Int><!>
abstract val x: T<!TYPE_ARGUMENTS_NOT_ALLOWED!><Int><!>
abstract fun foo(): <!TYPE_ARGUMENTS_NOT_ALLOWED!>T<String><!>
abstract fun foo(): T<!TYPE_ARGUMENTS_NOT_ALLOWED!><String><!>
}
fun <T> foo() {
bar<<!TYPE_ARGUMENTS_NOT_ALLOWED!>T<Int><!>>()
bar<List<List<<!TYPE_ARGUMENTS_NOT_ALLOWED!>T<Boolean><!>>>>()
bar<T<!TYPE_ARGUMENTS_NOT_ALLOWED!><Int><!>>()
bar<List<List<T<!TYPE_ARGUMENTS_NOT_ALLOWED!><Boolean><!>>>>()
}
fun <T> bar() {}
@@ -26,9 +26,9 @@ class C<F<!SYNTAX!><<!><!SYNTAX!>Boolean<!><!SYNTAX!>><!><!SYNTAX!>><!> <!SYNTAX
fun <G> gest() {}
fun <T> fest() {
val b: List<<!TYPE_ARGUMENTS_NOT_ALLOWED!>T<Double><!>>
gest<<!TYPE_ARGUMENTS_NOT_ALLOWED!>T<Char><!>>()
val b: List<T<!TYPE_ARGUMENTS_NOT_ALLOWED!><Double><!>>
gest<T<!TYPE_ARGUMENTS_NOT_ALLOWED!><Char><!>>()
gest<T>()
val c: List<List<List<<!TYPE_ARGUMENTS_NOT_ALLOWED!>T<String><!>>>>
gest<List<List<<!TYPE_ARGUMENTS_NOT_ALLOWED!>T<Boolean><!>>>>()
val c: List<List<List<T<!TYPE_ARGUMENTS_NOT_ALLOWED!><String><!>>>>
gest<List<List<T<!TYPE_ARGUMENTS_NOT_ALLOWED!><Boolean><!>>>>()
}
@@ -1843,12 +1843,20 @@ class DeclarationsConverter(
): FirTypeRef {
var simpleFirUserType: FirUserTypeRef? = null
var identifier: String? = null
var identifierSource: FirSourceElement? = null
val firTypeArguments = mutableListOf<FirTypeProjection>()
var typeArgumentsSource: FirSourceElement? = null
userType.forEachChildren {
when (it.tokenType) {
USER_TYPE -> simpleFirUserType = convertUserType(typeRefSource, it) as? FirUserTypeRef //simple user type
REFERENCE_EXPRESSION -> identifier = it.asText
TYPE_ARGUMENT_LIST -> firTypeArguments += convertTypeArguments(it)
REFERENCE_EXPRESSION -> {
identifierSource = it.toFirSourceElement()
identifier = it.asText
}
TYPE_ARGUMENT_LIST -> {
typeArgumentsSource = it.toFirSourceElement()
firTypeArguments += convertTypeArguments(it)
}
}
}
@@ -1859,8 +1867,9 @@ class DeclarationsConverter(
}
val qualifierPart = FirQualifierPartImpl(
identifierSource!!,
identifier.nameAsSafeName(),
FirTypeArgumentListImpl(typeRefSource).apply {
FirTypeArgumentListImpl(typeArgumentsSource ?: typeRefSource).apply {
typeArguments += firTypeArguments
}
)
@@ -1489,8 +1489,9 @@ open class RawFirBuilder(
do {
val firQualifier = FirQualifierPartImpl(
referenceExpression!!.toFirSourceElement(),
referenceExpression!!.getReferencedNameAsName(),
FirTypeArgumentListImpl(source).apply {
FirTypeArgumentListImpl(ktQualifier?.typeArgumentList?.toFirPsiSourceElement() ?: source).apply {
for (typeArgument in ktQualifier!!.typeArguments) {
typeArguments += typeArgument.convert<FirTypeProjection>()
}
@@ -14,6 +14,7 @@ interface FirTypeArgumentList {
}
interface FirQualifierPart {
val source: FirSourceElement
val name: Name
val typeArgumentList: FirTypeArgumentList
}
@@ -15,4 +15,8 @@ class FirTypeArgumentListImpl(override val source: FirSourceElement) : FirTypeAr
override val typeArguments = mutableListOf<FirTypeProjection>()
}
class FirQualifierPartImpl(override val name: Name, override val typeArgumentList: FirTypeArgumentList) : FirQualifierPart
class FirQualifierPartImpl(
override val source: FirSourceElement,
override val name: Name,
override val typeArgumentList: FirTypeArgumentList
) : FirQualifierPart
@@ -12,7 +12,7 @@ package foobar.a
package foobar
abstract class Foo<T>() {
abstract val x : <!TYPE_ARGUMENTS_NOT_ALLOWED!>T<Int><!>
abstract val x : T<!TYPE_ARGUMENTS_NOT_ALLOWED!><Int><!>
}
// FILE: c.kt
@@ -1,7 +1,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun <T> foo(t: <!TYPE_ARGUMENTS_NOT_ALLOWED!>T<String, Int><!>) {}
fun <T> foo(t: T<!TYPE_ARGUMENTS_NOT_ALLOWED!><String, Int><!>) {}
interface A
class B<T: A>
fun <T> foo1(t: <!TYPE_ARGUMENTS_NOT_ALLOWED!>T<B<String>><!>) {}
fun <T> foo1(t: T<!TYPE_ARGUMENTS_NOT_ALLOWED!><B<String>><!>) {}
@@ -1,14 +1,14 @@
// KT-9620 AssertionError in checkBounds
interface E1<T : <!TYPE_ARGUMENTS_NOT_ALLOWED!>D<String><!>, D>
interface E1<T : D<!TYPE_ARGUMENTS_NOT_ALLOWED!><String><!>, D>
interface A
interface B
interface D<X>
interface E2<T : <!TYPE_ARGUMENTS_NOT_ALLOWED!>D<A><!>, D<!SYNTAX!><<!><!SYNTAX!>B<!><!SYNTAX!>><!><!SYNTAX!>><!>
interface E2<T : D<!TYPE_ARGUMENTS_NOT_ALLOWED!><A><!>, D<!SYNTAX!><<!><!SYNTAX!>B<!><!SYNTAX!>><!><!SYNTAX!>><!>
// KT-11354 AE from DescriptorResolver
open class L<E>()
class M<C> : L<<!TYPE_ARGUMENTS_NOT_ALLOWED!>C<C><!>>()
class M<C> : L<C<!TYPE_ARGUMENTS_NOT_ALLOWED!><C><!>>()