Skip to content

Commit 98cbe06

Browse files
committed
Drop retained elements and keep the annotation
1 parent 6156530 commit 98cbe06

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ extension (tp: AnnotatedType)
449449
class CleanupRetains(using Context) extends TypeMap:
450450
def apply(tp: Type): Type =
451451
tp match
452-
case RetainingType(tp, _) => tp
452+
case AnnotatedType(tp, annot) if annot.symbol == defn.RetainsAnnot || annot.symbol == defn.RetainsByNameAnnot =>
453+
RetainingType(tp, Nil, byName = annot.symbol == defn.RetainsByNameAnnot)
453454
case _ => mapOver(tp)
454455

455456
/** An extractor for `caps.reachCapability(ref)`, which is used to express a reach

compiler/src/dotty/tools/dotc/cc/Setup.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
454454
case _ => false
455455

456456
def signatureChanges =
457-
(tree.tpt.hasRememberedType || tree.tpt.isInstanceOf[InferredTypeTree]) && !sym.isConstructor || paramSignatureChanges
457+
tree.tpt.hasRememberedType && !sym.isConstructor || paramSignatureChanges
458458

459459
// Replace an existing symbol info with inferred types where capture sets of
460460
// TypeParamRefs and TermParamRefs put in correspondence by BiTypeMaps with the

tests/neg-custom-args/captures/byname.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
| Found: (x$0: Int) ->{cap2} Int
1010
| Required: (x$0: Int) -> Int
1111
|
12-
| Note that the expected type Int -> Int
12+
| Note that the expected type Int ->{} Int
1313
| is the previously inferred result type of method test
1414
| which is also the type seen in separately compiled sources.
1515
| The new inferred type (x$0: Int) ->{cap2} Int

0 commit comments

Comments
 (0)