Skip to content

Commit

Permalink
Fix conversion of this.fld capture refs under separate compilation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky authored Apr 19, 2024
2 parents 0bf4911 + 736c6f4 commit fef6576
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
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(???)


0 comments on commit fef6576

Please sign in to comment.