diff options
Diffstat (limited to 'src/dotty/tools/dotc/core')
-rw-r--r-- | src/dotty/tools/dotc/core/Annotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Substituters.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 31 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/UnPickler.scala | 12 |
5 files changed, 30 insertions, 19 deletions
diff --git a/src/dotty/tools/dotc/core/Annotations.scala b/src/dotty/tools/dotc/core/Annotations.scala index 8b7cb7bd7..90b916971 100644 --- a/src/dotty/tools/dotc/core/Annotations.scala +++ b/src/dotty/tools/dotc/core/Annotations.scala @@ -58,7 +58,7 @@ object Annotations { apply(defn.AliasAnnot, List(Ident(TermRef.withSig(sym.owner.thisType, sym.name, sym.signature).withDenot(sym)))) def makeChild(sym: Symbol)(implicit ctx: Context) = - apply(defn.ChildAnnot.typeConstructor.appliedTo(NamedType(sym.owner.thisType, sym.name).withDenot(sym)), Nil) + apply(defn.ChildAnnot.typeConstructor.appliedTo(sym.owner.thisType.select(sym.name, sym)), Nil) } def ThrowsAnnotation(cls: ClassSymbol)(implicit ctx: Context) = { diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala index 27a2722f2..763c3eea7 100644 --- a/src/dotty/tools/dotc/core/Substituters.scala +++ b/src/dotty/tools/dotc/core/Substituters.scala @@ -88,7 +88,7 @@ trait Substituters { this: Context => var fs = from var ts = to while (fs.nonEmpty) { - if (fs.head eq sym) return NamedType.withSym(tp.prefix, ts.head) + if (fs.head eq sym) return tp.prefix select ts.head fs = fs.tail ts = ts.tail } diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index af2e6a8ca..de4a1d8e3 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -651,7 +651,7 @@ object SymDenotations { TermRef.withSym(owner.thisType, symbol.asTerm) def symRef(implicit ctx: Context): NamedType = - NamedType.withSym(owner.thisType, symbol) + if (isType) symTypeRef else symTermRef /** The variance of this type parameter or type member as an Int, with * +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 2cb14bf8f..d6dc81d4e 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -679,17 +679,31 @@ object Types { } /** The type <this . name> , reduced if possible */ - def select(name: Name)(implicit ctx: Context): Type = { - val res = lookupRefined(this, name) - if (res.exists) res else NamedType(this, name) + def select(name: Name)(implicit ctx: Context): Type = name match { + case name: TermName => + TermRef(this, name) + case name: TypeName => + val res = lookupRefined(this, name) + if (res.exists) res else TypeRef(this, name) } - /** The type <this . name> with given symbol, reduced if possible */ - def select(sym: Symbol)(implicit ctx: Context): Type = { - val res = lookupRefined(this, sym.name) - if (res.exists) res else NamedType.withSym(this, sym) + /** The type <this . name> , reduced if possible, with given denotation if undreduced */ + def select(name: Name, denot: Denotation)(implicit ctx: Context): Type = name match { + case name: TermName => + TermRef(this, name).withDenot(denot) + case name: TypeName => + val res = lookupRefined(this, name) + if (res.exists) res else TypeRef(this, name).withDenot(denot) } + /** The type <this . name> with given symbol, reduced if possible */ + def select(sym: Symbol)(implicit ctx: Context): Type = + if (sym.isTerm) TermRef.withSym(this, sym.asTerm) + else { + val res = lookupRefined(this, sym.name) + if (res.exists) res else TypeRef.withSym(this, sym.asType) + } + protected def lookupRefined(pre: Type, name: Name)(implicit ctx: Context): Type = pre.stripTypeVar match { case pre: RefinedType => if (pre.refinedName ne name) lookupRefined(pre.parent, name) @@ -1551,9 +1565,6 @@ object Types { def apply(prefix: Type, name: Name)(implicit ctx: Context) = if (name.isTermName) TermRef(prefix, name.asTermName) else TypeRef(prefix, name.asTypeName) - def withSym(prefix: Type, sym: Symbol)(implicit ctx: Context) = - if (sym.isTerm) TermRef.withSym(prefix, sym.asTerm) - else TypeRef.withSym(prefix, sym.asType) } object TermRef { diff --git a/src/dotty/tools/dotc/core/pickling/UnPickler.scala b/src/dotty/tools/dotc/core/pickling/UnPickler.scala index 465e4a060..400fcba86 100644 --- a/src/dotty/tools/dotc/core/pickling/UnPickler.scala +++ b/src/dotty/tools/dotc/core/pickling/UnPickler.scala @@ -934,7 +934,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: val ldef = DefDef(symbol.asTerm, rhs) def isCaseLabel(sym: Symbol) = sym.name.startsWith(nme.CASEkw) if (isCaseLabel(symbol)) ldef - else Block(ldef :: Nil, Apply(Ident(refType(symbol)), Nil)) + else Block(ldef :: Nil, Apply(Ident(symbol.symRef), Nil)) case IMPORTtree => setSym() @@ -955,7 +955,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: val self = readValDefRef() val body = until(end, readTreeRef) untpd.Template(???, parents, self, body) // !!! TODO: pull out primary constructor - .withType(refType(symbol)) + .withType(symbol.symRef) case BLOCKtree => val expr = readTreeRef() @@ -1016,7 +1016,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: case RETURNtree => setSym() - Return(readTreeRef(), Ident(refType(symbol))) + Return(readTreeRef(), Ident(symbol.symRef)) case TREtree => val block = readTreeRef() @@ -1072,11 +1072,11 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: setSym() val qualifier = readTreeRef() val selector = readNameRef() - Select(qualifier, refType(symbol)) + Select(qualifier, symbol.symRef) case IDENTtree => setSymName() - Ident(refType(symbol)) + Ident(symbol.symRef) case LITERALtree => Literal(readConstantRef()) @@ -1095,7 +1095,7 @@ class UnPickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClassRoot: case SELECTFROMTYPEtree => val qualifier = readTreeRef() val selector = readTypeNameRef() - SelectFromTypeTree(qualifier, refType(symbol)) + SelectFromTypeTree(qualifier, symbol.symRef) case COMPOUNDTYPEtree => readTemplateRef() |