Skip to content

Fix conversion of this.fld capture refs under separate compilation #20238

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,14 @@ class TypeUtils {
case _ =>
val cls = self.underlyingClassRef(refinementOK = false).typeSymbol
cls.isTransparentClass && (!traitOnly || cls.is(Trait))

/** Is this type the ThisType of class `cls?`. Note we can't use `self eq cls.thisType` for this,
* since ThisTypes take TermRef parameters and semantically equal TermRefs could have different
* forms (for instance one could use as a prefix the ThisType of an enclosing static module or package,
* and the other could select it from something further out)
*/
def isThisTypeOf(cls: Symbol)(using Context) = self match
case self: Types.ThisType => self.cls == cls
case _ => false
}
}
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2991,7 +2991,7 @@ object Types extends TypeUtils {
*/
override def isTrackableRef(using Context) =
((prefix eq NoPrefix)
|| symbol.is(ParamAccessor) && (prefix eq symbol.owner.thisType)
|| symbol.is(ParamAccessor) && prefix.isThisTypeOf(symbol.owner)
|| isRootCapability
) && !symbol.isOneOf(UnstableValueFlags)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class Future[T]
object Future:
class Collector[T](fs: (Future[T]^)*)
class MutableCollector[T](val futures: (Future[T]^)*) extends Collector[T](futures*):
def add(future: Future[T]^{futures*}) = ???
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def test =
val collector: Future.MutableCollector[Int] = Future.MutableCollector()
collector.add(???)


Loading