Skip to content

Commit

Permalink
Fix handling of by-name default getters
Browse files Browse the repository at this point in the history
There was an omission before, but as long as  byname parameters were ExprTypes it did
not lead to problems.
  • Loading branch information
odersky committed Jan 17, 2022
1 parent 8fe40ca commit 63f7dba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ class Namer { typer: Typer =>
ctx.defContext(sym).denotNamed(original)
def paramProto(paramss: List[List[Type]], idx: Int): Type = paramss match {
case params :: paramss1 =>
if (idx < params.length) params(idx)
if (idx < params.length) params(idx).widenByName
else paramProto(paramss1, idx - params.length)
case nil =>
NoType
Expand Down
5 changes: 5 additions & 0 deletions tests/pos/byname-default.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Extraction of a failing case in scalaSTM
object Test:

def apply[A](init: => A = null.asInstanceOf[A]) = init

0 comments on commit 63f7dba

Please sign in to comment.