File tree Expand file tree Collapse file tree 3 files changed +12
-4
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -270,11 +270,12 @@ class Mixin extends MiniPhase with SymTransformer { thisPhase =>
270270 parents = impl.parents.map(p => TypeTree (p.tpe).withSpan(p.span)),
271271 body =
272272 if (cls.is(Trait )) traitDefs(impl.body)
273- else {
273+ else if ( ! cls.isPrimitiveValueClass) {
274274 val mixInits = mixins.flatMap { mixin =>
275275 flatten(traitInits(mixin)) ::: superCallOpt(mixin) ::: setters(mixin) ::: mixinForwarders(mixin)
276276 }
277277 superCallOpt(superCls) ::: mixInits ::: impl.body
278- })
278+ }
279+ else impl.body)
279280 }
280281}
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class FrontEnd extends Phase {
8686 }
8787
8888 protected def discardAfterTyper (unit : CompilationUnit )(implicit ctx : Context ): Boolean =
89- unit.isJava || firstTopLevelDef(unit.tpdTree :: Nil ).isPrimitiveValueClass
89+ unit.isJava
9090
9191 override def runOn (units : List [CompilationUnit ])(implicit ctx : Context ): List [CompilationUnit ] = {
9292 val unitContexts = for (unit <- units) yield {
Original file line number Diff line number Diff line change @@ -790,7 +790,14 @@ object RefChecks {
790790 case Nil =>
791791 ctx.error(OverridesNothing (member), member.sourcePos)
792792 case ms =>
793- ctx.error(OverridesNothingButNameExists (member, ms), member.sourcePos)
793+ // getClass in primitive value classes is defined in the standard library as:
794+ // override def getClass(): Class[Int] = ???
795+ // However, it's not actually an override in Dotty because our Any#getClass
796+ // is polymorphic (see `Definitions#Any_getClass`), so since we can't change
797+ // the standard library, we need to drop the override flag without reporting
798+ // an error.
799+ if (! (member.name == nme.getClass_ && clazz.isPrimitiveValueClass))
800+ ctx.error(OverridesNothingButNameExists (member, ms), member.sourcePos)
794801 }
795802 member.resetFlag(Override )
796803 member.resetFlag(AbsOverride )
You can’t perform that action at this time.
0 commit comments