Skip to content

Commit 7ba0d43

Browse files
authored
Merge pull request #4381 from dotty-staging/harden-ide-10
Harden IDE: Avoid ClassCastException in ThisType.cls
2 parents c8030ef + f2b432e commit 7ba0d43

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

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

+5-1
Original file line numberDiff line numberDiff line change
@@ -2177,7 +2177,11 @@ object Types {
21772177
* do not survive runs whereas typerefs do.
21782178
*/
21792179
abstract case class ThisType(tref: TypeRef) extends CachedProxyType with SingletonType {
2180-
def cls(implicit ctx: Context): ClassSymbol = tref.stableInRunSymbol.asClass
2180+
def cls(implicit ctx: Context): ClassSymbol = tref.stableInRunSymbol match {
2181+
case cls: ClassSymbol => cls
2182+
case _ if ctx.mode.is(Mode.Interactive) => defn.AnyClass // was observed to happen in IDE mode
2183+
}
2184+
21812185
override def underlying(implicit ctx: Context): Type =
21822186
if (ctx.erasedTypes) tref
21832187
else cls.info match {

0 commit comments

Comments
 (0)