Skip to content

Commit bb3b5a7

Browse files
committed
Revert getClass changes
Move getClass back to Any. This is needed to make zio pass.
1 parent 1c34541 commit bb3b5a7

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class CommunityBuildTestA extends CommunityBuildTest:
101101
@Test def ujson = projects.ujson.run()
102102
@Test def upickle = projects.upickle.run()
103103
@Test def utest = projects.utest.run()
104-
//@Test def zio = projects.zio.run() // fails with some runtime failures of non-advancing fibers
104+
@Test def zio = projects.zio.run()
105105
end CommunityBuildTestA
106106

107107
@Category(Array(classOf[TestCategory]))

compiler/src/dotty/tools/backend/jvm/BCodeSkelBuilder.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ trait BCodeSkelBuilder extends BCodeHelpers {
716716
val rhs = dd.rhs
717717
val vparamss = dd.vparamss
718718
// the only method whose implementation is not emitted: getClass()
719-
if (dd.symbol eq defn.Matchable_getClass) { return }
719+
if (dd.symbol eq defn.Any_getClass) { return }
720720
assert(mnode == null, "GenBCode detected nested method.")
721721

722722
methSymbol = dd.symbol

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ class JSCodeGen()(using genCtx: Context) {
17311731
val Apply(fun @ Select(sup @ Super(qual, _), _), args) = tree
17321732
val sym = fun.symbol
17331733

1734-
if (sym == defn.Matchable_getClass) {
1734+
if (sym == defn.Any_getClass) {
17351735
// The only primitive that is also callable as super call
17361736
js.GetClass(genThis())
17371737
} else if (currentClassSym.isNonNativeJSClass) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,17 @@ class Definitions {
295295
@tu lazy val Matchable_isInstanceOf: TermSymbol = enterT1ParameterlessMethod(MatchableClass, nme.isInstanceOf_, _ => BooleanType, Final)
296296

297297
/** def getClass[A >: this.type](): Class[? <: A] */
298-
@tu lazy val Matchable_getClass: TermSymbol =
298+
@tu lazy val Any_getClass: TermSymbol =
299299
enterPolyMethod(
300-
MatchableClass, nme.getClass_, 1,
300+
AnyClass, nme.getClass_, 1,
301301
pt => MethodType(Nil, ClassClass.typeRef.appliedTo(TypeBounds.upper(pt.paramRefs(0)))),
302302
Final,
303-
bounds = TypeBounds.lower(MatchableClass.thisType))
303+
bounds = TypeBounds.lower(AnyClass.thisType))
304304

305-
def AnyMethods: List[TermSymbol] = List(Any_==, Any_!=, Any_equals, Any_hashCode,
305+
def AnyMethods: List[TermSymbol] = List(Any_==, Any_!=, Any_equals, Any_hashCode, Any_getClass,
306306
Any_toString, Any_##, Matchable_isInstanceOf, Any_asInstanceOf, Any_typeTest, Any_typeCast)
307307

308-
def MatchableMethods: List[TermSymbol] = List(Matchable_getClass, Matchable_isInstanceOf)
308+
def MatchableMethods: List[TermSymbol] = List(Matchable_isInstanceOf)
309309

310310
@tu lazy val MatchableMethodNames = MatchableMethods.map(_.name)
311311

@@ -443,7 +443,7 @@ class Definitions {
443443

444444
/** Methods in Object, Matchable, and Any that do not have a side effect */
445445
@tu lazy val pureMethods: List[TermSymbol] = List(Any_==, Any_!=, Any_equals, Any_hashCode,
446-
Any_toString, Any_##, Matchable_getClass, Matchable_isInstanceOf, Any_typeTest, Object_eq, Object_ne)
446+
Any_toString, Any_##, Any_getClass, Matchable_isInstanceOf, Any_typeTest, Object_eq, Object_ne)
447447

448448
@tu lazy val AnyKindClass: ClassSymbol = {
449449
val cls = newCompleteClassSymbol(ScalaPackageClass, tpnme.AnyKind, AbstractFinal | Permanent, Nil)

compiler/src/dotty/tools/dotc/transform/init/Env.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ case class Env(ctx: Context) {
2525

2626
// Methods that should be ignored in the checking
2727
lazy val ignoredMethods: Set[Symbol] = Set(
28-
defn.Matchable_getClass,
28+
defn.Any_getClass,
2929
defn.Matchable_isInstanceOf,
3030
defn.Object_eq,
3131
defn.Object_ne,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ object RefChecks {
864864
// getClass in primitive value classes is defined in the standard library as:
865865
// override def getClass(): Class[Int] = ???
866866
// However, it's not actually an override in Dotty because our Any#getClass
867-
// is polymorphic (see `Definitions#Matchable_getClass`), so since we can't change
867+
// is polymorphic (see `Definitions#Any_getClass`), so since we can't change
868868
// the standard library, we need to drop the override flag without reporting
869869
// an error.
870870
if (!(member.name == nme.getClass_ && clazz.isPrimitiveValueClass))

0 commit comments

Comments
 (0)