Skip to content

Commit

Permalink
Call normalizeOpaque in window of vulnerability
Browse files Browse the repository at this point in the history
It turns out we get confused when we call normalizeOpaque as part of normal
completion during computeDenot. Fine tuning normalizeOpaque and calling it
in the window of vulnerability where a type is Opaque but not yet Deferred
fixes the problem. Before the following tests failed when compiled from-tasty:

    tests/run/implicit-specifity.scala failed
    tests/pos/i5720.scala failed
    tests/pos/toplevel-opaque-xm failed
    tests/pos/postconditions.scala failed
  • Loading branch information
odersky committed May 29, 2019
1 parent 73e6bf2 commit 71f8413
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 2 additions & 3 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,6 @@ object SymDenotations {
if (isOpaqueAlias) {
info match {
case TypeAlias(alias) =>
info = TypeBounds(defn.NothingType, abstractRHS(alias))

def refineSelfType(selfType: Type) =
RefinedType(selfType, name, TypeAlias(alias))
val enclClassInfo = owner.asClass.classInfo
Expand All @@ -393,8 +391,9 @@ object SymDenotations {
case self: Symbol =>
self.info = refineSelfType(self.info)
}

info = TypeBounds(defn.NothingType, abstractRHS(alias))
setFlag(Deferred)
typeRef.recomputeDenot()
case _ =>
}
}
Expand Down
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1883,8 +1883,10 @@ object Types {
finish(memberDenot(symd.initial.name, allowPrivate = false))
else if (prefix.isArgPrefixOf(symd))
finish(argDenot(sym.asType))
else if (infoDependsOnPrefix(symd, prefix))
else if (infoDependsOnPrefix(symd, prefix)) {
if (!symd.isClass && symd.is(Opaque, butNot = Deferred)) symd.normalizeOpaque()
finish(memberDenot(symd.initial.name, allowPrivate = symd.is(Private)))
}
else
finish(symd.current)
}
Expand Down

0 comments on commit 71f8413

Please sign in to comment.