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 =>
270
270
parents = impl.parents.map(p => TypeTree (p.tpe).withSpan(p.span)),
271
271
body =
272
272
if (cls.is(Trait )) traitDefs(impl.body)
273
- else {
273
+ else if ( ! cls.isPrimitiveValueClass) {
274
274
val mixInits = mixins.flatMap { mixin =>
275
275
flatten(traitInits(mixin)) ::: superCallOpt(mixin) ::: setters(mixin) ::: mixinForwarders(mixin)
276
276
}
277
277
superCallOpt(superCls) ::: mixInits ::: impl.body
278
- })
278
+ }
279
+ else impl.body)
279
280
}
280
281
}
Original file line number Diff line number Diff line change @@ -86,7 +86,7 @@ class FrontEnd extends Phase {
86
86
}
87
87
88
88
protected def discardAfterTyper (unit : CompilationUnit )(implicit ctx : Context ): Boolean =
89
- unit.isJava || firstTopLevelDef(unit.tpdTree :: Nil ).isPrimitiveValueClass
89
+ unit.isJava
90
90
91
91
override def runOn (units : List [CompilationUnit ])(implicit ctx : Context ): List [CompilationUnit ] = {
92
92
val unitContexts = for (unit <- units) yield {
Original file line number Diff line number Diff line change @@ -790,7 +790,14 @@ object RefChecks {
790
790
case Nil =>
791
791
ctx.error(OverridesNothing (member), member.sourcePos)
792
792
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)
794
801
}
795
802
member.resetFlag(Override )
796
803
member.resetFlag(AbsOverride )
You can’t perform that action at this time.
0 commit comments