Skip to content

Commit 6df14d3

Browse files
committed
Fix #4125: Properly type erased dependent function types
1 parent 7624f5e commit 6df14d3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ class Typer extends Namer
777777
completeParams(params)
778778
val params1 = params.map(typedExpr(_).asInstanceOf[ValDef])
779779
val resultTpt = typed(body)
780-
val companion = if (isImplicit) ImplicitMethodType else MethodType
780+
val companion = MethodType.maker(isImplicit = isImplicit, isErased = isErased)
781781
val mt = companion.fromSymbols(params1.map(_.symbol), resultTpt.tpe)
782782
if (mt.isParamDependent)
783783
ctx.error(i"$mt is an illegal function type because it has inter-parameter dependencies", tree.pos)

tests/pos/i4125.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object Test {
2+
def foo: (erased (x: Int, y: Int) => Int) = erased (x, y) => 1
3+
def bar: (erased implicit (x: Int, y: Int) => Int) = erased implicit (x, y) => 1
4+
}

0 commit comments

Comments
 (0)