Skip to content

Commit b2f0791

Browse files
committed
Make Singleton an erased class only under modularity import
1 parent d3e6a95 commit b2f0791

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import Names.{Name, TermName}
88
import Constants.Constant
99

1010
import Names.Name
11+
import config.Feature
1112

1213
class TypeUtils:
1314
/** A decorator that provides methods on types
@@ -22,7 +23,11 @@ class TypeUtils:
2223
self.classSymbol.isPrimitiveValueClass
2324

2425
def isErasedClass(using Context): Boolean =
25-
self.underlyingClassRef(refinementOK = true).typeSymbol.is(Flags.Erased)
26+
val cls = self.underlyingClassRef(refinementOK = true).typeSymbol
27+
cls.is(Flags.Erased)
28+
&& (cls != defn.SingletonClass || Feature.enabled(Feature.modularity))
29+
// Singleton counts as an erased class only under x.modularity
30+
2631

2732
/** Is this type a checked exception? This is the case if the type
2833
* derives from Exception but not from RuntimeException. According to
@@ -179,7 +184,7 @@ class TypeUtils:
179184
def isThisTypeOf(cls: Symbol)(using Context) = self match
180185
case self: Types.ThisType => self.cls == cls
181186
case _ => false
182-
187+
183188
/** Strip all outer refinements off this type */
184189
def stripRefinement: Type = self match
185190
case self: RefinedOrRecType => self.parent.stripRefinement

0 commit comments

Comments
 (0)