@@ -1686,10 +1686,8 @@ object Types {
16861686
16871687 private def loadDenot (name : Name , allowPrivate : Boolean )(implicit ctx : Context ): Denotation = {
16881688 var d = memberDenot(prefix, name, allowPrivate)
1689- if (! d.exists) {
1690- val d1 = memberDenot(prefix, name, true )
1691- assert(! d1.exists, i " bad allow private $this $name $d1 at ${ctx.phase}" )
1692- }
1689+ if (! d.exists && ctx.mode.is(Mode .Interactive ))
1690+ d = memberDenot(prefix, name, true )
16931691 if (! d.exists && ctx.phaseId > FirstPhaseId && lastDenotation.isInstanceOf [SymDenotation ])
16941692 // name has changed; try load in earlier phase and make current
16951693 d = loadDenot(name, allowPrivate)(ctx.withPhase(ctx.phaseId - 1 )).current
@@ -1698,6 +1696,9 @@ object Types {
16981696 d
16991697 }
17001698
1699+ /** Reload denotation by computing the member with the reference's name as seen
1700+ * from the reference's prefix.
1701+ */
17011702 def reloadDenot ()(implicit ctx : Context ) =
17021703 setDenot(loadDenot(name, allowPrivate = ! symbol.exists || symbol.is(Private )))
17031704
@@ -1706,7 +1707,7 @@ object Types {
17061707
17071708 private def disambiguate (d : Denotation )(implicit ctx : Context ): Denotation = {
17081709 val sig = currentSignature
1709- // if (ctx.isAfterTyper) println(i"overloaded $this / $d / sig = $sig")
1710+ // if (ctx.isAfterTyper) println(i"overloaded $this / $d / sig = $sig") // DEBUG
17101711 if (sig != null )
17111712 d.atSignature(sig, relaxed = ! ctx.erasedTypes) match {
17121713 case d1 : SingleDenotation => d1
@@ -1900,10 +1901,12 @@ object Types {
19001901 case _ => withPrefix(prefix)
19011902 }
19021903
1904+ /** A reference like this one, but with the given symbol, if it exists */
19031905 final def withSym (sym : Symbol )(implicit ctx : Context ): ThisType =
19041906 if ((designator ne sym) && sym.exists) NamedType (prefix, sym).asInstanceOf [ThisType ]
19051907 else this
19061908
1909+ /** A reference like this one, but with the given denotation, if it exists */
19071910 final def withDenot (denot : Denotation )(implicit ctx : Context ): ThisType =
19081911 if (denot.exists) {
19091912 val adapted = withSym(denot.symbol)
@@ -1916,8 +1919,7 @@ object Types {
19161919 else // don't assign NoDenotation, we might need to recover later. Test case is pos/avoid.scala.
19171920 this
19181921
1919- /** Create a NamedType of the same kind as this type, but with a new prefix.
1920- */
1922+ /** A reference like this one, but with the given prefix. */
19211923 final def withPrefix (prefix : Type )(implicit ctx : Context ): NamedType = {
19221924 def reload (): NamedType = {
19231925 val allowPrivate = ! lastSymbol.exists || lastSymbol.is(Private ) && prefix.classSymbol == this .prefix.classSymbol
@@ -1930,7 +1932,8 @@ object Types {
19301932 }
19311933 NamedType (prefix, name, d)
19321934 }
1933- if (lastDenotation == null ) NamedType (prefix, designator)
1935+ if (prefix eq this .prefix) this
1936+ else if (lastDenotation == null ) NamedType (prefix, designator)
19341937 else designator match {
19351938 case sym : Symbol =>
19361939 if (infoDependsOnPrefix(sym, prefix)) {
0 commit comments