Match triangle & diamond intersections in FirTypeIntersectionScope
This commit is contained in:
+41
@@ -0,0 +1,41 @@
|
||||
FILE: doubleGenericDiamond.kt
|
||||
public abstract interface Left : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface Right : R|kotlin/Any| {
|
||||
}
|
||||
public final class Bottom : R|Left|, R|Right| {
|
||||
public constructor(): R|Bottom| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface A<T> : R|kotlin/Any| {
|
||||
public open fun f(): R|T?| {
|
||||
^f Null(null)
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface B<T : R|Left|> : R|A<T>| {
|
||||
public open override fun f(): R|T?| {
|
||||
^f Null(null)
|
||||
}
|
||||
|
||||
}
|
||||
public abstract class C<T> : R|A<T>| {
|
||||
public constructor<T>(): R|C<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public abstract class D<T : R|Right|> : R|C<T>| {
|
||||
public constructor<T : R|Right|>(): R|D<T>| {
|
||||
super<R|C<T>|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final class Z : R|D<Bottom>|, R|B<Bottom>| {
|
||||
public constructor(): R|Z| {
|
||||
super<R|D<Bottom>|>()
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
interface Left
|
||||
interface Right
|
||||
class Bottom : Left, Right
|
||||
|
||||
interface A<T> {
|
||||
fun f(): T? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
interface B<T : Left> : A<T> {
|
||||
override fun f(): T? {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
abstract class C<T> : A<T>
|
||||
|
||||
abstract class D<T : Right> : C<T>()
|
||||
|
||||
// We should not have intersection override f() in this class
|
||||
class Z : D<Bottom>(), B<Bottom>
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
FILE: falseIntersection.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
public open fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface B : R|A| {
|
||||
public open override fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
public final class C : R|B|, R|A| {
|
||||
public constructor(): R|C| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
interface A {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface B : A {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
// We should not have intersection override foo() in this class
|
||||
class C : B, A
|
||||
@@ -0,0 +1,160 @@
|
||||
FILE: transform.kt
|
||||
public sealed class CompositeTransformResult<out T : R|kotlin/Any|> : R|kotlin/Any| {
|
||||
protected constructor<out T : R|kotlin/Any|>(): R|CompositeTransformResult<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final class Single<out T : R|kotlin/Any|> : R|CompositeTransformResult<T>| {
|
||||
public constructor<out T : R|kotlin/Any|>(_single: R|T|): R|CompositeTransformResult.Single<T>| {
|
||||
super<R|CompositeTransformResult<T>|>()
|
||||
}
|
||||
|
||||
public final val _single: R|T| = R|<local>/_single|
|
||||
public get(): R|T|
|
||||
|
||||
}
|
||||
|
||||
public final class Multiple<out T : R|kotlin/Any|> : R|CompositeTransformResult<T>| {
|
||||
public constructor<out T : R|kotlin/Any|>(_list: R|kotlin/collections/List<T>|): R|CompositeTransformResult.Multiple<T>| {
|
||||
super<R|CompositeTransformResult<T>|>()
|
||||
}
|
||||
|
||||
public final val _list: R|kotlin/collections/List<T>| = R|<local>/_list|
|
||||
public get(): R|kotlin/collections/List<T>|
|
||||
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|CompositeTransformResult.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun <T : R|kotlin/Any|> single(t: R|T|): R|CompositeTransformResult.Single<T>| {
|
||||
^single R|SubstitutionOverride</CompositeTransformResult.Single.Single>|<R|T|>(R|<local>/t|)
|
||||
}
|
||||
|
||||
public final fun <T : R|kotlin/Any|> many(l: R|kotlin/collections/List<T>|): R|CompositeTransformResult.Multiple<T>| {
|
||||
^many R|SubstitutionOverride</CompositeTransformResult.Multiple.Multiple>|<R|T|>(R|<local>/l|)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final val single: R|T|
|
||||
public get(): R|T| {
|
||||
^ ((this@R|/CompositeTransformResult| as R|CompositeTransformResult.Single<*>|).R|SubstitutionOverride</CompositeTransformResult.Single._single: R|CapturedType(*)|>| as R|T|)
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface FirElement : R|kotlin/Any| {
|
||||
public abstract fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
public open fun accept(visitor: R|FirVisitorVoid|): R|kotlin/Unit| {
|
||||
^accept this@R|/FirElement|.R|/FirElement.accept|<R|kotlin/Unit|, R|kotlin/Nothing?|>(R|<local>/visitor|, Null(null))
|
||||
}
|
||||
|
||||
public abstract fun <E : R|FirElement|, D> transform(visitor: R|FirTransformer<D>|, data: R|D|): R|CompositeTransformResult<E>|
|
||||
|
||||
}
|
||||
public abstract class FirVisitor<out R, in D> : R|kotlin/Any| {
|
||||
public constructor<out R, in D>(): R|FirVisitor<R, D>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public abstract class FirVisitorVoid : R|FirVisitor<kotlin/Unit, kotlin/Nothing?>| {
|
||||
public constructor(): R|FirVisitorVoid| {
|
||||
super<R|FirVisitor<kotlin/Unit, kotlin/Nothing?>|>()
|
||||
}
|
||||
|
||||
}
|
||||
public abstract class FirTransformer<in D> : R|FirVisitor<CompositeTransformResult<FirElement>, D>| {
|
||||
public constructor<in D>(): R|FirTransformer<D>| {
|
||||
super<R|FirVisitor<CompositeTransformResult<FirElement>, D>|>()
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface FirAnnotationContainer : R|FirElement| {
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract interface FirStatement : R|FirAnnotationContainer| {
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract interface FirTypeParameterRefsOwner : R|FirElement| {
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract interface FirDeclaration : R|FirElement| {
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract interface FirAnnotatedDeclaration : R|FirDeclaration|, R|FirAnnotationContainer| {
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract interface FirSymbolOwner<E : R|FirSymbolOwner<E>|, R|FirDeclaration|> : R|FirElement| {
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract interface FirClassLikeDeclaration<F : R|FirClassLikeDeclaration<F>|> : R|FirAnnotatedDeclaration|, R|FirStatement|, R|FirSymbolOwner<F>| {
|
||||
}
|
||||
public abstract interface FirClass<F : R|FirClass<F>|> : R|FirClassLikeDeclaration<F>|, R|FirStatement|, R|FirTypeParameterRefsOwner| {
|
||||
}
|
||||
private final class FirApplySupertypesTransformer : R|FirTransformer<kotlin/Nothing?>| {
|
||||
public constructor(): R|FirApplySupertypesTransformer| {
|
||||
super<R|FirTransformer<kotlin/Nothing?>|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <F : R|FirClass<F>|> R|F|.runSupertypeResolvePhaseForLocalClass(): R|F| {
|
||||
lval applySupertypesTransformer: R|FirApplySupertypesTransformer| = R|/FirApplySupertypesTransformer.FirApplySupertypesTransformer|()
|
||||
^runSupertypeResolvePhaseForLocalClass this@R|/runSupertypeResolvePhaseForLocalClass|.R|SubstitutionOverride</FirClass.transform: R|CompositeTransformResult<E>|>|<R|F|, R|kotlin/Nothing?|>(R|<local>/applySupertypesTransformer|, Null(null)).R|SubstitutionOverride</CompositeTransformResult.single: R|F|>|
|
||||
}
|
||||
public abstract class FirPureAbstractElement : R|FirElement| {
|
||||
public constructor(): R|FirPureAbstractElement| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface FirTypedDeclaration : R|FirAnnotatedDeclaration| {
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract interface FirCallableDeclaration<F : R|FirCallableDeclaration<F>|> : R|FirTypedDeclaration|, R|FirSymbolOwner<F>| {
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract class FirVariable<F : R|FirVariable<F>|> : R|FirPureAbstractElement|, R|FirCallableDeclaration<F>|, R|FirAnnotatedDeclaration|, R|FirStatement| {
|
||||
public constructor<F : R|FirVariable<F>|>(): R|FirVariable<F>| {
|
||||
super<R|FirPureAbstractElement|>()
|
||||
}
|
||||
|
||||
public abstract override fun <R, D> accept(visitor: R|FirVisitor<R, D>|, data: R|D|): R|R|
|
||||
|
||||
}
|
||||
public abstract class FirWhenExpression : R|kotlin/Any| {
|
||||
public constructor(): R|FirWhenExpression| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public abstract val subjectVariable: R|FirVariable<*>?|
|
||||
public get(): R|FirVariable<*>?|
|
||||
|
||||
}
|
||||
public final class FirRenderer : R|FirVisitorVoid| {
|
||||
public constructor(): R|FirRenderer| {
|
||||
super<R|FirVisitorVoid|>()
|
||||
}
|
||||
|
||||
public final fun foo(expression: R|FirWhenExpression|): R|kotlin/Unit| {
|
||||
lval variable: R|FirVariable<*>?| = R|<local>/expression|.R|/FirWhenExpression.subjectVariable|
|
||||
when () {
|
||||
!=(R|<local>/variable|, Null(null)) -> {
|
||||
R|<local>/variable|.R|/FirElement.accept|(this@R|/FirRenderer|)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
sealed class CompositeTransformResult<out T : Any> {
|
||||
|
||||
class Single<out T : Any>(val _single: T) : CompositeTransformResult<T>()
|
||||
|
||||
class Multiple<out T : Any>(val _list: List<T>) : CompositeTransformResult<T>()
|
||||
|
||||
companion object {
|
||||
fun <T : Any> single(t: T) = Single(t)
|
||||
fun <T : Any> many(l: List<T>) = Multiple(l)
|
||||
}
|
||||
|
||||
val single: T
|
||||
get() = (this as Single<*>)._single as T
|
||||
}
|
||||
|
||||
interface FirElement {
|
||||
fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
|
||||
fun accept(visitor: FirVisitorVoid) = accept(visitor, null)
|
||||
|
||||
fun <E : FirElement, D> transform(visitor: FirTransformer<D>, data: D): CompositeTransformResult<E>
|
||||
}
|
||||
|
||||
abstract class FirVisitor<out R, in D>
|
||||
|
||||
abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>()
|
||||
|
||||
abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirElement>, D>()
|
||||
|
||||
interface FirAnnotationContainer : FirElement {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
interface FirStatement : FirAnnotationContainer {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
interface FirTypeParameterRefsOwner : FirElement {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
interface FirDeclaration : FirElement {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
interface FirAnnotatedDeclaration : FirDeclaration, FirAnnotationContainer {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
interface FirSymbolOwner<E> : FirElement where E : FirSymbolOwner<E>, E : FirDeclaration {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
interface FirClassLikeDeclaration<F : FirClassLikeDeclaration<F>> : FirAnnotatedDeclaration, FirStatement, FirSymbolOwner<F>
|
||||
|
||||
interface FirClass<F : FirClass<F>> : FirClassLikeDeclaration<F>, FirStatement, FirTypeParameterRefsOwner
|
||||
|
||||
private class FirApplySupertypesTransformer() : FirTransformer<Nothing?>()
|
||||
|
||||
fun <F : FirClass<F>> F.runSupertypeResolvePhaseForLocalClass(): F {
|
||||
val applySupertypesTransformer = FirApplySupertypesTransformer()
|
||||
return this.transform<F, Nothing?>(applySupertypesTransformer, null).single
|
||||
}
|
||||
|
||||
abstract class FirPureAbstractElement : FirElement
|
||||
|
||||
interface FirTypedDeclaration : FirAnnotatedDeclaration {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
interface FirCallableDeclaration<F : FirCallableDeclaration<F>> : FirTypedDeclaration, FirSymbolOwner<F> {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
abstract class FirVariable<F : FirVariable<F>> : FirPureAbstractElement(), FirCallableDeclaration<F>, FirAnnotatedDeclaration, FirStatement {
|
||||
abstract override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R
|
||||
}
|
||||
|
||||
abstract class FirWhenExpression {
|
||||
abstract val subjectVariable: FirVariable<*>?
|
||||
}
|
||||
|
||||
class FirRenderer : FirVisitorVoid() {
|
||||
fun foo(expression: FirWhenExpression) {
|
||||
val variable = expression.subjectVariable
|
||||
if (variable != null) {
|
||||
variable.accept(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -23,7 +23,7 @@ FILE: Test.kt
|
||||
}
|
||||
|
||||
public final fun test(): R|kotlin/String| {
|
||||
^test this@R|/LightClassWrapper|.R|/LightClassWrapper.typeParameters|.R|/single|()
|
||||
^test this@R|/LightClassWrapper|.R|/Light.typeParameters|.R|/single|()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -47,7 +47,7 @@ FILE: Test.kt
|
||||
public final fun test(other: R|kotlin/Any?|): R|kotlin/Unit| {
|
||||
when () {
|
||||
(R|<local>/other| is R|LightField<*>|) -> {
|
||||
R|<local>/other|.R|/LightField.name|
|
||||
R|<local>/other|.R|/LightMember.name|
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user