FIR deserializer: provide type-parameters for constructors

This commit is contained in:
Simon Ogorodnik
2019-04-18 18:18:10 +03:00
committed by Mikhail Glukhikh
parent 1512a6ba9a
commit aa077b42e9
53 changed files with 84 additions and 74 deletions
@@ -66,20 +66,10 @@ fun deserializeClassToSymbol(
// TODO: properties
addDeclarations(classProto.functionList.map(classDeserializer::loadFunction))
val delegatedSelfType = FirResolvedTypeRefImpl(
session,
null,
ConeClassTypeImpl(
symbol.toLookupTag(),
typeParameters.map { ConeTypeParameterTypeImpl(it.symbol, false) }.toTypedArray(),
false
),
isMarkedNullable = false,
annotations = emptyList()
)
addDeclarations(
classProto.constructorList.map {
classDeserializer.loadConstructor(it, delegatedSelfType)
classDeserializer.loadConstructor(it, this)
}
)
@@ -163,12 +163,31 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
}
}
fun loadConstructor(proto: ProtoBuf.Constructor, delegatedSelfType: FirTypeRef): FirConstructor {
fun loadConstructor(proto: ProtoBuf.Constructor, klass: FirRegularClass): FirConstructor {
val flags = proto.flags
val relativeClassName = c.relativeClassName!!
val symbol = FirFunctionSymbol(CallableId(c.packageFqName, relativeClassName, relativeClassName.shortName()))
val local = c.childContext(emptyList())
val isPrimary = !Flags.IS_SECONDARY.get(flags)
val typeParameters = klass.typeParameters.map {
FirTypeParameterImpl(c.session, null, FirTypeParameterSymbol(), it.name, Variance.INVARIANT, false).apply {
bounds.addAll(it.bounds)
}
}
val delegatedSelfType = FirResolvedTypeRefImpl(
c.session,
null,
ConeClassTypeImpl(
klass.symbol.toLookupTag(),
typeParameters.map { ConeTypeParameterTypeImpl(it.symbol, false) }.toTypedArray(),
false
),
isMarkedNullable = false,
annotations = emptyList()
)
return if (isPrimary) {
FirPrimaryConstructorImpl(
c.session,
@@ -192,6 +211,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
null
)
}.apply {
this.typeParameters += typeParameters
valueParameters += local.memberDeserializer.valueParameters(proto.valueParameterList)
annotations += getAnnotations(proto, flags, AnnotatedCallableKind.FUNCTION)
}
+2 -2
View File
@@ -49,7 +49,7 @@ public final class Array<T> : R|kotlin/Any| {
public final operator fun set(index: R|kotlin/Int|, value: R|T|): R|kotlin/Unit|
public constructor(size: R|kotlin/Int|, init: R|kotlin/Function1<kotlin/Int, T>|): R|kotlin/Array<T>|
public constructor<T>(size: R|kotlin/Int|, init: R|kotlin/Function1<kotlin/Int, T>|): R|kotlin/Array<T>|
}
@@ -446,7 +446,7 @@ public abstract class Enum<E> : R|kotlin/Comparable<E>| {
public open fun toString(): R|kotlin/String|
public constructor(name: R|kotlin/String|, ordinal: R|kotlin/Int|): R|kotlin/Enum<E>|
public constructor<E>(name: R|kotlin/String|, ordinal: R|kotlin/Int|): R|kotlin/Enum<E>|
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|kotlin/Enum.Companion|
@@ -17,15 +17,15 @@ public final annotation class Ann : R|kotlin/Annotation| {
}
public final class Generic<T> : R|kotlin/Any| {
public constructor(): R|test/Generic<T>|
public constructor<T>(): R|test/Generic<T>|
}
public final class InnerGeneric<A, B> : R|kotlin/Any| {
public constructor(): R|test/InnerGeneric<A, B>|
public constructor<A, B>(): R|test/InnerGeneric<A, B>|
public final inner class Inner<in C, D : R|A|> : R|kotlin/Any| {
public constructor(): R|test/InnerGeneric.Inner<C, D>|
public constructor<C, D : R|A|>(): R|test/InnerGeneric.Inner<C, D>|
}
@@ -1,4 +1,4 @@
public final class Wine<in T> : R|kotlin/Any| {
public constructor(): R|test/Wine<T>|
public constructor<T>(): R|test/Wine<T>|
}
@@ -1,5 +1,5 @@
public final class ConstructorTypeParamClassObjectConflict<test> : R|kotlin/Any| {
public constructor(): R|test/ConstructorTypeParamClassObjectConflict<test>|
public constructor<test>(): R|test/ConstructorTypeParamClassObjectConflict<test>|
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|test/ConstructorTypeParamClassObjectConflict.Companion|
@@ -9,7 +9,7 @@ public final class ConstructorTypeParamClassObjectConflict<test> : R|kotlin/Any|
}
public final class ConstructorTypeParamClassObjectTypeConflict<test> : R|kotlin/Any| {
public constructor(): R|test/ConstructorTypeParamClassObjectTypeConflict<test>|
public constructor<test>(): R|test/ConstructorTypeParamClassObjectTypeConflict<test>|
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|test/ConstructorTypeParamClassObjectTypeConflict.Companion|
@@ -1,4 +1,4 @@
public final class Juice<out T> : R|kotlin/Any| {
public constructor(): R|test/Juice<T>|
public constructor<T>(): R|test/Juice<T>|
}
@@ -1,4 +1,4 @@
public final class Beer<T> : R|kotlin/Any| {
public constructor(): R|test/Beer<T>|
public constructor<T>(): R|test/Beer<T>|
}
@@ -1,4 +1,4 @@
public final class ClassParamReferencesParam<A, B : R|A|> : R|kotlin/Any| {
public constructor(): R|test/ClassParamReferencesParam<A, B>|
public constructor<A, B : R|A|>(): R|test/ClassParamReferencesParam<A, B>|
}
@@ -1,4 +1,4 @@
public final class ClassParamReferencesParam<A, in B : R|A|> : R|kotlin/Any| {
public constructor(): R|test/ClassParamReferencesParam<A, B>|
public constructor<A, B : R|A|>(): R|test/ClassParamReferencesParam<A, B>|
}
@@ -1,5 +1,5 @@
public final class ClassParamReferencesSelf<A : R|test/TraitWithP<A>|> : R|kotlin/Any| {
public constructor(): R|test/ClassParamReferencesSelf<A>|
public constructor<A : R|test/TraitWithP<A>|>(): R|test/ClassParamReferencesSelf<A>|
}
@@ -1,4 +1,4 @@
public final class Clock<A : R|java/lang/Number|> : R|kotlin/Any| {
public constructor(): R|test/Clock<A>|
public constructor<A : R|java/lang/Number|>(): R|test/Clock<A>|
}
@@ -1,4 +1,4 @@
public final class Clock<A : R|java/lang/Number|, R|java/io/Serializable|> : R|kotlin/Any| {
public constructor(): R|test/Clock<A>|
public constructor<A : R|java/lang/Number|, R|java/io/Serializable|>(): R|test/Clock<A>|
}
@@ -1,4 +1,4 @@
public final class Clock<A : R|java/io/Serializable|> : R|kotlin/Any| {
public constructor(): R|test/Clock<A>|
public constructor<A : R|java/io/Serializable|>(): R|test/Clock<A>|
}
@@ -1,4 +1,4 @@
public final class ClassTwoParams<P, Q> : R|kotlin/Any| {
public constructor(): R|test/ClassTwoParams<P, Q>|
public constructor<P, Q>(): R|test/ClassTwoParams<P, Q>|
}
@@ -1,4 +1,4 @@
public final class ClassTwoParams<out P, Q> : R|kotlin/Any| {
public constructor(): R|test/ClassTwoParams<P, Q>|
public constructor<P, Q>(): R|test/ClassTwoParams<P, Q>|
}
@@ -1,5 +1,5 @@
public abstract class Aaa<P> : R|kotlin/Any| {
public constructor(): R|test/Aaa<P>|
public constructor<P>(): R|test/Aaa<P>|
}
@@ -2,7 +2,7 @@ public final class Outer : R|kotlin/Any| {
public constructor(): R|test/Outer|
public final inner class Inner<T> : R|kotlin/Any| {
public constructor(): R|test/Outer.Inner<T>|
public constructor<T>(): R|test/Outer.Inner<T>|
}
@@ -1,15 +1,15 @@
public final class Outer<E, F> : R|kotlin/Any| {
public final fun bar(x: R|test/Outer.Inner2<kotlin/String, kotlin/Double>|, y: R|test/Outer.Inner2<E, F>|): R|kotlin/Unit|
public constructor(): R|test/Outer<E, F>|
public constructor<E, F>(): R|test/Outer<E, F>|
public final inner class Inner<G, H> : R|kotlin/Any| {
public constructor(): R|test/Outer.Inner<G, H>|
public constructor<G, H>(): R|test/Outer.Inner<G, H>|
public final inner class Inner3<I> : R|kotlin/Any| {
public final fun foo(x: R|test/Outer.Inner<G, kotlin/Int, kotlin/String, F>|, y: R|test/Outer.Inner<E, kotlin/Double, E, F>|, z: R|test/Outer.Inner.Inner3<kotlin/Double, G, kotlin/Int, kotlin/String, F>|, w: R|test/Outer.Inner.Inner3<*, G, H, E, F>|): R|kotlin/Unit|
public constructor(): R|test/Outer.Inner.Inner3<I>|
public constructor<I>(): R|test/Outer.Inner.Inner3<I>|
}
@@ -2,7 +2,7 @@ public final class Outer : R|kotlin/Any| {
public constructor(): R|test/Outer|
public final class Nested<T> : R|kotlin/Any| {
public constructor(): R|test/Outer.Nested<T>|
public constructor<T>(): R|test/Outer.Nested<T>|
}
@@ -3,6 +3,6 @@ public open class JavaBeanVarOfGenericType<P> : R|kotlin/Any| {
public open fun setCharacters(p0: R|java/util/ArrayList<P>|?): R|kotlin/Unit|
public constructor(): R|test/JavaBeanVarOfGenericType<P>|
public constructor<P>(): R|test/JavaBeanVarOfGenericType<P>|
}
@@ -1,6 +1,6 @@
public final class ClassParamUsedInFun<in T> : R|kotlin/Any| {
public final fun f(t: R|T|): R|kotlin/Int|
public constructor(): R|test/ClassParamUsedInFun<T>|
public constructor<T>(): R|test/ClassParamUsedInFun<T>|
}
@@ -1,6 +1,6 @@
public final class ClassParamUsedInFun<T> : R|kotlin/Any| {
public final fun f(t: R|T|): R|kotlin/Int|
public constructor(): R|test/ClassParamUsedInFun<T>|
public constructor<T>(): R|test/ClassParamUsedInFun<T>|
}
@@ -1,7 +1,7 @@
public open class Base<T> : R|kotlin/Any| {
public final fun foo(): R|T|
public constructor(): R|test/Base<T>|
public constructor<T>(): R|test/Base<T>|
}
@@ -1,4 +1,4 @@
public final class ClassWithConstructorAndTypeParameter<P, Q> : R|kotlin/Any| {
public constructor(): R|test/ClassWithConstructorAndTypeParameter<P, Q>|
public constructor<P, Q>(): R|test/ClassWithConstructorAndTypeParameter<P, Q>|
}
@@ -1,4 +1,4 @@
public final class ClassWithConstructorAndTypeParameter<P, Q> : R|kotlin/Any| {
public constructor(q: R|kotlin/Int|): R|test/ClassWithConstructorAndTypeParameter<P, Q>|
public constructor<P, Q>(q: R|kotlin/Int|): R|test/ClassWithConstructorAndTypeParameter<P, Q>|
}
@@ -1,4 +1,4 @@
public final class ClassWithConstructorAndTypeParameter<P, Q> : R|kotlin/Any| {
public constructor(q: R|Q|): R|test/ClassWithConstructorAndTypeParameter<P, Q>|
public constructor<P, Q>(q: R|Q|): R|test/ClassWithConstructorAndTypeParameter<P, Q>|
}
@@ -1,4 +1,4 @@
public final class ClassWithConstructorAndTypeParameter<P> : R|kotlin/Any| {
public constructor(): R|test/ClassWithConstructorAndTypeParameter<P>|
public constructor<P>(): R|test/ClassWithConstructorAndTypeParameter<P>|
}
@@ -1,4 +1,4 @@
public final class OneTypeParameterErased<P, Q> : R|kotlin/Any| {
public constructor(q: R|Q|): R|test/OneTypeParameterErased<P, Q>|
public constructor<P, Q>(q: R|Q|): R|test/OneTypeParameterErased<P, Q>|
}
@@ -1,4 +1,4 @@
public final class ClassWithTypeP<P> : R|kotlin/Any| {
public constructor(): R|test/ClassWithTypeP<P>|
public constructor<P>(): R|test/ClassWithTypeP<P>|
}
@@ -1,4 +1,4 @@
public abstract class ClassWithTypePExtendsIterableP<P> : R|kotlin/collections/MutableIterable<P>| {
public constructor(): R|test/ClassWithTypePExtendsIterableP<P>|
public constructor<P>(): R|test/ClassWithTypePExtendsIterableP<P>|
}
@@ -1,4 +1,4 @@
public final class ClassWithTypePP<P, Q : R|P|> : R|kotlin/Any| {
public constructor(): R|test/ClassWithTypePP<P, Q>|
public constructor<P, Q : R|P|>(): R|test/ClassWithTypePP<P, Q>|
}
@@ -1,4 +1,4 @@
public open class ClassWithTypePRefNext<R : R|kotlin/collections/Iterable<P>|?, P> : R|kotlin/Any| {
public constructor(): R|test/ClassWithTypePRefNext<R, P>|
public constructor<R : R|kotlin/collections/Iterable<P>|?, P>(): R|test/ClassWithTypePRefNext<R, P>|
}
@@ -1,4 +1,4 @@
public final class ClassWithTypePRefSelf<P : R|kotlin/Enum<P>|> : R|kotlin/Any| {
public constructor(): R|test/ClassWithTypePRefSelf<P>|
public constructor<P : R|kotlin/Enum<P>|>(): R|test/ClassWithTypePRefSelf<P>|
}
@@ -1,4 +1,4 @@
public final class ClassWithTypePRefSelfAndClass<P : R|test/ClassWithTypePRefSelfAndClass<P>|?> : R|kotlin/Any| {
public constructor(): R|test/ClassWithTypePRefSelfAndClass<P>|
public constructor<P : R|test/ClassWithTypePRefSelfAndClass<P>|?>(): R|test/ClassWithTypePRefSelfAndClass<P>|
}
@@ -1,6 +1,6 @@
public open class MethodWithTypePRefClassP<P> : R|kotlin/Any| {
public final fun <Q : R|P|> f(): R|kotlin/Unit|
public constructor(): R|test/MethodWithTypePRefClassP<P>|
public constructor<P>(): R|test/MethodWithTypePRefClassP<P>|
}
@@ -1,4 +1,4 @@
public open class ConstructorWithNewTypeParams<T> : R|kotlin/Any| {
public constructor(first: R|kotlin/Any|): R|test/ConstructorWithNewTypeParams<T>|
public constructor<T>(first: R|kotlin/Any|): R|test/ConstructorWithNewTypeParams<T>|
}
@@ -1,4 +1,4 @@
public open class ConstructorWithParentTypeParams<T> : R|kotlin/Any| {
public constructor(first: R|T|): R|test/ConstructorWithParentTypeParams<T>|
public constructor<T>(first: R|T|): R|test/ConstructorWithParentTypeParams<T>|
}
@@ -1,4 +1,4 @@
public open class PropertyArrayTypes<T> : R|kotlin/Any| {
public constructor(): R|test/PropertyArrayTypes<T>|
public constructor<T>(): R|test/PropertyArrayTypes<T>|
}
@@ -1,4 +1,4 @@
public open class PropertyComplexTypes<T> : R|kotlin/Any| {
public constructor(): R|test/PropertyComplexTypes<T>|
public constructor<T>(): R|test/PropertyComplexTypes<T>|
}
@@ -1,18 +1,18 @@
public final class A<TA> : R|kotlin/Any| {
public constructor(): R|test/A<TA>|
public constructor<TA>(): R|test/A<TA>|
public final inner class B<TB> : R|kotlin/Any| {
public constructor(): R|test/A.B<TB>|
public constructor<TB>(): R|test/A.B<TB>|
public final inner class C<TC> : R|kotlin/Any| {
public constructor(): R|test/A.B.C<TC>|
public constructor<TC>(): R|test/A.B.C<TC>|
public final inner class D<TD> : R|kotlin/Any| {
public final fun bar(ta: R|TA|, tb: R|TB|, tc: R|TC|, td: R|TD|): R|test/A.B.C.D<TD, TC, TB, TA>|
public final fun <P1, P2, P3, P4> foo(p1: R|P1|, p2: R|P2|, p3: R|P3|, p4: R|P4|): R|kotlin/Nothing|
public constructor(): R|test/A.B.C.D<TD>|
public constructor<TD>(): R|test/A.B.C.D<TD>|
}
@@ -1,8 +1,8 @@
public final class InnerClassReferencesOuterTP<P> : R|kotlin/Any| {
public constructor(): R|test/InnerClassReferencesOuterTP<P>|
public constructor<P>(): R|test/InnerClassReferencesOuterTP<P>|
public final inner class Inner<Q : R|P|> : R|kotlin/Any| {
public constructor(): R|test/InnerClassReferencesOuterTP.Inner<Q>|
public constructor<Q : R|P|>(): R|test/InnerClassReferencesOuterTP.Inner<Q>|
}
@@ -1,5 +1,5 @@
public final class MembersReferenceOuterTP<P> : R|kotlin/Any| {
public constructor(): R|test/MembersReferenceOuterTP<P>|
public constructor<P>(): R|test/MembersReferenceOuterTP<P>|
public final inner class Inner : R|kotlin/Any| {
public final fun <Q : R|P|> f(): R|kotlin/Unit|
@@ -1,4 +1,4 @@
public final class ExtValInClass<T> : R|kotlin/Any| {
public constructor(): R|test/ExtValInClass<T>|
public constructor<T>(): R|test/ExtValInClass<T>|
}
@@ -1,4 +1,4 @@
public final class ExtValInClass<P> : R|kotlin/Any| {
public constructor(): R|test/ExtValInClass<P>|
public constructor<P>(): R|test/ExtValInClass<P>|
}
@@ -1,4 +1,4 @@
public final class ExtValPIntInClass<P> : R|kotlin/Any| {
public constructor(): R|test/ExtValPIntInClass<P>|
public constructor<P>(): R|test/ExtValPIntInClass<P>|
}
@@ -1,4 +1,4 @@
public final class ExtValInClass<P> : R|kotlin/Any| {
public constructor(): R|test/ExtValInClass<P>|
public constructor<P>(): R|test/ExtValInClass<P>|
}
@@ -1,4 +1,4 @@
public final class ExtValInClass<P> : R|kotlin/Any| {
public constructor(): R|test/ExtValInClass<P>|
public constructor<P>(): R|test/ExtValInClass<P>|
}
@@ -1,4 +1,4 @@
public final class ExtValPIntInClass<P> : R|kotlin/Any| {
public constructor(): R|test/ExtValPIntInClass<P>|
public constructor<P>(): R|test/ExtValPIntInClass<P>|
}
@@ -1,4 +1,4 @@
public final class ExtValPIntInClass<P> : R|kotlin/Any| {
public constructor(): R|test/ExtValPIntInClass<P>|
public constructor<P>(): R|test/ExtValPIntInClass<P>|
}
@@ -8,6 +8,6 @@ public final class MyProperty<T> : R|kotlin/Any| {
public final operator fun setValue(t: R|T|, p: R|kotlin/reflect/KProperty<*>|, i: R|kotlin/Int|): R|kotlin/Unit|
public constructor(): R|test/MyProperty<T>|
public constructor<T>(): R|test/MyProperty<T>|
}
@@ -1,6 +1,6 @@
public final fun <P> foo(x: R|kotlin/Function1<test/Foo<P>, kotlin/Unit>|): R|kotlin/Unit|
public final class Foo<T> : R|kotlin/Any| {
public constructor(): R|test/Foo<T>|
public constructor<T>(): R|test/Foo<T>|
}
@@ -1,6 +1,6 @@
public final class A<in I> : R|kotlin/Any| {
private/*private to this*/ final fun bas(): R|I|
public constructor(): R|test/A<I>|
public constructor<I>(): R|test/A<I>|
}