Skip to content

Commit d27a210

Browse files
committed
Start new name allocation scope when moving into function calls as
sibling function calls can reuse the same names. Fixes #250
1 parent 561ffbe commit d27a210

File tree

3 files changed

+2
-44
lines changed

3 files changed

+2
-44
lines changed

kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/ArgNameAllocator.kt

Lines changed: 0 additions & 14 deletions
This file was deleted.

kotlin-inject-compiler/core/src/main/kotlin/me/tatarka/inject/compiler/TypeResultResolver.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ class TypeResultResolver(private val provider: AstProvider, private val options:
451451
result: (context: Context) -> TypeResultRef,
452452
): TypeResult {
453453
cycleDetector.delayedConstruction()
454+
val context = context.copyNameAllocator()
454455
val namedArgs = args.mapIndexed { i, arg ->
455456
arg to context.nameAllocator.newName("arg$i")
456457
}
@@ -463,6 +464,7 @@ class TypeResultResolver(private val provider: AstProvider, private val options:
463464
key: TypeKey,
464465
args: List<AstType>,
465466
) = withCycleDetection(key, function) {
467+
val context = context.copyNameAllocator()
466468
// Drop receiver from args
467469
val namedArgs = if (function.receiverParameterType != null) {
468470
args.drop(1)

kotlin-inject-compiler/core/src/test/kotlin/me/tatarka/inject/compiler/ArgNameAllocatorTest.kt

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)