Skip to content

Commit 533980a

Browse files
Backport "Strip CC annotations in TypeMap when CC is not enabled" to 3.8.0 (#24610)
Backports #24556 to the 3.8.0-RC3. PR submitted by the release tooling. [skip ci]
2 parents d61e0ed + b39687c commit 533980a

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import Hashable.*
3030
import Uniques.*
3131
import collection.mutable
3232
import config.Config
33+
import config.Feature
3334
import config.Feature.sourceVersion
3435
import config.SourceVersion
3536
import annotation.{tailrec, constructorOnly}
@@ -6261,12 +6262,12 @@ object Types extends TypeUtils {
62616262

62626263
end BiTypeMap
62636264

6264-
/** A typemap that follows aliases and keeps their transformed results if
6265-
* there is a change.
6266-
*/
6265+
/** A typemap that follows non-opaque aliases and keeps their transformed
6266+
* results if there is a change.
6267+
*/
62676268
trait FollowAliasesMap(using Context) extends TypeMap:
62686269
def mapFollowingAliases(t: Type): Type =
6269-
val t1 = t.dealiasKeepAnnots
6270+
val t1 = t.dealiasKeepAnnotsAndOpaques
62706271
if t1 ne t then
62716272
val t2 = apply(t1)
62726273
if t2 ne t1 then t2
@@ -6465,10 +6466,13 @@ object Types extends TypeUtils {
64656466
mapCapturingType(tp, parent, refs, variance)
64666467

64676468
case tp @ AnnotatedType(underlying, annot) =>
6468-
val underlying1 = this(underlying)
6469-
val annot1 = annot.mapWith(this)
6470-
if annot1 eq EmptyAnnotation then underlying1
6471-
else derivedAnnotatedType(tp, underlying1, annot1)
6469+
if annot.symbol.isRetainsLike && !Feature.ccEnabledSomewhere then
6470+
this(underlying) // strip retains like annotations unless capture checking is enabled
6471+
else
6472+
val underlying1 = this(underlying)
6473+
val annot1 = annot.mapWith(this)
6474+
if annot1 eq EmptyAnnotation then underlying1
6475+
else derivedAnnotatedType(tp, underlying1, annot1)
64726476

64736477
case _: ThisType
64746478
| _: BoundType

0 commit comments

Comments
 (0)