diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/Annotations.scala | 15 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Contexts.scala | 5 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Flags.scala | 14 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Printers.scala | 9 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 69 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymbolLoaders.scala | 12 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Symbols.scala | 8 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 53 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/flagtest.sc | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/ClassfileParser.scala | 15 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 23 | ||||
-rw-r--r-- | src/dotty/tools/dotc/reporting/Reporter.scala | 10 | ||||
-rw-r--r-- | src/test/loadDefs.scala (renamed from src/test/test1.scala) | 2 |
14 files changed, 170 insertions, 70 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala index ff05c9faa..acd5258b9 100644 --- a/src/dotty/tools/dotc/core/Annotations.scala +++ b/src/dotty/tools/dotc/core/Annotations.scala @@ -16,6 +16,15 @@ object Annotations { case class ConcreteAnnotation(val tree: Tree) extends Annotation + case class LazyAnnotation(sym: Symbol)(treeFn: => Tree) extends Annotation { + private var _tree: Tree = null + def tree = { + if (_tree == null) _tree = treeFn + _tree + } + override def symbol(implicit ctx: Context): Symbol = sym + } + object Annotation { def apply(tree: Tree) = ConcreteAnnotation(tree) @@ -38,6 +47,12 @@ object Annotations { def apply(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation = apply(New(atp, args)) + def deferred(sym: Symbol, treeFn: => Tree): Annotation = + new LazyAnnotation(sym)(treeFn) + + def deferred(atp: Type, args: List[Tree])(implicit ctx: Context): Annotation = + deferred(atp.typeSymbol, New(atp, args)) + def makeAlias(sym: TermSymbol)(implicit ctx: Context) = apply(defn.AliasAnnot, List(Ident(TermRef(sym.owner.thisType, sym.name, sym.signature)))) diff --git a/src/dotty/tools/dotc/core/Contexts.scala b/src/dotty/tools/dotc/core/Contexts.scala index fd2ce2251..d2b41b9a3 100644 --- a/src/dotty/tools/dotc/core/Contexts.scala +++ b/src/dotty/tools/dotc/core/Contexts.scala @@ -334,6 +334,11 @@ object Contexts { // Printers state /** Number of recursive invocations of a show method on cuyrrent stack */ private[core] var showRecursions = 0 + + // Reporters state + private[dotc] var indent = 0 + + protected[dotc] val indentTab = " " } object Context { diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index 170233ee2..c3486aa0a 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -530,7 +530,7 @@ object Denotations { /** The union of two groups. */ def union(that: PreDenotation) = if (!this.exists) that - else if (that.exists) this + else if (!that.exists) this else DenotUnion(this, that) } diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala index 1a8ff3ea8..20be08d46 100644 --- a/src/dotty/tools/dotc/core/Flags.scala +++ b/src/dotty/tools/dotc/core/Flags.scala @@ -240,10 +240,11 @@ object Flags { final val PackageVal = Package.toTermFlags final val PackageClass = Package.toTypeFlags - /** A package object or its module class */ + /** A package object or its module class (unused) final val PackageObject = commonFlag(17, "package") final val PackageObjectVal = PackageObject.toTermFlags final val PackageObjectClass = PackageObject.toTypeFlags + */ /** A case class or its companion object */ final val Case = commonFlag(17, "case") @@ -355,13 +356,13 @@ object Flags { commonFlags(Private, Protected, Abstract, Final, Sealed, Case, Implicit, AbsOverride, Lazy) + /** Flags representing access rights */ + final val AccessFlags = Private | Protected | Local + /** Flags guaranteed to be set upon symbol creation */ final val FromStartFlags = AccessFlags | Module | Package | Deferred | Param | Scala2ExistentialCommon - /** Flags representing access rights */ - final val AccessFlags = Private | Protected | Local - /** A value that's unstable unless complemented with a Stable flag */ final val UnstableValue = Mutable | Method @@ -382,7 +383,7 @@ object Flags { * are added at creation anyway */ final val RetainedModuleValAndClassFlags: FlagSet = - AccessFlags | Package | PackageObject | Case | + AccessFlags | Package | Case | Synthetic | ExpandedName | JavaDefined | Static | Artifact | Erroneous | Lifted | MixedIn | Specialized @@ -397,8 +398,7 @@ object Flags { /** Packages and package classes always have these flags set */ final val PackageCreationFlags = - (Module | Package | Final | JavaDefined | Static).toTermFlags - final val PackageClassCreationFlags = PackageCreationFlags.toTypeFlags + Module | Package | Final | JavaDefined | Static /** These flags are pickled */ final val PickledFlags = flagRange(FirstFlag, FirstNotPickledFlag) diff --git a/src/dotty/tools/dotc/core/Printers.scala b/src/dotty/tools/dotc/core/Printers.scala index 6e89b2034..c90e5f39c 100644 --- a/src/dotty/tools/dotc/core/Printers.scala +++ b/src/dotty/tools/dotc/core/Printers.scala @@ -284,8 +284,9 @@ object Printers { def showKind(sym: Symbol) = 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.isPackageObject) + if (sym.isClass) "package object class" + else "package object" else if (sym.isAnonymousClass) "anonymous class" else if (sym is ModuleClass) "module class" else if (sym is ModuleVal) "module" @@ -411,7 +412,7 @@ object Printers { if (cls is ModuleClass) return showFullName(cls) + "." case tp @ TermRef(pre, name) => val sym = tp.symbol - if (sym is PackageObject) return showPrefix(pre) + if (sym.isPackageObject) return showPrefix(pre) if (isOmittablePrefix(sym)) return "" case _ => } @@ -461,7 +462,7 @@ object Printers { override def showKind(sym: Symbol) = if (sym is Package) "package" - else if (sym is PackageObject) "package object" + else if (sym.isPackageObject) "package object" else if (sym is Module) "object" else if (sym is ImplClass) "class" else if (sym.isClassConstructor) "constructor" diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index 1bbeb1009..029b6035b 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -46,26 +46,25 @@ object SymDenotations { // ------ Getting and setting fields ----------------------------- - private[this] var _flags: FlagSet = initFlags + private[this] var _flags: FlagSet = adaptFlags(initFlags) private[this] var _info: Type = initInfo private[this] var _privateWithin: Symbol = initPrivateWithin private[this] var _annotations: List[Annotation] = Nil - if (isType) assert(_flags.toTypeFlags == _flags, this.name + " " + _flags) - if (isTerm) assert(_flags.toTermFlags == _flags, this.name + " " + _flags) - /** The owner of the symbol */ def owner: Symbol = _owner /** The flag set */ final def flags: FlagSet = { ensureCompleted(); _flags } + final def flagsUNSAFE = _flags // !!! DEBUG; drop when no longer needed + + /** Adapt flag set to this denotation's term or type nature */ + def adaptFlags(flags: FlagSet) = if (isType) flags.toTypeFlags else flags.toTermFlags + /** Update the flag set */ - private[core] final def flags_=(flags: FlagSet): Unit = { - _flags = flags - if (isType) assert(_flags.toTypeFlags == _flags, this.name) - if (isTerm) assert(_flags.toTermFlags == _flags, this.name) - } + private final def flags_=(flags: FlagSet): Unit = + _flags = adaptFlags(flags) /** Set given flags(s) of this denotation */ final def setFlag(flags: FlagSet): Unit = { _flags |= flags } @@ -126,14 +125,16 @@ object SymDenotations { } /** Update the annotations of this denotation */ - private[core] final def annotations_=(annots: List[Annotation]): Unit = { _annotations = annots } + private[core] final def annotations_=(annots: List[Annotation]): Unit = + _annotations = annots /** Does this denotation have an annotation matching the given class symbol? */ - final def hasAnnotation(cls: Symbol)(implicit ctx: Context) = dropOtherAnnotations(annotations, cls).nonEmpty + final def hasAnnotation(cls: Symbol)(implicit ctx: Context) = + dropOtherAnnotations(annotations, cls).nonEmpty /** Add given annotation to the annotations of this denotation */ - final def addAnnotation(annot: Annotation): Unit = annotations = - annot :: annotations + final def addAnnotation(annot: Annotation): Unit = + annotations = annot :: _annotations @tailrec private def dropOtherAnnotations(anns: List[Annotation], cls: Symbol)(implicit ctx: Context): List[Annotation] = anns match { @@ -207,6 +208,10 @@ object SymDenotations { final def isAnonymousClass(implicit ctx: Context): Boolean = initial.asSymDenotation.name startsWith tpnme.ANON_CLASS + /** Is this symbol a package object or its module class? */ + def isPackageObject(implicit ctx: Context): Boolean = + (name.toTermName == nme.PACKAGEkw) && (owner is Package) && (this is Module) + /** Is this symbol an abstract type? */ final def isAbstractType = isType && (this is Deferred) @@ -429,7 +434,7 @@ object SymDenotations { * otherwise the denoting symbol. */ final def skipPackageObject(implicit ctx: Context): Symbol = - if (this is PackageObject) owner else symbol + if (isPackageObject) owner else symbol /** The owner, skipping package objects. */ final def effectiveOwner(implicit ctx: Context) = owner.skipPackageObject @@ -622,7 +627,7 @@ object SymDenotations { /** The type parameters of this class */ override final def typeParams(implicit ctx: Context): List[TypeSymbol] = { - if (_typeParams == null) _typeParams == computeTypeParams + if (_typeParams == null) _typeParams = computeTypeParams _typeParams } @@ -784,29 +789,33 @@ object SymDenotations { final def membersNamed(name: Name)(implicit ctx: Context): PreDenotation = { var denots: PreDenotation = memberCache lookup name if (denots == null) { - if (!classSymbol.hasChildren || (memberFingerPrint contains name)) { - val ownDenots = info.decls.denotsNamed(name) - denots = ownDenots - var ps = classInfo.classParents - while (ps.nonEmpty) { - val parentSym = ps.head.symbol - parentSym.denot match { + denots = computeMembersNamed(name) + memberCache enter (name, denots) + } + denots + } + + private def computeMembersNamed(name: Name)(implicit ctx: Context): PreDenotation = + if (!classSymbol.hasChildren || (memberFingerPrint contains name)) { + val ownDenots = info.decls.denotsNamed(name) + def collect(denots: PreDenotation, parents: List[TypeRef]): PreDenotation = parents match { + case p :: ps => + val denots1 = p.symbol.denot match { case parentd: ClassDenotation => - denots = denots union + denots union parentd.membersNamed(name) .filterExcluded(Private) .asSeenFrom(thisType) .filterDisjoint(ownDenots) case _ => + denots } - } - } else { - denots = NoDenotation + collect(denots1, ps) + case _ => + denots } - memberCache enter (name, denots) - } - denots - } + collect(ownDenots, classInfo.classParents) + } else NoDenotation private[this] var baseTypeCache: java.util.HashMap[CachedType, Type] = null private[this] var baseTypeValid: RunId = NoRunId diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala index c3b3a944f..41c4c727b 100644 --- a/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -67,7 +67,7 @@ class SymbolLoaders { return NoSymbol } } - ctx.newModuleSymbol(owner, pname, PackageCreationFlags, PackageClassCreationFlags, + ctx.newModuleSymbol(owner, pname, PackageCreationFlags, PackageCreationFlags, (module, modcls) => new PackageLoader(module, pkg)).entered } @@ -212,16 +212,16 @@ trait SymbolLoader extends LazyType { else "error while loading " + root.name + ",\n " + msg) } try { - // println("trying to complete "+root) // !!! DEBUG val start = currentTime - doComplete(root) + cctx.traceIndented(s">>>> loading ${root.debugString}", s"<<<< loaded ${root.debugString}") { + doComplete(root) + } cctx.informTime("loaded " + description, start) } catch { case ex: IOException => signalError(ex) - case ex: Throwable => // !!! DEBUG - println("caught: "+ex) - ex.printStackTrace() + case ex: Throwable => + println(s"exception caught when loading $root: $ex") throw ex } finally { def postProcess(denot: SymDenotation) = diff --git a/src/dotty/tools/dotc/core/Symbols.scala b/src/dotty/tools/dotc/core/Symbols.scala index 809265856..57c29f66e 100644 --- a/src/dotty/tools/dotc/core/Symbols.scala +++ b/src/dotty/tools/dotc/core/Symbols.scala @@ -117,10 +117,10 @@ trait Symbols { this: Context => val module = newNakedSymbol[TermName](coord) val modcls = newNakedClassSymbol(coord, assocFile) val cdenot = SymDenotation( - modcls, owner, name.toTypeName, clsFlags, + modcls, owner, name.toTypeName, clsFlags | ModuleClassCreationFlags, infoFn(module, modcls), privateWithin) val mdenot = SymDenotation( - module, owner, name, modFlags, + module, owner, name, modFlags | ModuleCreationFlags, if (cdenot.isCompleted) TypeRef(owner.thisType, name.toTypeName, modcls) else new LazyModuleInfo(modcls)(condensed)) module.denot = mdenot @@ -156,7 +156,7 @@ trait Symbols { this: Context => owner: Symbol, name: TermName, infoFn: (TermSymbol, ClassSymbol) => LazyType): TermSymbol = - newModuleSymbol(owner, name, PackageCreationFlags, PackageClassCreationFlags, infoFn) + newModuleSymbol(owner, name, PackageCreationFlags, PackageCreationFlags, infoFn) /** Create a package symbol with associated package class * from its non-info fields its member scope. @@ -169,7 +169,7 @@ trait Symbols { this: Context => decls: Scope = newScope): TermSymbol = newCompleteModuleSymbol( owner, name, - modFlags | PackageCreationFlags, clsFlags | PackageClassCreationFlags, + modFlags | PackageCreationFlags, clsFlags | PackageCreationFlags, Nil, decls) diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 966150ab3..526b1014d 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -30,6 +30,14 @@ object Types { */ private final val NotCachedAlt = Int.MinValue + /** A value that indicates that the hash code is unknown + */ + private final val HashUnknown = 1234 + + /** An alternative value if computeHash would otherwise yield HashUnknown + */ + private final val HashUnknownAlt = 4321 + /** The class of types. * The principal subclasses and sub-objects are as follows: * @@ -682,7 +690,14 @@ object Types { /** Instances of this class are cached and are not proxies. */ abstract class CachedGroundType extends Type with CachedType { - final val hash = computeHash + private[this] var _hash = HashUnknown + final def hash = { + if (_hash == HashUnknown) { + _hash == computeHash + if (_hash == HashUnknown) _hash = HashUnknownAlt + } + _hash + } override final def hashCode = if (hash == NotCached) System.identityHashCode(this) else hash def computeHash: Int @@ -690,7 +705,14 @@ object Types { /** Instances of this class are cached and are proxies. */ abstract class CachedProxyType extends TypeProxy with CachedType { - final val hash = computeHash + private[this] var _hash = HashUnknown + final def hash = { + if (_hash == HashUnknown) { + _hash == computeHash + if (_hash == HashUnknown) _hash = HashUnknownAlt + } + _hash + } override final def hashCode = if (hash == NotCached) System.identityHashCode(this) else hash def computeHash: Int @@ -822,6 +844,14 @@ object Types { val owner = denot.owner if (owner.isTerm) denot else denot.asSeenFrom(prefix) } + override def equals(that: Any) = that match { + case that: HasFixedSym => + this.prefix == that.prefix && + this.fixedSym == that.fixedSym + case _ => + false + } + override def computeHash = doHash(fixedSym, prefix) } final class TermRefBySym(prefix: Type, name: TermName, val fixedSym: TermSymbol) @@ -831,14 +861,22 @@ object Types { else TermRef(prefix, name, fixedSym.signature) } - final class TermRefWithSignature(prefix: Type, name: TermName, sig: Signature) extends TermRef(prefix, name) { + final class TermRefWithSignature(prefix: Type, name: TermName, val sig: Signature) extends TermRef(prefix, name) { override def signature(implicit ctx: Context) = sig - override def computeHash = doHash((name, sig), prefix) - override def loadDenot(implicit ctx: Context): Denotation = + override def loadDenot(implicit ctx: Context): Denotation = super.loadDenot.atSignature(sig) override def newLikeThis(prefix: Type)(implicit ctx: Context): TermRefWithSignature = TermRef(prefix, name, sig) - } + override def equals(that: Any) = that match { + case that: TermRefWithSignature => + this.prefix == that.prefix && + this.name == that.name && + this.sig == that.sig + case _ => + false + } + override def computeHash = doHash((name, sig), prefix) + } final class TypeRefBySym(prefix: Type, name: TypeName, val fixedSym: TypeSymbol) extends TypeRef(prefix, name) with HasFixedSym { @@ -1196,7 +1234,8 @@ object Types { if (optSelfType.exists) optSelfType else cls.typeConstructor def rebase(tp: Type)(implicit ctx: Context): Type = - tp.substThis(cls, prefix) + if (prefix eq cls.owner.thisType) tp + else tp.substThis(cls, prefix) def typeConstructor(implicit ctx: Context): Type = NamedType(prefix, cls.name) diff --git a/src/dotty/tools/dotc/core/flagtest.sc b/src/dotty/tools/dotc/core/flagtest.sc index f9de76b9e..bd1a9bd25 100644 --- a/src/dotty/tools/dotc/core/flagtest.sc +++ b/src/dotty/tools/dotc/core/flagtest.sc @@ -19,4 +19,7 @@ object flagtest { Abstract //> res7: dotty.tools.dotc.core.Flags.FlagSet = abstract Method == Abstract //> res8: Boolean = false Method.toCommonFlags //> res9: dotty.tools.dotc.core.Flags.FlagSet = <method> abstract + FromStartFlags //> res10: dotty.tools.dotc.core.Flags.FlagSet = private protected <deferred> <p + //| aram> <local> module <package> <existential> + AccessFlags <= FromStartFlags //> res11: Boolean = true }
\ No newline at end of file diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index 8699033bd..1b2672c4a 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -113,8 +113,8 @@ class ClassfileParser( enterOwnInnerClasses - classRoot.flags = sflags - moduleRoot.flags = Flags.JavaDefined | Flags.ModuleClassCreationFlags + classRoot.setFlag(sflags) + moduleRoot.setFlag(Flags.JavaDefined | Flags.ModuleClassCreationFlags) setPrivateWithin(classRoot, jflags) setPrivateWithin(moduleRoot, jflags) @@ -150,9 +150,11 @@ class ClassfileParser( if (method) FlagTranslation.methodFlags(jflags) else FlagTranslation.fieldFlags(jflags) val name = pool.getName(in.nextChar) - if (!(sflags is Flags.Private) || name == nme.CONSTRUCTOR || settings.optimise.value) - cctx.newSymbol( - getOwner(jflags), name, sflags, memberCompleter, coord = start).entered + if (!(sflags is Flags.Private) || name == nme.CONSTRUCTOR || settings.optimise.value) { + val member = cctx.newSymbol( + getOwner(jflags), name, sflags, memberCompleter, coord = start) + getScope(jflags).enter(member) + } // skip rest of member for now in.nextChar // info skipAttributes @@ -341,6 +343,7 @@ class ClassfileParser( sig2typeBounds(tparams, skiptvs = true) newTParams += s } + index += 1 } val ownTypeParams = newTParams.toList val tpe = @@ -405,7 +408,7 @@ class ClassfileParser( } } if (hasError || skip) None - else Some(Annotation(attrType, argbuf.toList)) + else Some(Annotation.deferred(attrType, argbuf.toList)) } catch { case f: FatalError => throw f // don't eat fatal errors, they mean a class was not found case ex: Throwable => diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index c26b33758..de6dc053e 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -82,7 +82,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: }) } - print("unpickling "); showPickled() // !!! DEBUG + // print("unpickling "); showPickled() // !!! DEBUG import UnPickler._ @@ -319,6 +319,8 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: NoSymbol } + // println(s"read ext symbol $name from ${owner.denot.debugString} in ${classRoot.debugString}") // !!! DEBUG + // (1) Try name. fromName(name) orElse { // (2) Try with expanded name. Can happen if references to private @@ -378,6 +380,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: var name1 = name.asTypeName var flags1 = flags if (flags is TypeParam) { + // println(s"expanding name of type parameter $name, owner = ${owner.denot}, completed = ${owner.isCompleted}") // !!! DEBUG name1 = name1.expandedName(owner) flags1 |= TypeParamCreationFlags } @@ -520,7 +523,9 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: val tycon = if (isLocal(sym)) TypeRef(pre, sym.asType) else TypeRef(pre, sym.name.asTypeName) - tycon.appliedTo(until(end, readTypeRef)) + val args = until(end, readTypeRef) + // println(s"reading app type $tycon $args") // !!! DEBUG + tycon.appliedTo(args) case TYPEBOUNDStpe => TypeBounds(readTypeRef(), readTypeRef()) case REFINEDtpe => @@ -704,7 +709,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: errorBadSignature("symbol annotation expected (" + tag + ")") val end = readNat() + readIndex val target = readSymbolRef() - target.addAnnotation(ConcreteAnnotation(readAnnotationContents(end))) + target.addAnnotation(deferredAnnot(end)) } /** Read an annotation and return it. Used when unpickling @@ -715,7 +720,17 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: if (tag != ANNOTINFO) errorBadSignature("annotation expected (" + tag + ")") val end = readNat() + readIndex - ConcreteAnnotation(readAnnotationContents(end)) + deferredAnnot(end) + } + + /** A deferred annotation that can be comleted by reading + * the bytes between `readIndex` and `end`. + */ + protected def deferredAnnot(end: Int): Annotation = { + val start = readIndex + val atp = readTypeRef() + Annotation.deferred( + atp.typeSymbol, atReadPos(start, () => readAnnotationContents(end))) } /* Read an abstract syntax tree */ diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index cab75cbfd..723af8768 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -35,6 +35,16 @@ trait Reporting { this: Context => log(msg + " " + value) value } + + def traceIndented[T](leading: => String, trailing: => String)(op: => T): T = + try { + log(s"${base.indentTab * base.indent}$leading") + base.indent += 1 + op + } finally { + base.indent -= 1 + log(s"${base.indentTab * base.indent}$trailing") + } } object Reporter { diff --git a/src/test/test1.scala b/src/test/loadDefs.scala index 272feab66..77115d93b 100644 --- a/src/test/test1.scala +++ b/src/test/loadDefs.scala @@ -3,7 +3,7 @@ package test import dotty.tools.dotc.core._ import Contexts._ -object test1 { +object loadDefs { def main(args: Array[String]) = { val base = new ContextBase |