diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index ac02baa429b4..45dba97a79f7 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -72,12 +72,11 @@ object Annotations { def refersToParamOf(tl: TermLambda)(using Context): Boolean = val args = arguments if args.isEmpty then false - else tree.existsSubTree { - case id: Ident => id.tpe.stripped match + else tree.existsSubTree: + case id: (Ident | This) => id.tpe.stripped match case TermParamRef(tl1, _) => tl eq tl1 case _ => false case _ => false - } /** A string representation of the annotation. Overridden in BodyAnnotation. */ diff --git a/tests/pos-custom-args/captures/i19990.scala b/tests/pos-custom-args/captures/i19990.scala new file mode 100644 index 000000000000..2e25a4244bca --- /dev/null +++ b/tests/pos-custom-args/captures/i19990.scala @@ -0,0 +1,13 @@ +import language.experimental.captureChecking + +trait Iterable[T] { self: Iterable[T]^ => + def map[U](f: T => U): Iterable[U]^{this, f} +} + +object Test { + def indentLines(level: Int, lines: Iterable[String]) = + lines.map(line => line.split("\n").map(" " + _).mkString("\n")) + + def indentErrorMessages(messages: Iterable[String]) = + indentLines(1, messages) +}