Skip to content

Check This references in refersToParamOf #20005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
13 changes: 13 additions & 0 deletions tests/pos-custom-args/captures/i19990.scala
Original file line number Diff line number Diff line change
@@ -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)
}