File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1809,6 +1809,13 @@ class Typer extends Namer
18091809 // check value class constraints
18101810 checkDerivedValueClass(cls, body1)
18111811
1812+ val effectiveOwner = cls.owner.skipWeakOwner
1813+ if ! cls.isRefinementClass
1814+ && ! cls.isAllOf(PrivateLocal )
1815+ && effectiveOwner.is(Trait )
1816+ && ! effectiveOwner.derivesFrom(defn.ObjectClass )
1817+ ctx.error(i " $cls cannot be defined in universal $effectiveOwner" , cdef.sourcePos)
1818+
18121819 // Temporarily set the typed class def as root tree so that we have at least some
18131820 // information in the IDE in case we never reach `SetRootTree`.
18141821 if (ctx.mode.is(Mode .Interactive ) && ctx.settings.YretainTrees .value)
Original file line number Diff line number Diff line change 1+ trait A extends Any {
2+ case class B () // error
3+ val x = {
4+ case class C () // error
5+ 1
6+ }
7+ def f = {
8+ case class C () // ok
9+ 1
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments