From 8d4b2a6de5d9d9b31283b969f3c3271a5f177900 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 1 Jun 2020 11:06:30 +0200 Subject: [PATCH] Fix variance fixing code in the fix of #9061 It did not work for curried type lambdas. --- compiler/src/dotty/tools/dotc/typer/Namer.scala | 4 ++-- tests/pos/nestedLambdas.scala | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index a7dc9c6ee3b7..0c326cfc3735 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1009,8 +1009,8 @@ class Namer { typer: Typer => case tp: TypeBounds => def recur(tp: Type): Type = tp match case tp: HKTypeLambda if !tp.isDeclaredVarianceLambda => - tp.withVariances(tp.paramNames.map(alwaysInvariant)) - .derivedLambdaType(resType = recur(tp.resType)) + val tp1 = tp.withVariances(tp.paramNames.map(alwaysInvariant)) + tp1.derivedLambdaType(resType = recur(tp1.resType)) case tp => tp tp.derivedTypeBounds(tp.lo, recur(tp.hi)) case _ => diff --git a/tests/pos/nestedLambdas.scala b/tests/pos/nestedLambdas.scala index 869c11bfc838..8cc0020dbfbb 100644 --- a/tests/pos/nestedLambdas.scala +++ b/tests/pos/nestedLambdas.scala @@ -10,11 +10,11 @@ class Test { val y: A[Int][Boolean] = x - def f[X <: T[Int]] = ??? + def f[X <: [Y] =>> T[Int][Y]] = ??? f[A[Int]] - def g[X <: T] = ??? + def g[X <: [Y] =>> [Z] =>> T[Y][Z]] = ??? g[A]