Skip to content

Commit 4f0bb7e

Browse files
committed
Don't lose paramSyms when unpickling from Scala 2
We could lose them for curried methods since the nested method type was copied in case there was a depencency on a parameter of the first method type. Fixes scala#13238
1 parent 8c3e7a2 commit 4f0bb7e

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,12 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
847847
val maker = MethodType.companion(
848848
isImplicit = tag == IMPLICITMETHODtpe || params.nonEmpty && params.head.is(Implicit))
849849
val result = maker.fromSymbols(params, restpe)
850+
result.resType match
851+
case restpe1: MethodType =>
852+
val prevResParams = paramsOfMethodType.remove(restpe)
853+
if prevResParams != null then
854+
paramsOfMethodType.put(restpe1, prevResParams)
855+
case _ =>
850856
if params.nonEmpty then paramsOfMethodType.put(result, params)
851857
result
852858
case POLYtpe =>

tests/neg/i13238/boom_2.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def boom(foo: Foo) = foo.foo(foo) // error
2+

tests/neg/i13238/foo_1.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Should be compiled with 2.13
2+
trait Bar
3+
class Foo {
4+
def foo(out: Foo)(implicit bar: Bar): out.type = out
5+
}

0 commit comments

Comments
 (0)