[FIR] Introduce TYPE_ARGUMENTS_NOT_ALLOWED & some other type errors
This commit introduces several different things, in particular: - check type arguments in expressions - new TypeArgumentList node to deal with diagnostic source - ConeDiagnostic was moved to fir:cones - ConeIntermediateDiagnostic to use in inference (?) without reporting - detailed diagnostics on error type
This commit is contained in:
@@ -24,7 +24,7 @@ internal class FirErrorTypeRefImpl(
|
||||
override val diagnostic: ConeDiagnostic,
|
||||
) : FirErrorTypeRef() {
|
||||
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
|
||||
override val type: ConeKotlinType = ConeClassErrorType(diagnostic.reason)
|
||||
override val type: ConeKotlinType = ConeClassErrorType(diagnostic)
|
||||
override val delegatedTypeRef: FirTypeRef? get() = null
|
||||
override val isSuspend: Boolean = false
|
||||
|
||||
|
||||
@@ -871,9 +871,9 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
||||
print(".")
|
||||
}
|
||||
print(qualifier.name)
|
||||
if (qualifier.typeArguments.isNotEmpty()) {
|
||||
if (qualifier.typeArgumentList.typeArguments.isNotEmpty()) {
|
||||
print("<")
|
||||
qualifier.typeArguments.renderSeparated()
|
||||
qualifier.typeArgumentList.typeArguments.renderSeparated()
|
||||
print(">")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.fir.diagnostics
|
||||
|
||||
class ConeUnexpectedTypeArgumentsError(override val reason: String, val source: Any? = null) : ConeDiagnostic()
|
||||
|
||||
class ConeIntermediateDiagnostic(override val reason: String) : ConeDiagnostic()
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.fir.diagnostics
|
||||
|
||||
abstract class ConeDiagnostic {
|
||||
abstract val reason: String
|
||||
}
|
||||
|
||||
class ConeStubDiagnostic(val original: ConeDiagnostic) : ConeDiagnostic() {
|
||||
override val reason: String get() = original.reason
|
||||
}
|
||||
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.declarations.FirVariable
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
|
||||
@@ -5,9 +5,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.types
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
interface FirTypeArgumentList {
|
||||
val source: FirSourceElement
|
||||
val typeArguments: List<FirTypeProjection>
|
||||
}
|
||||
|
||||
interface FirQualifierPart {
|
||||
val name: Name
|
||||
val typeArguments: List<FirTypeProjection>
|
||||
val typeArgumentList: FirTypeArgumentList
|
||||
}
|
||||
@@ -5,10 +5,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.types.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.types.FirQualifierPart
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeArgumentList
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeProjection
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirQualifierPartImpl(override val name: Name) : FirQualifierPart {
|
||||
class FirTypeArgumentListImpl(override val source: FirSourceElement) : FirTypeArgumentList {
|
||||
override val typeArguments = mutableListOf<FirTypeProjection>()
|
||||
}
|
||||
}
|
||||
|
||||
class FirQualifierPartImpl(override val name: Name, override val typeArgumentList: FirTypeArgumentList) : FirQualifierPart
|
||||
@@ -24,14 +24,14 @@ open class FirUserTypeRefImpl(
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
for (part in qualifier) {
|
||||
part.typeArguments.forEach { it.accept(visitor, data) }
|
||||
part.typeArgumentList.typeArguments.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirUserTypeRefImpl {
|
||||
for (part in qualifier) {
|
||||
(part.typeArguments as MutableList<FirTypeProjection>).transformInplace(transformer, data)
|
||||
(part.typeArgumentList.typeArguments as MutableList<FirTypeProjection>).transformInplace(transformer, data)
|
||||
}
|
||||
transformAnnotations(transformer, data)
|
||||
return this
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
}
|
||||
|
||||
val errorTypeRefImpl = impl(errorTypeRef) {
|
||||
default("type", "ConeClassErrorType(diagnostic.reason)")
|
||||
default("type", "ConeClassErrorType(diagnostic)")
|
||||
default("delegatedTypeRef") {
|
||||
value = "null"
|
||||
withGetter = true
|
||||
|
||||
Reference in New Issue
Block a user