Skip to content

Commit eb92d6b

Browse files
authored
Merge pull request #10324 from dotty-staging/workaround-$9886
Fix #9886: Disallow by-name trait parameters
2 parents c1da280 + d0c27ff commit eb92d6b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ object desugar {
423423
}
424424
else originalTparams
425425

426+
if mods.is(Trait) then
427+
for vparams <- originalVparamss; vparam <- vparams do
428+
if vparam.tpt.isInstanceOf[ByNameTypeTree] then
429+
report.error(em"implementation restriction: traits cannot have by name parameters", vparam.srcPos)
430+
426431
// Annotations on class _type_ parameters are set on the derived parameters
427432
// but not on the constructor parameters. The reverse is true for
428433
// annotations on class _value_ parameters.

tests/neg/i9886.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trait D(l: => Any): // error
2+
def f = l

0 commit comments

Comments
 (0)