File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -1810,6 +1810,10 @@ class Typer extends Namer
1810
1810
// check value class constraints
1811
1811
checkDerivedValueClass(cls, body1)
1812
1812
1813
+ val effectiveOwner = cls.owner.skipWeakOwner
1814
+ if ! cls.isRefinementClass && effectiveOwner.is(Trait ) && ! effectiveOwner.derivesFrom(defn.ObjectClass )
1815
+ ctx.error(i " class $cls cannot be defined in universal $effectiveOwner" , cdef.sourcePos)
1816
+
1813
1817
// Temporarily set the typed class def as root tree so that we have at least some
1814
1818
// information in the IDE in case we never reach `SetRootTree`.
1815
1819
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