FIR supertype resolve: generate error types for type parameters
This commit is contained in:
+9
-5
@@ -11,10 +11,7 @@ import org.jetbrains.kotlin.fir.expressions.FirStatement
|
|||||||
import org.jetbrains.kotlin.fir.render
|
import org.jetbrains.kotlin.fir.render
|
||||||
import org.jetbrains.kotlin.fir.resolve.*
|
import org.jetbrains.kotlin.fir.resolve.*
|
||||||
import org.jetbrains.kotlin.fir.scopes.addImportingScopes
|
import org.jetbrains.kotlin.fir.scopes.addImportingScopes
|
||||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
import org.jetbrains.kotlin.fir.types.*
|
||||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
|
||||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
|
||||||
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
import org.jetbrains.kotlin.fir.types.impl.FirErrorTypeRefImpl
|
||||||
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
import org.jetbrains.kotlin.fir.visitors.CompositeTransformResult
|
||||||
import org.jetbrains.kotlin.fir.visitors.compose
|
import org.jetbrains.kotlin.fir.visitors.compose
|
||||||
@@ -162,7 +159,14 @@ class FirSupertypeResolverTransformer : FirAbstractTreeTransformer(phase = FirRe
|
|||||||
|
|
||||||
val resultingTypeRefs = mutableListOf<FirTypeRef>()
|
val resultingTypeRefs = mutableListOf<FirTypeRef>()
|
||||||
for (superTypeRef in resolvedTypesRefs) {
|
for (superTypeRef in resolvedTypesRefs) {
|
||||||
val resolvedType = superTypeRef.coneTypeSafe<ConeClassLikeType>() ?: continue
|
val coneType = (superTypeRef as FirResolvedTypeRef).type
|
||||||
|
if (coneType is ConeTypeParameterType) {
|
||||||
|
resultingTypeRefs.add(
|
||||||
|
FirErrorTypeRefImpl(superTypeRef.psi, "Type parameter cannot be a super-type: ${coneType.render()}")
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
val resolvedType = coneType as ConeClassLikeType
|
||||||
val superTypeClassId = resolvedType.lookupTag.classId
|
val superTypeClassId = resolvedType.lookupTag.classId
|
||||||
|
|
||||||
if (superTypeClassId.outerClasses().any { it.areSupertypesComputing() }) {
|
if (superTypeClassId.outerClasses().any { it.areSupertypesComputing() }) {
|
||||||
|
|||||||
@@ -14,4 +14,6 @@ abstract class My<T : Some> {
|
|||||||
abstract val z: test.My.T
|
abstract val z: test.My.T
|
||||||
|
|
||||||
class Some : T()
|
class Some : T()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
abstract class Your<T : Some> : T
|
||||||
@@ -24,7 +24,7 @@ FILE: typeParameterVsNested.kt
|
|||||||
public abstract val z: R|test/My.T|
|
public abstract val z: R|test/My.T|
|
||||||
public get(): R|test/My.T|
|
public get(): R|test/My.T|
|
||||||
|
|
||||||
public final class Some : R|test/My.T| {
|
public final class Some : R|class error: Type parameter cannot be a super-type: T| {
|
||||||
public constructor(): R|test/My.Some| {
|
public constructor(): R|test/My.Some| {
|
||||||
super<R|T|>()
|
super<R|T|>()
|
||||||
}
|
}
|
||||||
@@ -32,3 +32,9 @@ FILE: typeParameterVsNested.kt
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public abstract class Your<T : R|test/Some|> : R|class error: Type parameter cannot be a super-type: T| {
|
||||||
|
public constructor<T : R|test/Some|>(): R|test/Your<T>| {
|
||||||
|
super<R|kotlin/Any|>()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user