@@ -680,12 +680,20 @@ class CheckCaptures extends Recheck, SymTransformer:
680680 if pt.select.symbol.isReadOnlyMethod then
681681 markFree(ref.readOnly, tree)
682682 else
683- markPathFree(ref.select(pt.select.symbol).asInstanceOf [TermRef ], pt.pt, pt.select)
683+ val sel = ref.select(pt.select.symbol).asInstanceOf [TermRef ]
684+ sel.recomputeDenot()
685+ // We need to do a recomputeDenot here since we have not yet properly
686+ // computed the type of the full path. This means that we erroneously
687+ // think the denotation is the same as in the previous phase so no
688+ // member computation is performed. A test case where this matters is
689+ // read-only-use.scala, where the error on r3 goes unreported.
690+ markPathFree(sel, pt.pt, pt.select)
684691 case _ =>
685- if ref.derivesFromMutable && pt.isValueType && ! pt.isMutableType then
686- markFree(ref.readOnly, tree)
687- else
688- markFree(ref, tree)
692+ if ref.derivesFromMutable then
693+ if pt.isValueType && ! pt.isMutableType || ref.exclusivityInContext != Exclusivity .OK
694+ then markFree(ref.readOnly, tree)
695+ else markFree(ref, tree)
696+ else markFree(ref, tree)
689697
690698 /** The expected type for the qualifier of a selection. If the selection
691699 * could be part of a capability path or is a a read-only method, we return
0 commit comments