Skip to content

Commit

Permalink
Drop retained elements and keep the annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
Linyxus committed Apr 9, 2024
1 parent 6156530 commit 98cbe06
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/cc/CaptureOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ extension (tp: AnnotatedType)
class CleanupRetains(using Context) extends TypeMap:
def apply(tp: Type): Type =
tp match
case RetainingType(tp, _) => tp
case AnnotatedType(tp, annot) if annot.symbol == defn.RetainsAnnot || annot.symbol == defn.RetainsByNameAnnot =>
RetainingType(tp, Nil, byName = annot.symbol == defn.RetainsByNameAnnot)
case _ => mapOver(tp)

/** An extractor for `caps.reachCapability(ref)`, which is used to express a reach
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/cc/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ class Setup extends PreRecheck, SymTransformer, SetupAPI:
case _ => false

def signatureChanges =
(tree.tpt.hasRememberedType || tree.tpt.isInstanceOf[InferredTypeTree]) && !sym.isConstructor || paramSignatureChanges
tree.tpt.hasRememberedType && !sym.isConstructor || paramSignatureChanges

// Replace an existing symbol info with inferred types where capture sets of
// TypeParamRefs and TermParamRefs put in correspondence by BiTypeMaps with the
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-custom-args/captures/byname.check
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
| Found: (x$0: Int) ->{cap2} Int
| Required: (x$0: Int) -> Int
|
| Note that the expected type Int -> Int
| Note that the expected type Int ->{} Int
| is the previously inferred result type of method test
| which is also the type seen in separately compiled sources.
| The new inferred type (x$0: Int) ->{cap2} Int
Expand Down

0 comments on commit 98cbe06

Please sign in to comment.