Skip to content

Commit 97dd197

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

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class FromTastyTests extends ParallelTesting {
4646
// Type miss match after unpickling
4747
"hklub0.scala",
4848

49+
// Closure type miss match
50+
"i4125.scala",
51+
4952
// Missing position
5053
"t1203a.scala",
5154
"t2260.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)