Skip to content

Backport "Fix mapping of annotations" to 3.3 LTS #194

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
Apr 3, 2025
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ object Annotations {
if tm.isRange(x) then x
else
val tp1 = tm(tree.tpe)
foldOver(if !tp1.exists || (tp1 frozen_=:= tree.tpe) then x else tp1, tree)
foldOver(if !tp1.exists || tp1.eql(tree.tpe) then x else tp1, tree)
val diff = findDiff(NoType, args)
if tm.isRange(diff) then EmptyAnnotation
else if diff.exists then derivedAnnotation(tm.mapOver(tree))
Expand Down
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5967,6 +5967,8 @@ object Types extends TypeUtils {
override def stopAt = thisMap.stopAt
def apply(tp: Type) = f(thisMap(tp))
}

override def toString = s"${getClass.getSimpleName}@$hashCode" // otherwise would print as <function1>
}

/** A type map that maps also parents and self type of a ClassInfo */
Expand Down
6 changes: 6 additions & 0 deletions tests/pos-custom-args/captures/setup/a_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// a.scala
import language.experimental.captureChecking
import scala.caps.CapSet

trait A:
def f[C^](x: AnyRef^{C^}): Unit
5 changes: 5 additions & 0 deletions tests/pos-custom-args/captures/setup/b_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import language.experimental.captureChecking
import scala.caps.CapSet

class B extends A:
def f[C^](x: AnyRef^{C^}): Unit = ???
5 changes: 5 additions & 0 deletions tests/pos-custom-args/captures/setup/b_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import language.experimental.captureChecking
import scala.caps.CapSet

class B extends A:
def f[C^](x: AnyRef^{C^}): Unit = ???