Skip to content

Commit 63f7dba

Browse files
committed
Fix handling of by-name default getters
There was an omission before, but as long as byname parameters were ExprTypes it did not lead to problems.
1 parent 8fe40ca commit 63f7dba

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ class Namer { typer: Typer =>
16561656
ctx.defContext(sym).denotNamed(original)
16571657
def paramProto(paramss: List[List[Type]], idx: Int): Type = paramss match {
16581658
case params :: paramss1 =>
1659-
if (idx < params.length) params(idx)
1659+
if (idx < params.length) params(idx).widenByName
16601660
else paramProto(paramss1, idx - params.length)
16611661
case nil =>
16621662
NoType

tests/pos/byname-default.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Extraction of a failing case in scalaSTM
2+
object Test:
3+
4+
def apply[A](init: => A = null.asInstanceOf[A]) = init
5+

0 commit comments

Comments
 (0)