diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 402e0d6d7e14..032cc6bb4417 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -428,6 +428,11 @@ object desugar { } else originalTparams + if mods.is(Trait) then + for vparams <- originalVparamss; vparam <- vparams do + if vparam.tpt.isInstanceOf[ByNameTypeTree] then + report.error(em"implementation restriction: traits cannot have by name parameters", vparam.srcPos) + // Annotations on class _type_ parameters are set on the derived parameters // but not on the constructor parameters. The reverse is true for // annotations on class _value_ parameters. diff --git a/tests/neg/i9886.scala b/tests/neg/i9886.scala new file mode 100644 index 000000000000..765bd389826c --- /dev/null +++ b/tests/neg/i9886.scala @@ -0,0 +1,2 @@ +trait D(l: => Any): // error + def f = l