Skip to content

Commit 6eac7c2

Browse files
committed
sharpen asSeenFrom condition and expand comment
1 parent b4c2972 commit 6eac7c2

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,20 +1134,23 @@ object Denotations {
11341134

11351135
/** The derived denotation with the given `info` transformed with `asSeenFrom`.
11361136
* The prefix of the derived denotation is the new prefix `pre` if the type is
1137-
* abstract or opaque, or if the current prefix is already different from `NoPrefix`.
1137+
* opaque, or if the current prefix is already different from `NoPrefix`.
11381138
* That leaves SymDenotations (which have NoPrefix as the prefix), which are left
1139-
* as SymDenotations unless the type is abstract or opaque. This special case
1140-
* is not ideal, and we should see whether we can drop it.
1141-
* Currently dropping the special case fails the bootstrap. There's also a concern
1142-
* that without the special case we'd create more denotation objects, at a price
1143-
* in performance.
1139+
* as SymDenotations unless the type is opaque. The treatment of opaque types
1140+
* is needed, without it i7159.scala fails in from-tasty. Without the treatment,
1141+
* opaque type denotations in subclasses are kept as SymDenotations, which means
1142+
* that the transform in `ElimOpaque` will return the symbol's opaque alias without
1143+
* adding the needed asSeenFrom.
1144+
*
1145+
* Logically, the right thing to do would be to extend the same treatment to all denotations
1146+
* Currently this fails the bootstrap. There's also a concern that this generalization
1147+
* would create more denotation objects, at a price in performance.
11441148
*/
11451149
def derived(info: Type) =
11461150
derivedSingleDenotation(
11471151
symbol,
11481152
info.asSeenFrom(pre, owner),
1149-
if (symbol.isOneOf(Opaque | Deferred) || this.prefix != NoPrefix) pre
1150-
else /* special case, see above */ this.prefix)
1153+
if (symbol.is(Opaque) || this.prefix != NoPrefix) pre else this.prefix)
11511154

11521155
pre match {
11531156
case pre: ThisType if symbol.isOpaqueAlias && pre.cls == owner =>

0 commit comments

Comments
 (0)