Skip to content

Commit 043bf54

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

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-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)

compiler/test/dotty/tools/dotc/FromTastyTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class FromTastyTests extends ParallelTesting {
8787

8888
// Closure type miss match
8989
"eff-dependent.scala",
90+
"i4125.scala",
9091

9192
// Issue unpickling universes
9293
"phantom-decls-1.scala",

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)