FIR: Make replace function accepting parameter with nullability as-is

This commit is contained in:
Denis Zharkov
2020-02-03 20:23:27 +03:00
parent 23e9a0c861
commit c3e900b945
6 changed files with 7 additions and 9 deletions
@@ -42,7 +42,7 @@ abstract class FirAnonymousFunction : FirPureAbstractElement(), FirFunction<FirA
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitAnonymousFunction(this, data)
abstract fun replaceInvocationKind(newInvocationKind: InvocationKind)
abstract fun replaceInvocationKind(newInvocationKind: InvocationKind?)
abstract override fun <D> transformReturnTypeRef(transformer: FirTransformer<D>, data: D): FirAnonymousFunction
@@ -107,7 +107,7 @@ class FirAnonymousFunctionImpl(
typeRef = newTypeRef
}
override fun replaceInvocationKind(newInvocationKind: InvocationKind) {
override fun replaceInvocationKind(newInvocationKind: InvocationKind?) {
invocationKind = newInvocationKind
}
}
@@ -21,5 +21,5 @@ abstract class FirThisReference : FirReference() {
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitThisReference(this, data)
abstract fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>)
abstract fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>?)
}
@@ -27,7 +27,7 @@ class FirExplicitThisReference(
return this
}
override fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>) {
override fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>?) {
boundSymbol = newBoundSymbol
}
}
@@ -27,5 +27,5 @@ class FirImplicitThisReference(
return this
}
override fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>) {}
override fun replaceBoundSymbol(newBoundSymbol: AbstractFirBasedSymbol<*>?) {}
}
@@ -67,7 +67,7 @@ fun transformFunctionDeclaration(transformName: String, returnType: String): Str
fun Field.replaceFunctionDeclaration(): String {
val capName = name.capitalize()
return "fun replace$capName(new$capName: $typeWithArgumentsWithoutNullablity)"
return "fun replace$capName(new$capName: $typeWithArguments)"
}
val Field.mutableType: String
@@ -107,8 +107,6 @@ val Importable.typeWithArguments: String
else -> throw IllegalArgumentException()
}
val Importable.typeWithArgumentsWithoutNullablity: String get() = typeWithArguments.dropLastWhile { it == '?' }
val ImplementationWithArg.generics: String
get() = argument?.let { "<${it.type}>" } ?: ""
@@ -128,4 +126,4 @@ val Element.typeParameters: String
?: ""
val Type.generics: String
get() = arguments.takeIf { it.isNotEmpty() }?.joinToString(",", "<", ">") ?: ""
get() = arguments.takeIf { it.isNotEmpty() }?.joinToString(",", "<", ">") ?: ""