File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
compiler/src/dotty/tools/dotc/ast Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -431,11 +431,18 @@ object desugar {
431
431
// For all other classes, the parent is AnyRef.
432
432
val companions =
433
433
if (isCaseClass) {
434
+ def extractType (t : Tree ): Tree = t match {
435
+ case Apply (t1, _) => extractType(t1)
436
+ case TypeApply (t1, ts) => AppliedTypeTree (extractType(t1), ts)
437
+ case Select (t1, nme.CONSTRUCTOR ) => extractType(t1)
438
+ case New (t1) => t1
439
+ case t1 => t1
440
+ }
434
441
// The return type of the `apply` method
435
442
val applyResultTpt =
436
443
if (isEnumCase)
437
444
if (parents.isEmpty) enumClassTypeRef
438
- else parents.reduceLeft(AndTypeTree )
445
+ else parents.map(extractType). reduceLeft(AndTypeTree )
439
446
else TypeTree ()
440
447
441
448
val parent =
Original file line number Diff line number Diff line change
1
+ object Foo extends (Int => Int ) { // OK
2
+ def apply (x : Int ) = x
3
+ }
4
+
5
+ enum class E (x : Int ) // used to generate Int => new E(x) as the parent of object E --> crash
6
+ object E {
7
+ case C (x : Int ) extends E (x)
8
+ }
You can’t perform that action at this time.
0 commit comments