Skip to content

Commit 6a95fef

Browse files
authored
Merge pull request #1904 from dotty-staging/fix-npe-implicits
Fix another NPE when compiling under -Yno-imports
2 parents 2c229a6 + dc32420 commit 6a95fef

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

compiler/src/dotty/tools/dotc/typer/Implicits.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -176,15 +176,17 @@ object Implicits {
176176
if (monitored) record(s"elided eligible refs", elided(this))
177177
eligibles
178178
case None =>
179-
val savedEphemeral = ctx.typerState.ephemeral
180-
ctx.typerState.ephemeral = false
181-
try {
182-
val result = computeEligible(tp)
183-
if (ctx.typerState.ephemeral) record("ephemeral cache miss: eligible")
184-
else eligibleCache(tp) = result
185-
result
179+
if (ctx eq NoContext) Nil
180+
else {
181+
val savedEphemeral = ctx.typerState.ephemeral
182+
ctx.typerState.ephemeral = false
183+
try {
184+
val result = computeEligible(tp)
185+
if (ctx.typerState.ephemeral) record("ephemeral cache miss: eligible")
186+
else eligibleCache(tp) = result
187+
result
188+
} finally ctx.typerState.ephemeral |= savedEphemeral
186189
}
187-
finally ctx.typerState.ephemeral |= savedEphemeral
188190
}
189191
}
190192

0 commit comments

Comments
 (0)