Skip to content

Commit 9b491c1

Browse files
committed
Make sure typer is a Typer
The previous cast can fail if applyOverloaded is used outside a compilation run. This can happen in the IDE, when annotations are forced. Reconstructing applications from Scala2 pickles calls applyOverloaded.
1 parent fccb010 commit 9b491c1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ object Contexts {
131131
private[this] var _typeAssigner: TypeAssigner = _
132132
protected def typeAssigner_=(typeAssigner: TypeAssigner) = _typeAssigner = typeAssigner
133133
def typeAssigner: TypeAssigner = _typeAssigner
134-
def typer: Typer = _typeAssigner.asInstanceOf[Typer]
135134

136135
/** The currently active import info */
137136
private[this] var _importInfo: ImportInfo = _

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ import reporting.diagnostic.messages._
2727
trait NamerContextOps { this: Context =>
2828
import NamerContextOps._
2929

30+
def typer = ctx.typeAssigner match {
31+
case typer: Typer => typer
32+
case _ => new Typer
33+
}
34+
3035
/** Enter symbol into current class, if current class is owner of current context,
3136
* or into current scope, if not. Should always be called instead of scope.enter
3237
* in order to make sure that updates to class members are reflected in

0 commit comments

Comments
 (0)