IrTypes: use proper scope for type parameters in stub generation

This commit is contained in:
Dmitry Petrov
2018-05-30 15:06:35 +03:00
parent f837537cb6
commit 3a11767fae
3 changed files with 29 additions and 29 deletions
@@ -50,13 +50,6 @@ class InsertImplicitCasts(context: GeneratorContext) : IrElementTransformerVoid(
private val typeTranslator = TypeTranslator(context.moduleDescriptor, symbolTable)
private fun KotlinType.toIrType() = typeTranslator.translateType(this)
private inline fun <T> runInTypeParameterScope(typeParametersContainer: IrTypeParametersContainer, fn: () -> T): T {
typeTranslator.enterScope(typeParametersContainer)
val result = fn()
typeTranslator.leaveScope()
return result
}
override fun visitCallableReference(expression: IrCallableReference): IrExpression =
expression.transformPostfix {
transformReceiverArguments()
@@ -128,7 +121,7 @@ class InsertImplicitCasts(context: GeneratorContext) : IrElementTransformerVoid(
}
override fun visitFunction(declaration: IrFunction): IrStatement =
runInTypeParameterScope(declaration) {
typeTranslator.buildWithScope(declaration) {
declaration.transformPostfix {
valueParameters.forEach {
it.defaultValue?.coerceInnerExpression(it.descriptor.type)
@@ -137,7 +130,7 @@ class InsertImplicitCasts(context: GeneratorContext) : IrElementTransformerVoid(
}
override fun visitClass(declaration: IrClass): IrStatement =
runInTypeParameterScope(declaration) {
typeTranslator.buildWithScope(declaration) {
super.visitClass(declaration)
}