diff options
author | Martin Odersky <odersky@gmail.com> | 2014-09-21 14:13:09 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-10-11 08:24:35 +0200 |
commit | 8975b85958e4d600eebb843c4847e52486c33f46 (patch) | |
tree | 1c4e2e89debed1cf86ec447833afd48eee850c7c /src | |
parent | c93f545dc344d4acebdb84dc76eae062eaf67ce0 (diff) | |
download | dotty-8975b85958e4d600eebb843c4847e52486c33f46.tar.gz dotty-8975b85958e4d600eebb843c4847e52486c33f46.tar.bz2 dotty-8975b85958e4d600eebb843c4847e52486c33f46.zip |
Drop type declarations from erased ClassInfo
Need to drop all non-class type declarations.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/TypeErasure.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Scopes.scala | 19 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/TypeErasure.scala b/src/dotty/tools/dotc/TypeErasure.scala index 1e3bc5ca6..f6c62cf30 100644 --- a/src/dotty/tools/dotc/TypeErasure.scala +++ b/src/dotty/tools/dotc/TypeErasure.scala @@ -269,7 +269,8 @@ class TypeErasure(isJava: Boolean, isSemi: Boolean, isConstructor: Boolean, wild val parents: List[TypeRef] = if ((cls eq defn.ObjectClass) || cls.isPrimitiveValueClass) Nil else removeLaterObjects(classParents.mapConserve(eraseTypeRef)) - tp.derivedClassInfo(NoPrefix, parents, decls, this(tp.selfType)) + val erasedDecls = decls.filteredScope(d => !d.isType || d.isClass) + tp.derivedClassInfo(NoPrefix, parents, erasedDecls, this(tp.selfType)) // can't replace selftype by NoType because this would lose the sourceModule link } case NoType | NoPrefix | ErrorType | JavaArrayType(_) => diff --git a/src/dotty/tools/dotc/core/Scopes.scala b/src/dotty/tools/dotc/core/Scopes.scala index 54317a496..3f7a4cb2c 100644 --- a/src/dotty/tools/dotc/core/Scopes.scala +++ b/src/dotty/tools/dotc/core/Scopes.scala @@ -106,7 +106,10 @@ object Scopes { def next(): Symbol = { val r = e.sym; e = lookupNextEntry(e); r } } - /** The denotation set of all the symbols with given name in this scope */ + /** The denotation set of all the symbols with given name in this scope + * Symbols occur in the result in reverse order relative to their occurrence + * in `this.toList`. + */ final def denotsNamed(name: Name, select: SymDenotation => Boolean = selectAll)(implicit ctx: Context): PreDenotation = { var syms: PreDenotation = NoDenotation var e = lookupEntry(name) @@ -118,6 +121,20 @@ object Scopes { syms } + /** The scope that keeps only those symbols from this scope that match the + * given predicates. If all symbols match, returns the scope itself, otherwise + * a copy with the matching symbols. + */ + final def filteredScope(p: Symbol => Boolean)(implicit ctx: Context): Scope = { + var result: MutableScope = null + for (sym <- iterator) + if (!p(sym)) { + if (result == null) result = cloneScope + result.unlink(sym) + } + if (result == null) this else result + } + def implicitDecls(implicit ctx: Context): List[TermRef] = Nil final def toText(printer: Printer): Text = printer.toText(this) |