From bf8e854c9f2dc2b03be5a44c84183af21510e6ef Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 12 Mar 2013 09:04:57 +0100 Subject: Split filterAsSeenFrom and generalized flag handling. 1. filterAsSeenFrom has been split again into its constituents "filterExcluded" and "asSeenFrom", and care was taken not to force the info unless we have to. The accessible check is no longer done when collecting members, because it would have forced the symbol through requesting privateWithin. 2. SymDenotation#is is tweaked to no longer force the denotation if the flags are in "FromStartFlags", i.e. set upon symbol creation. We can then eliminate special cases isModuleXXX, isPackageXXX. 3. Other tweaks mostly having to do with weakening sym.exists checks to avoid CyclicReference errros. --- src/dotty/tools/dotc/core/Denotations.scala | 44 ++++++++-------- src/dotty/tools/dotc/core/Flags.scala | 7 +++ src/dotty/tools/dotc/core/Printers.scala | 16 +++--- src/dotty/tools/dotc/core/SymDenotations.scala | 60 ++++++++++------------ src/dotty/tools/dotc/core/SymbolLoaders.scala | 8 +-- src/dotty/tools/dotc/core/Symbols.scala | 6 +-- src/dotty/tools/dotc/core/TypeComparers.scala | 2 +- src/dotty/tools/dotc/core/TypeOps.scala | 2 +- src/dotty/tools/dotc/core/TypedTrees.scala | 2 +- src/dotty/tools/dotc/core/Types.scala | 6 +-- .../tools/dotc/core/pickling/ClassfileParser.scala | 2 +- src/dotty/tools/dotc/core/transform/Erasure.scala | 4 +- 12 files changed, 81 insertions(+), 78 deletions(-) (limited to 'src/dotty') diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index a89aa6bf8..693c3c0c5 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -184,7 +184,8 @@ object Denotations { */ def requiredSymbol(p: Symbol => Boolean, name: Name, source: AbstractFile = null)(implicit ctx: Context): Symbol = { val sym = disambiguate(p).symbol - if (sym.exists) sym else { + if (sym != NoSymbol) sym // note would like to ask sym.exists instead, but this would force too much + else { val firstSym = ((NoSymbol: Symbol) /: alternatives.map(_.symbol)) (_ orElse _) val owner = if (firstSym.exists) firstSym.owner else NoSymbol ctx.newStubSymbol(owner, name, source) @@ -471,19 +472,18 @@ object Denotations { // ------ PreDenotation ops ---------------------------------------------- - def first = this - def toDenot(implicit ctx: Context) = this - def containsSig(sig: Signature)(implicit ctx: Context) = + final def first = this + final def toDenot(implicit ctx: Context) = this + final def containsSig(sig: Signature)(implicit ctx: Context) = signature == sig - def filterDisjoint(denots: PreDenotation)(implicit ctx: Context): PreDenotation = + final def filterDisjoint(denots: PreDenotation)(implicit ctx: Context): SingleDenotation = if (denots.containsSig(signature)) NoDenotation else this - def filterAsSeenFrom(pre: Type, excluded: FlagSet)(implicit ctx: Context): PreDenotation = { - val sym = symbol - if (sym.exists && !(sym is excluded) && sym.isAccessibleFrom(pre)) - derivedSingleDenotation(symbol, info.asSeenFrom(pre, symbol.owner)) - else - NoDenotation - } + final def filterExcluded(excluded: FlagSet)(implicit ctx: Context): SingleDenotation = + if (excluded != EmptyFlags && (asSymDenotation is excluded)) NoDenotation + else this + def asSeenFrom(pre: Type)(implicit ctx: Context): SingleDenotation = + if (!asSymDenotation.owner.membersNeedAsSeenFrom(pre)) this + else derivedSingleDenotation(symbol, info.asSeenFrom(pre, asSymDenotation.owner)) } class UniqueRefDenotation( @@ -533,12 +533,14 @@ object Denotations { def filterDisjoint(denots: PreDenotation)(implicit ctx: Context): PreDenotation /** Keep only those denotations in this group whose flags do not intersect - * with given `excluded` and that are accessible from prefix `pre`. - * Rewrite the infos to be as seen from `pre`. + * with `excluded`. */ - def filterAsSeenFrom(pre: Type, excluded: FlagSet)(implicit ctx: Context): PreDenotation + def filterExcluded(excluded: FlagSet)(implicit ctx: Context): PreDenotation + + /** The denotation with info(s) as seen from prefix type */ + def asSeenFrom(pre: Type)(implicit ctx: Context): PreDenotation - /** The union of two groups. */ + /** The union of two groups. */ def union(that: PreDenotation) = if (!this.exists) that else if (that.exists) this @@ -554,8 +556,10 @@ object Denotations { (denots1 containsSig sig) || (denots2 containsSig sig) def filterDisjoint(denots: PreDenotation)(implicit ctx: Context): PreDenotation = derivedUnion(denots1 filterDisjoint denots, denots2 filterDisjoint denots) - def filterAsSeenFrom(pre: Type, excluded: FlagSet)(implicit ctx: Context): PreDenotation = - derivedUnion(denots1.filterAsSeenFrom(pre, excluded), denots2.filterAsSeenFrom(pre, excluded)) + def filterExcluded(excluded: FlagSet)(implicit ctx: Context): PreDenotation = + derivedUnion(denots1.filterExcluded(excluded), denots2.filterExcluded(excluded)) + def asSeenFrom(pre: Type)(implicit ctx: Context): PreDenotation = + derivedUnion(denots1.asSeenFrom(pre), denots2.asSeenFrom(pre)) private def derivedUnion(denots1: PreDenotation, denots2: PreDenotation) = if ((denots1 eq this.denots1) && (denots2 eq this.denots2)) this else denots1 union denots2 @@ -577,7 +581,7 @@ object Denotations { else { val name = path slice (point + 1, len) val result = owner.info.member(name) - if (result.exists) result + if (result != NoDenotation) result else { val alt = missingHook(owner.symbol.moduleClass, name) if (alt.exists) alt.denot @@ -593,7 +597,7 @@ object Denotations { * enter it. */ def missingHook(owner: Symbol, name: Name)(implicit ctx: Context): Symbol = - if (owner.isPackage && name.isTermName) + if ((owner is Package) && name.isTermName) ctx.newCompletePackageSymbol(owner, name.asTermName).entered else NoSymbol diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala index d846e4405..14f31a16d 100644 --- a/src/dotty/tools/dotc/core/Flags.scala +++ b/src/dotty/tools/dotc/core/Flags.scala @@ -61,6 +61,9 @@ object Flags { */ def is(flags: FlagConjunction, butNot: FlagSet): Boolean = is(flags) && !is(butNot) + /** Is this flag set a subset of that one? */ + def <= (that: FlagSet) = (bits & that.bits) == bits + /** This flag set with all flags transposed to be type flags */ def toTypeFlags = FlagSet(bits & ~KINDFLAGS | TYPES) @@ -349,6 +352,10 @@ object Flags { commonFlags(Private, Protected, Abstract, Final, Sealed, Case, Implicit, AbsOverride, Lazy) + /** Flags guaranteed to be set upon symbol creation */ + final val FromStartFlags = + AccessFlags | Module | Package | Deferred + /** Flags representing access rights */ final val AccessFlags = Private | Protected | Local diff --git a/src/dotty/tools/dotc/core/Printers.scala b/src/dotty/tools/dotc/core/Printers.scala index 25fa2ca01..0b1d951aa 100644 --- a/src/dotty/tools/dotc/core/Printers.scala +++ b/src/dotty/tools/dotc/core/Printers.scala @@ -282,13 +282,13 @@ object Printers { /** Show kind of symbol */ def showKind(sym: Symbol) = - if (sym.isPackageClass) "package class" - else if (sym.isPackageVal) "package" + if (sym is PackageClass) "package class" + else if (sym is PackageVal) "package" else if (sym is PackageObjectClass) "package object class" else if (sym is PackageObjectVal) "package object" else if (sym.isAnonymousClass) "anonymous class" - else if (sym.isModuleClass) "module class" - else if (sym.isModuleVal) "module" + else if (sym is ModuleClass) "module class" + else if (sym is ModuleVal) "module" else if (sym is ImplClass) "implementation class" else if (sym is Trait) "trait" else if (sym.isClass) "class" @@ -310,8 +310,8 @@ object Printers { else if (sym.isClass) "class" else if (sym.isType && !(sym is ExpandedTypeParam)) "type" else if (sym is Mutable) "var" - else if (sym.isPackage) "package" - else if (sym.isModule) "object" + else if (sym is Package) "package" + else if (sym is Module) "object" else if (sym.isSourceMethod) "def" else if (sym.isTerm && (!(sym is Param))) "val" else "" @@ -406,7 +406,7 @@ object Printers { case ThisType(cls) => if (cls.isAnonymousClass) return "this." if (isOmittablePrefix(cls)) return "" - if (cls.isModuleClass) return showFullName(cls) + "." + if (cls is ModuleClass) return showFullName(cls) + "." case tp @ TermRef(pre, name) => val sym = tp.symbol if (sym is PackageObject) return showPrefix(pre) @@ -458,7 +458,7 @@ object Printers { } override def showKind(sym: Symbol) = - if (sym.isPackage) "package" + if (sym is Package) "package" else if (sym is PackageObject) "package object" else if (sym is Module) "object" else if (sym is ImplClass) "class" diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index f4d047d58..6dd45a4a2 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -67,10 +67,14 @@ object SymDenotations { /** UnsSet given flags(s) of this denotation */ final def resetFlag(flags: FlagSet): Unit = { _flags &~= flags } - final def is(fs: FlagSet) = flags is fs - final def is(fs: FlagSet, butNot: FlagSet) = flags is (fs, butNot) - final def is(fs: FlagConjunction) = flags is fs - final def is(fs: FlagConjunction, butNot: FlagSet) = flags is (fs, butNot) + final def is(fs: FlagSet) = + (if (fs <= FromStartFlags) _flags else flags) is fs + final def is(fs: FlagSet, butNot: FlagSet) = + (if (fs <= FromStartFlags) _flags else flags) is (fs, butNot) + final def is(fs: FlagConjunction) = + (if (fs <= FromStartFlags) _flags else flags) is fs + final def is(fs: FlagConjunction, butNot: FlagSet) = + (if (fs <= FromStartFlags) _flags else flags) is (fs, butNot) /** The type info. * The info is an instance of TypeType iff this is a type denotation @@ -174,16 +178,6 @@ object SymDenotations { /** Cast to class denotation */ final def asClass: ClassDenotation = asInstanceOf[ClassDenotation] - /** Special case tests for flags that are known a-priori and do not need loading - * flags. - */ - final def isModule = _flags is Module - final def isModuleVal = _flags is ModuleVal - final def isModuleClass = _flags is ModuleClass - final def isPackage = _flags is Package - final def isPackageVal = _flags is PackageVal - final def isPackageClass = _flags is PackageClass - /** is this symbol the result of an erroneous definition? */ def isError: Boolean = false @@ -228,7 +222,7 @@ object SymDenotations { def recur(sym: Symbol): Boolean = if (sym eq boundary) true else if (sym eq NoSymbol) false - else if (sym.isPackageClass && !boundary.isPackageClass) false + else if ((sym is PackageClass) && !(boundary is PackageClass)) false else recur(sym.owner) recur(symbol) } @@ -238,12 +232,12 @@ object SymDenotations { /** Is this a package class or module class that defines static symbols? */ final def isStaticOwner(implicit ctx: Context): Boolean = - isPackageClass || isModuleClass && isStatic + (this is PackageClass) || (this is ModuleClass) && isStatic /** Is this denotation defined in the same scope and compilation unit as that symbol? */ final def isCoDefinedWith(that: Symbol)(implicit ctx: Context) = (this.effectiveOwner == that.effectiveOwner) && - ( !this.effectiveOwner.isPackageClass + ( !(this.effectiveOwner is PackageClass) || { val thisFile = this.symbol.associatedFile val thatFile = that.symbol.associatedFile ( thisFile == null @@ -348,7 +342,7 @@ object SymDenotations { else if ( !( isType // allow accesses to types from arbitrary subclasses fixes #4737 || pre.baseType(cls).exists - || owner.isModuleClass // don't perform this check for static members + || (owner is ModuleClass) // don't perform this check for static members )) fail( s"""Access to protected ${symbol.show} not permitted because @@ -393,14 +387,14 @@ object SymDenotations { /** The class implementing this module, NoSymbol if not applicable. */ final def moduleClass: Symbol = _info match { - case info: TypeRefBySym if isModuleVal => info.fixedSym + case info: TypeRefBySym if this is ModuleVal => info.fixedSym case info: LazyModuleInfo => info.mclass case _ => NoSymbol } /** The module implemented by this module class, NoSymbol if not applicable. */ final def sourceModule: Symbol = _info match { - case ClassInfo(_, _, _, _, selfType: TermRefBySym) if isModuleClass => + case ClassInfo(_, _, _, _, selfType: TermRefBySym) if this is ModuleClass => selfType.fixedSym case info: LazyModuleClassInfo => info.modul @@ -444,11 +438,11 @@ object SymDenotations { /** The top-level symbol containing this denotation. */ final def topLevelSym(implicit ctx: Context): Symbol = - if (owner.isPackageClass) symbol else owner.topLevelSym + if (owner is PackageClass) symbol else owner.topLevelSym /** The package containing this denotation */ final def enclosingPackage(implicit ctx: Context): Symbol = - if (isPackageClass) symbol else owner.enclosingPackage + if (this is PackageClass) symbol else owner.enclosingPackage /** The module object with the same (term-) name as this class or module class, * and which is also defined in the same scope and compilation unit. @@ -456,7 +450,7 @@ object SymDenotations { */ final def companionModule(implicit ctx: Context): Symbol = { owner.info.decl(name.toTermName) - .suchThat(sym => sym.isModule && sym.isCoDefinedWith(symbol)) + .suchThat(sym => (sym is Module) && sym.isCoDefinedWith(symbol)) .symbol } @@ -474,7 +468,7 @@ object SymDenotations { * NoSymbol otherwise. */ final def linkedClass(implicit ctx: Context): Symbol = - if (this.isModuleClass) companionClass + if (this is ModuleClass) companionClass else if (this.isClass) companionModule.moduleClass else NoSymbol @@ -530,10 +524,6 @@ object SymDenotations { // ----- type-related ------------------------------------------------ - /** The denotation as seen from prefix type */ - def asSeenFrom(pre: Type)(implicit ctx: Context): SingleDenotation = - derivedSingleDenotation(symbol, info.asSeenFrom(pre, owner)) - /** The type parameters of a class symbol, Nil for all other symbols */ def typeParams(implicit ctx: Context): List[TypeSymbol] = Nil @@ -544,7 +534,7 @@ object SymDenotations { * @throws ClassCastException is this is not a type */ def typeConstructor(implicit ctx: Context): TypeRef = - if (isPackageClass || owner.isTerm) symbolicRef + if ((this is PackageClass) || owner.isTerm) symbolicRef else TypeRef(owner.thisType, name.asTypeName) /** The symbolic typeref representing the type constructor for this type. @@ -563,10 +553,10 @@ object SymDenotations { override def toString = { val kindString = - if (isModuleClass) "module class" + if (this is ModuleClass) "module class" else if (isClass) "class" else if (isType) "type" - else if (isModule) "module" + else if (this is Module) "module" else "val" s"$kindString $name" } @@ -638,7 +628,7 @@ object SymDenotations { private def computeThisType(implicit ctx: Context): Type = ThisType(classSymbol) /* was: - if (isPackageClass && !isRoot) + if ((this is PackageClass) && !isRoot) TermRef(owner.thisType, name.toTermName) else ThisType(classSymbol) @@ -792,7 +782,8 @@ object SymDenotations { case parentd: ClassDenotation => denots = denots union parentd.membersNamed(name) - .filterAsSeenFrom(thisType, Flags.Private) + .filterExcluded(Private) + .asSeenFrom(thisType) .filterDisjoint(ownDenots) case _ => } @@ -862,7 +853,7 @@ object SymDenotations { val candidates = inheritedNames ++ ownNames candidates filter (keepOnly(thisType, _)) } - if (isPackageClass) computeMemberNames // don't cache package member names; they might change + if (this is PackageClass) computeMemberNames // don't cache package member names; they might change else memberNamesCache get keepOnly match { case Some(names) => names @@ -901,6 +892,7 @@ object SymDenotations { override def isTerm = false override def isType = false override def owner: Symbol = throw new AssertionError("NoDenotation.owner") + override def asSeenFrom(pre: Type)(implicit ctx: Context): SingleDenotation = this validFor = Period.allInRun(NoRunId) // will be brought forward automatically } diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala index 41f45fcbd..93e8ed64a 100644 --- a/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -75,7 +75,7 @@ class SymbolLoaders { def enterClassAndModule(owner: Symbol, name: PreName, completer: SymbolLoader, flags: FlagSet = EmptyFlags)(implicit ctx: Context) { val clazz = enterClass(owner, name, completer, flags) val module = enterModule(owner, name, completer, flags) - /* + /* * !!! disabled for now because it causes CyclicReference. Need to revisit * if (!clazz.isAnonymousClass) { assert(clazz.companionModule == module, module) @@ -130,7 +130,7 @@ class SymbolLoaders { protected def description = "package loader " + classpath.name protected override def doComplete(root: SymDenotation) { - assert(root.isPackageClass, root) + assert(root is PackageClass, root) val pre = root.owner.thisType root.info = ClassInfo(pre, root.symbol.asClass, Nil, newScope, TermRef(pre, module)) if (!module.isCompleted) @@ -152,7 +152,7 @@ class SymbolLoaders { /** if there's a `package` member object in `pkgClass`, enter its members into it. */ def openPackageModule(pkgClass: ClassSymbol)(implicit ctx: Context) { val pkgModule = pkgClass.info.decl(nme.PACKAGEkw).symbol - if (pkgModule.isModule && + if ((pkgModule is Module) && (pkgModule.isCompleted || !pkgModule.completer.isInstanceOf[SourcefileLoader])) // println("open "+pkgModule)//DEBUG @@ -242,7 +242,7 @@ class ClassfileLoader(val classfile: AbstractFile)(implicit val cctx: CondensedC case d: ClassDenotation => d case d => throw new FatalError(s"linked class denot $d of $rootDenot is expected to be a ClassDenotation, but is a ${d.getClass}") } - if (rootDenot.isModuleClass) (linkedDenot, rootDenot) + if (rootDenot is ModuleClass) (linkedDenot, rootDenot) else (rootDenot, linkedDenot) } diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 52456f98d..213ddb765 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -256,7 +256,7 @@ trait Symbols { this: Context => def requiredPackage(path: PreName): TermSymbol = { val pathName = path.toTermName - base.staticRef(pathName).requiredSymbol(_.isPackage, pathName).asTerm + base.staticRef(pathName).requiredSymbol(_ is Package, pathName).asTerm } def requiredClass(path: PreName): ClassSymbol = { @@ -266,7 +266,7 @@ trait Symbols { this: Context => def requiredModule(path: PreName): TermSymbol = { val pathName = path.toTermName - base.staticRef(pathName).requiredSymbol(_.isModule, pathName).asTerm + base.staticRef(pathName).requiredSymbol(_ is Module, pathName).asTerm } } @@ -383,7 +383,7 @@ object Symbols { /** The source or class file from which this class was generated, null if not applicable. */ override def associatedFile(implicit ctx: Context): AbstractFile = - if (this.owner.isPackageClass) assocFile + if (this.owner is PackageClass) assocFile else super.associatedFile final def classDenot(implicit ctx: Context): ClassDenotation = diff --git a/src/dotty/tools/dotc/core/TypeComparers.scala b/src/dotty/tools/dotc/core/TypeComparers.scala index f07ec5b9e..5f92d65c9 100644 --- a/src/dotty/tools/dotc/core/TypeComparers.scala +++ b/src/dotty/tools/dotc/core/TypeComparers.scala @@ -65,7 +65,7 @@ object TypeComparers { val pre2 = tp2.prefix if (sym1 == sym2) ( ctx.erasedTypes - || sym1.owner.isPackage + || (sym1.owner is Package) || isSubType(pre1, pre2) ) else ( tp1.name == tp2.name && isSubType(pre1, pre2) diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 4b2f3f09f..7660b8f2d 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -7,7 +7,7 @@ trait TypeOps { this: Context => final def asSeenFrom(tp: Type, pre: Type, cls: Symbol, theMap: AsSeenFromMap): Type = { def toPrefix(pre: Type, cls: Symbol, thiscls: ClassSymbol): Type = - if ((pre eq NoType) || (pre eq NoPrefix) || cls.isPackageClass) + if ((pre eq NoType) || (pre eq NoPrefix) || (cls is PackageClass)) tp else if (thiscls.isNonBottomSubClass(cls) && pre.baseType(thiscls).exists) pre match { diff --git a/src/dotty/tools/dotc/core/TypedTrees.scala b/src/dotty/tools/dotc/core/TypedTrees.scala index e87410b30..791f0b40a 100644 --- a/src/dotty/tools/dotc/core/TypedTrees.scala +++ b/src/dotty/tools/dotc/core/TypedTrees.scala @@ -620,7 +620,7 @@ object TypedTrees { check(expr.tpe.termSymbol.isStable) case PackageDef(pid, stats) => check(pid.isTerm) - check(pid.symbol.isPackage) + check(pid.symbol is Package) case Annotated(annot, arg) => check(annot.isInstantiation) check(annot.symbol.owner.isSubClass(defn.AnnotationClass)) diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index b8993f71c..80a56d76b 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -88,7 +88,7 @@ object Types { * be refined later. */ final def isNotNull(implicit ctx: Context): Boolean = - widen.typeSymbol.isModuleClass + widen.typeSymbol is ModuleClass /** Is this type produced as a repair for an error? */ final def isError(implicit ctx: Context): Boolean = @@ -227,7 +227,7 @@ object Types { */ final def findDecl(name: Name, excluded: FlagSet)(implicit ctx: Context): Denotation = this match { case tp: ClassInfo => - tp.decls.denotsNamed(name).filterAsSeenFrom(NoPrefix, excluded).toDenot + tp.decls.denotsNamed(name).filterExcluded(excluded).toDenot case tp: TypeProxy => tp.underlying.findDecl(name, excluded) } @@ -256,7 +256,7 @@ object Types { tp.underlying.findMember(name, pre, excluded) case tp: ClassInfo => val candidates = tp.cls.membersNamed(name) - candidates.filterAsSeenFrom(pre, excluded).toDenot + candidates.filterExcluded(excluded).asSeenFrom(pre).toDenot case AndType(l, r) => l.findMember(name, pre, excluded) & r.findMember(name, pre, excluded) case OrType(l, r) => diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index abdd94dad..a5a09a4cd 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -135,7 +135,7 @@ class ClassfileParser( /** Add type parameters of enclosing classes */ def addEnclosingTParams { var sym = classRoot.owner - while (sym.isClass && !sym.isModuleClass) { + while (sym.isClass && !(sym is Flags.ModuleClass)) { for (tparam <- sym.typeParams) { classTParams = classTParams.updated(tparam.name, tparam) } diff --git a/src/dotty/tools/dotc/core/transform/Erasure.scala b/src/dotty/tools/dotc/core/transform/Erasure.scala index 6ee6484df..d10415829 100644 --- a/src/dotty/tools/dotc/core/transform/Erasure.scala +++ b/src/dotty/tools/dotc/core/transform/Erasure.scala @@ -37,7 +37,7 @@ object Erasure { val sym = tp.symbol if (sym.isClass) /*if (sym.isDerivedValueClass) eraseDerivedValueClassRef(tref) - else */if (sym.owner.isPackage) normalizeClass(sym.asClass).typeConstructor + else */if (sym.owner is Package) normalizeClass(sym.asClass).typeConstructor else tp.derivedNamedType(erasure(tp.prefix)) else erasure(sym.info) case tp: RefinedType => @@ -104,7 +104,7 @@ object Erasure { val sym = tp.symbol if (sym.isClass) /*if (sym.isDerivedValueClass) eraseDerivedValueClassRef(tref) - else */if (sym.owner.isPackage) normalizeClass(sym.asClass).name + else */if (sym.owner is Package) normalizeClass(sym.asClass).name else sym.asClass.name else paramSignature(sym.info) case tp: RefinedType => -- cgit v1.2.3