File tree Expand file tree Collapse file tree 3 files changed +13
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -291,9 +291,11 @@ trait Deriving {
291291 companionRef(tp.underlying)
292292 }
293293 val resultType = instantiated(sym.info)
294- val module = untpd.ref(companionRef(resultType)).withSpan(sym.span)
294+ val companion = companionRef(resultType)
295+ val module = untpd.ref(companion).withSpan(sym.span)
295296 val rhs = untpd.Select (module, nme.derived)
296- typed(rhs, resultType)
297+ if companion.termSymbol.exists then typed(rhs, resultType)
298+ else errorTree(rhs, em " $resultType cannot be derived since ${resultType.typeSymbol} has no companion object " )
297299 end typeclassInstance
298300
299301 def syntheticDef (sym : Symbol ): Tree = inContext(ctx.fresh.setOwner(sym).setNewScope) {
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg/i11072.scala:3:17 ----------------------------------------------------------------------------------
2+ 3 |enum Foo derives Sealed { // error
3+ | ^
4+ | Sealed[Foo] cannot be derived since trait Sealed has no companion object
Original file line number Diff line number Diff line change 1+ trait Sealed [A ]
2+
3+ enum Foo derives Sealed { // error
4+ case A , B , C
5+ }
You can’t perform that action at this time.
0 commit comments