diff options
-rw-r--r-- | docs/HigherKinded-v2.md | 4 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 10 | ||||
-rw-r--r-- | tests/pos/i143.scala | 14 |
3 files changed, 22 insertions, 6 deletions
diff --git a/docs/HigherKinded-v2.md b/docs/HigherKinded-v2.md index e30f4e429..3216f42f4 100644 --- a/docs/HigherKinded-v2.md +++ b/docs/HigherKinded-v2.md @@ -75,7 +75,7 @@ Type parameters in the encodings The notion of type parameters makes sense even for encoded types, which do not contain parameter lists in their syntax. Specifically, the type parameters of a type are a sequence of type fields that -correspond to paraneters in the unencoded type. They are determined as +correspond to parameters in the unencoded type. They are determined as follows. - The type parameters of a class or trait type are those parameter fields declared in the class @@ -176,7 +176,7 @@ have more than one type parameter. For instance, here is a trait with contravari trait Lambda$NP[type -$hkArg$0, +$hkArg1] { type +Apply } extends Lambda$IP with Lambda$NI Aside: the `+` prefix in front of `Apply` indicates that `Apply` is a covariant type field. Dotty -admits variance annotations on type members). +admits variance annotations on type members. The definition of `Lambda$NP` shows that `Lambda` traits form a subtyping hierarchy: Traits which have covariant or contravariant type parameters are subtypes of traits which don't. The supertraits diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 289515ae1..2cf4516cd 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1166,9 +1166,7 @@ object Types { TermRef.withSig(prefix, name.asTermName, sig) protected def loadDenot(implicit ctx: Context): Denotation = { - val d = - if (name.isInheritedName) prefix.nonPrivateMember(name.revertInherited) - else prefix.member(name) + val d = asMemberOf(prefix) if (d.exists || ctx.phaseId == FirstPhaseId || !lastDenotation.isInstanceOf[SymDenotation]) d else { // name has changed; try load in earlier phase and make current @@ -1178,6 +1176,10 @@ object Types { } } + protected def asMemberOf(prefix: Type)(implicit ctx: Context) = + if (name.isInheritedName) prefix.nonPrivateMember(name.revertInherited) + else prefix.member(name) + def symbol(implicit ctx: Context): Symbol = { val now = ctx.period if (checkedPeriod == now || @@ -1289,7 +1291,7 @@ object Types { sig != Signature.OverloadedSignature && symbol.exists) { val ownSym = symbol - TermRef(prefix, name).withDenot(prefix.member(name).disambiguate(_ eq ownSym)) + TermRef(prefix, name).withDenot(asMemberOf(prefix).disambiguate(_ eq ownSym)) } else TermRef.withSig(prefix, name, sig) } diff --git a/tests/pos/i143.scala b/tests/pos/i143.scala new file mode 100644 index 000000000..8804b20ce --- /dev/null +++ b/tests/pos/i143.scala @@ -0,0 +1,14 @@ +package dotty.tools.dotc +package transform + +import dotty.tools.dotc.core.Denotations._ +import dotty.tools.dotc.core.Symbols._ +import dotty.tools.dotc.core.Contexts._ + +class TC5 extends AnyVal { + implicit val ctx: Context = ??? + + def candidates(mbr: SingleDenotation): Boolean = { + mbr.symbol.denot(ctx).exists + } +} |