From ab79724aa736a3cc17e4b97a447aeac6f3152914 Mon Sep 17 00:00:00 2001 From: odersky Date: Sun, 9 Oct 2022 18:09:43 +0200 Subject: [PATCH] Handle copies of constrained type lambdas when determining an implicit scope Fixes #16146 --- compiler/src/dotty/tools/dotc/typer/Implicits.scala | 3 +++ tests/neg/i16146.scala | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 tests/neg/i16146.scala diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index ede44c2b7f86..020027ea9d74 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -627,6 +627,9 @@ trait ImplicitRunInfo: traverse(t.underlying) case t: TermParamRef => traverse(t.underlying) + case t: TypeLambda => + for p <- t.paramRefs do partSeen += p + traverseChildren(t) case t => traverseChildren(t) diff --git a/tests/neg/i16146.scala b/tests/neg/i16146.scala new file mode 100644 index 000000000000..6aed6b263ce4 --- /dev/null +++ b/tests/neg/i16146.scala @@ -0,0 +1,3 @@ + +type N = [X] => (X => X) => X => X +val exp = (a: N) => (b: N) => b(a) // error