Skip to content

Commit fe49539

Browse files
authored
Strip CC annotations in TypeMap when CC is not enabled (#24556)
Hot fixes #24550. This is a mitigation, but doesn't fix the root cause.
2 parents 6462d7d + fe1dfee commit fe49539

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}
@@ -6279,12 +6280,12 @@ object Types extends TypeUtils {
62796280

62806281
end BiTypeMap
62816282

6282-
/** A typemap that follows aliases and keeps their transformed results if
6283-
* there is a change.
6284-
*/
6283+
/** A typemap that follows non-opaque aliases and keeps their transformed
6284+
* results if there is a change.
6285+
*/
62856286
trait FollowAliasesMap(using Context) extends TypeMap:
62866287
def mapFollowingAliases(t: Type): Type =
6287-
val t1 = t.dealiasKeepAnnots
6288+
val t1 = t.dealiasKeepAnnotsAndOpaques
62886289
if t1 ne t then
62896290
val t2 = apply(t1)
62906291
if t2 ne t1 then t2
@@ -6483,10 +6484,13 @@ object Types extends TypeUtils {
64836484
mapCapturingType(tp, parent, refs, variance)
64846485

64856486
case tp @ AnnotatedType(underlying, annot) =>
6486-
val underlying1 = this(underlying)
6487-
val annot1 = annot.mapWith(this)
6488-
if annot1 eq EmptyAnnotation then underlying1
6489-
else derivedAnnotatedType(tp, underlying1, annot1)
6487+
if annot.symbol.isRetainsLike && !Feature.ccEnabledSomewhere then
6488+
this(underlying) // strip retains like annotations unless capture checking is enabled
6489+
else
6490+
val underlying1 = this(underlying)
6491+
val annot1 = annot.mapWith(this)
6492+
if annot1 eq EmptyAnnotation then underlying1
6493+
else derivedAnnotatedType(tp, underlying1, annot1)
64906494

64916495
case _: ThisType
64926496
| _: BoundType

0 commit comments

Comments
 (0)