Skip to content

Harden IDE: Avoid ClassCastException in ThisType.cls #4381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,11 @@ object Types {
* do not survive runs whereas typerefs do.
*/
abstract case class ThisType(tref: TypeRef) extends CachedProxyType with SingletonType {
def cls(implicit ctx: Context): ClassSymbol = tref.stableInRunSymbol.asClass
def cls(implicit ctx: Context): ClassSymbol = tref.stableInRunSymbol match {
case cls: ClassSymbol => cls
case _ if ctx.mode.is(Mode.Interactive) => defn.AnyClass // was observed to happen in IDE mode
}

override def underlying(implicit ctx: Context): Type =
if (ctx.erasedTypes) tref
else cls.info match {
Expand Down