FIR: load default value from meta-data

This commit is contained in:
Simon Ogorodnik
2019-04-18 18:17:33 +03:00
committed by Mikhail Glukhikh
parent 879563233a
commit 9352d52e7e
16 changed files with 30 additions and 20 deletions
@@ -7,23 +7,25 @@ package org.jetbrains.kotlin.fir.deserialization
import org.jetbrains.kotlin.descriptors.annotations.Annotations
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.declarations.FirConstructor
import org.jetbrains.kotlin.fir.declarations.FirNamedFunction
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.impl.*
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.expressions.impl.FirExpressionStub
import org.jetbrains.kotlin.fir.resolve.transformers.firUnsafe
import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.impl.ConeClassTypeImpl
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.*
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.protobuf.MessageLite
import org.jetbrains.kotlin.serialization.deserialization.AnnotatedCallableKind
import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
@@ -196,6 +198,13 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
}
private fun defaultValue(flags: Int): FirExpression? {
if (Flags.DECLARES_DEFAULT_VALUE.get(flags)) {
return FirExpressionStub(c.session, null)
}
return null
}
private fun valueParameters(
valueParameters: List<ProtoBuf.ValueParameter>
): List<FirValueParameter> {
@@ -204,7 +213,7 @@ class FirMemberDeserializer(private val c: FirDeserializationContext) {
FirValueParameterImpl(
c.session, null, c.nameResolver.getName(proto.name),
c.typeDeserializer.type(proto.type(c.typeTable)).toTypeRef(),
null, // TODO: default value
defaultValue(flags),
Flags.IS_CROSSINLINE.get(flags),
Flags.IS_NOINLINE.get(flags),
proto.varargElementType(c.typeTable) != null
+1 -1
View File
@@ -292,7 +292,7 @@ public abstract interface Comparable<in T> : R|kotlin/Any| {
}
public final annotation class Deprecated : R|kotlin/Annotation| {
public constructor(message: R|kotlin/String|, replaceWith: R|kotlin/ReplaceWith|, level: R|kotlin/DeprecationLevel|): R|kotlin/Deprecated|
public constructor(message: R|kotlin/String|, replaceWith: R|kotlin/ReplaceWith| = STUB, level: R|kotlin/DeprecationLevel| = STUB): R|kotlin/Deprecated|
}
@@ -1,5 +1,5 @@
public final annotation class Anno : R|kotlin/Annotation| {
public constructor(value: R|kotlin/String|, x: R|kotlin/Int|): R|test/Anno|
public constructor(value: R|kotlin/String| = STUB, x: R|kotlin/Int| = STUB): R|test/Anno|
}
@@ -1,7 +1,7 @@
public final data class My : R|kotlin/Any| {
public final operator fun component1(): R|kotlin/Int|
public final fun copy(x: R|kotlin/Int|): R|test/My|
public final fun copy(x: R|kotlin/Int| = STUB): R|test/My|
public open operator fun equals(other: R|kotlin/Any|?): R|kotlin/Boolean|
@@ -1,4 +1,4 @@
public final class ClassWithConstructorWithValueParamWithDefaultValue : R|kotlin/Any| {
public constructor(p: R|kotlin/Int|): R|test/ClassWithConstructorWithValueParamWithDefaultValue|
public constructor(p: R|kotlin/Int| = STUB): R|test/ClassWithConstructorWithValueParamWithDefaultValue|
}
@@ -1,4 +1,4 @@
public final class TestConstructor : R|kotlin/Any| {
public constructor(p: R|kotlin/Int|, s: R|kotlin/Int|): R|test/TestConstructor|
public constructor(p: R|kotlin/Int| = STUB, s: R|kotlin/Int|): R|test/TestConstructor|
}
@@ -1,4 +1,4 @@
public final class TestConstructor : R|kotlin/Any| {
public constructor(p: R|kotlin/Int|, d: R|kotlin/Int|): R|test/TestConstructor|
public constructor(p: R|kotlin/Int| = STUB, d: R|kotlin/Int| = STUB): R|test/TestConstructor|
}
@@ -2,7 +2,7 @@ public final class A : R|kotlin/Any| {
public constructor(): R|test/A|
public final class TestConstructor : R|kotlin/Any| {
public constructor(p: R|kotlin/Int|): R|test/A.TestConstructor|
public constructor(p: R|kotlin/Int| = STUB): R|test/A.TestConstructor|
}
@@ -1,4 +1,4 @@
public final class TestConstructor : R|kotlin/Any| {
private constructor(p: R|kotlin/Int|): R|test/TestConstructor|
private constructor(p: R|kotlin/Int| = STUB): R|test/TestConstructor|
}
@@ -3,7 +3,7 @@ public final data class DataClass : R|kotlin/Any| {
public final operator fun component2(): R|kotlin/Double|
public final fun copy(x: R|kotlin/String|, z: R|kotlin/Double|): R|test/DataClass|
public final fun copy(x: R|kotlin/String| = STUB, z: R|kotlin/Double| = STUB): R|test/DataClass|
public open operator fun equals(other: R|kotlin/Any|?): R|kotlin/Boolean|
@@ -1,7 +1,7 @@
public final data class DataClass : R|kotlin/Any| {
public final operator fun component1(): R|kotlin/String|
public final fun copy(x: R|kotlin/String|): R|test/DataClass|
public final fun copy(x: R|kotlin/String| = STUB): R|test/DataClass|
public open operator fun equals(other: R|kotlin/Any|?): R|kotlin/Boolean|
@@ -3,7 +3,7 @@ public final data class DataClass : R|kotlin/Any| {
public final operator fun component2(): R|kotlin/Int|
public final fun copy(x: R|kotlin/String|, y: R|kotlin/Int|): R|test/DataClass|
public final fun copy(x: R|kotlin/String| = STUB, y: R|kotlin/Int| = STUB): R|test/DataClass|
public open operator fun equals(other: R|kotlin/Any|?): R|kotlin/Boolean|
@@ -3,7 +3,7 @@ public final data class DataClass : R|kotlin/Any| {
public final operator fun component2(): R|kotlin/Int|
public final fun copy(x: R|kotlin/String|, y: R|kotlin/Int|): R|test/DataClass|
public final fun copy(x: R|kotlin/String| = STUB, y: R|kotlin/Int| = STUB): R|test/DataClass|
public open operator fun equals(other: R|kotlin/Any|?): R|kotlin/Boolean|
@@ -1,4 +1,4 @@
public final enum class En : R|kotlin/Enum<test/En>| {
private constructor(b: R|kotlin/Boolean|, i: R|kotlin/Int|): R|test/En|
private constructor(b: R|kotlin/Boolean| = STUB, i: R|kotlin/Int| = STUB): R|test/En|
}
@@ -1 +1,2 @@
public final fun funDefaultArg(p: R|kotlin/Int|, q: R|kotlin/Int|, r: R|kotlin/Int|): R|kotlin/Int|
public final fun funDefaultArg(p: R|kotlin/Int|, q: R|kotlin/Int| = STUB, r: R|kotlin/Int| = STUB): R|kotlin/Int|
@@ -1,4 +1,4 @@
public final annotation class Ann : R|kotlin/Annotation| {
public constructor(value: R|kotlin/String|): R|test/Ann|
public constructor(value: R|kotlin/String| = STUB): R|test/Ann|
}