Skip to content

Commit b3d8ef3

Browse files
dwijnandtgodzik
authored andcommitted
Fix issues after merging
1 parent 97c2b63 commit b3d8ef3

File tree

5 files changed

+38
-34
lines changed

5 files changed

+38
-34
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package core
55
import Symbols.*, Types.*, Contexts.*, Flags.*, Names.*, StdNames.*, Phases.*
66
import Flags.JavaDefined
77
import Uniques.unique
8-
import TypeOps.makePackageObjPrefixExplicit
98
import backend.sjs.JSDefinitions
109
import transform.ExplicitOuter.*
1110
import transform.ValueClasses.*

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -598,36 +598,6 @@ object TypeOps:
598598
widenMap(tp)
599599
}
600600

601-
/** If `tpe` is of the form `p.x` where `p` refers to a package
602-
* but `x` is not owned by a package, expand it to
603-
*
604-
* p.package.x
605-
*/
606-
def makePackageObjPrefixExplicit(tpe: NamedType)(using Context): Type = {
607-
def tryInsert(pkgClass: SymDenotation): Type = pkgClass match {
608-
case pkg: PackageClassDenotation =>
609-
var sym = tpe.symbol
610-
if !sym.exists && tpe.denot.isOverloaded then
611-
// we know that all alternatives must come from the same package object, since
612-
// otherwise we would get "is already defined" errors. So we can take the first
613-
// symbol we see.
614-
sym = tpe.denot.alternatives.head.symbol
615-
val pobj = pkg.packageObjFor(sym)
616-
if (pobj.exists) tpe.derivedSelect(pobj.termRef)
617-
else tpe
618-
case _ =>
619-
tpe
620-
}
621-
if (tpe.symbol.isRoot)
622-
tpe
623-
else
624-
tpe.prefix match {
625-
case pre: ThisType if pre.cls.is(Package) => tryInsert(pre.cls)
626-
case pre: TermRef if pre.symbol.is(Package) => tryInsert(pre.symbol.moduleClass)
627-
case _ => tpe
628-
}
629-
}
630-
631601
/** An argument bounds violation is a triple consisting of
632602
* - the argument tree
633603
* - a string "upper" or "lower" indicating which bound is violated

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotc
33
package core
44

55
import TypeErasure.ErasedValueType
6-
import Types.*, Contexts.*, Symbols.*, Flags.*, Decorators.*
6+
import Types.*, Contexts.*, Symbols.*, Flags.*, Decorators.*, SymDenotations.*
77
import Names.Name
88
import StdNames.nme
99

@@ -147,6 +147,41 @@ class TypeUtils:
147147
val cls = self.underlyingClassRef(refinementOK = false).typeSymbol
148148
cls.isTransparentClass && (!traitOnly || cls.is(Trait))
149149

150+
/** If `self` is of the form `p.x` where `p` refers to a package
151+
* but `x` is not owned by a package, expand it to
152+
*
153+
* p.package.x
154+
*/
155+
def makePackageObjPrefixExplicit(using Context): Type =
156+
def tryInsert(tpe: NamedType, pkgClass: SymDenotation): Type = pkgClass match
157+
case pkg: PackageClassDenotation =>
158+
var sym = tpe.symbol
159+
if !sym.exists && tpe.denot.isOverloaded then
160+
// we know that all alternatives must come from the same package object, since
161+
// otherwise we would get "is already defined" errors. So we can take the first
162+
// symbol we see.
163+
sym = tpe.denot.alternatives.head.symbol
164+
val pobj = pkg.packageObjFor(sym)
165+
if pobj.exists then tpe.derivedSelect(pobj.termRef)
166+
else tpe
167+
case _ =>
168+
tpe
169+
self match
170+
case tpe: NamedType =>
171+
if tpe.symbol.isRoot then
172+
tpe
173+
else
174+
tpe.prefix match
175+
case pre: ThisType if pre.cls.is(Package) => tryInsert(tpe, pre.cls)
176+
case pre: TermRef if pre.symbol.is(Package) => tryInsert(tpe, pre.symbol.moduleClass)
177+
case _ => tpe
178+
case tpe => tpe
179+
180+
/** Strip all outer refinements off this type */
181+
def stripRefinement: Type = self match
182+
case self: RefinedOrRecType => self.parent.stripRefinement
183+
case seld => self
184+
150185
/** The constructors of this type that are applicable to `argTypes`, without needing
151186
* an implicit conversion. Curried constructors are always excluded.
152187
* @param adaptVarargs if true, allow a constructor with just a varargs argument to

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ class TreeUnpickler(reader: TastyReader,
11921192
val tpe0 = name match
11931193
case name: TypeName => TypeRef(qualType, name, denot)
11941194
case name: TermName => TermRef(qualType, name, denot)
1195-
val tpe = TypeOps.makePackageObjPrefixExplicit(tpe0)
1195+
val tpe = tpe0.makePackageObjPrefixExplicit
11961196
ConstFold.Select(untpd.Select(qual, name).withType(tpe))
11971197

11981198
def completeSelect(name: Name, sig: Signature, target: Name): Select =

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ trait TypeAssigner {
8181
defn.FromJavaObjectType
8282
else tpe match
8383
case tpe: NamedType =>
84-
val tpe1 = TypeOps.makePackageObjPrefixExplicit(tpe)
84+
val tpe1 = tpe.makePackageObjPrefixExplicit
8585
if tpe1 ne tpe then
8686
accessibleType(tpe1, superAccess)
8787
else

0 commit comments

Comments
 (0)