diff --git a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala index 2b2b167e2a85..09e36950b8d4 100644 --- a/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala +++ b/compiler/src/dotty/tools/dotc/ast/TreeInfo.scala @@ -718,104 +718,4 @@ object TreeInfo { val Pure = new PurityLevel(2) val Idempotent = new PurityLevel(1) val Impure = new PurityLevel(0) -} - - /** a Match(Typed(_, tpt), _) must be translated into a switch if isSwitchAnnotation(tpt.tpe) - def isSwitchAnnotation(tpe: Type) = tpe hasAnnotation defn.SwitchClass - */ - - /** Does list of trees start with a definition of - * a class of module with given name (ignoring imports) - def firstDefinesClassOrObject(trees: List[Tree], name: Name): Boolean = trees match { - case Import(_, _) :: xs => firstDefinesClassOrObject(xs, name) - case Annotated(_, tree1) :: Nil => firstDefinesClassOrObject(List(tree1), name) - case ModuleDef(_, `name`, _) :: Nil => true - case ClassDef(_, `name`, _, _) :: Nil => true - case _ => false - } - - - /** Is this file the body of a compilation unit which should not - * have Predef imported? - */ - def noPredefImportForUnit(body: Tree) = { - // Top-level definition whose leading imports include Predef. - def isLeadingPredefImport(defn: Tree): Boolean = defn match { - case PackageDef(_, defs1) => defs1 exists isLeadingPredefImport - case Import(expr, _) => isReferenceToPredef(expr) - case _ => false - } - // Compilation unit is class or object 'name' in package 'scala' - def isUnitInScala(tree: Tree, name: Name) = tree match { - case PackageDef(Ident(nme.scala_), defs) => firstDefinesClassOrObject(defs, name) - case _ => false - } - - isUnitInScala(body, nme.Predef) || isLeadingPredefImport(body) - } - */ - - /* - def isAbsTypeDef(tree: Tree) = tree match { - case TypeDef(_, _, _, TypeBoundsTree(_, _)) => true - case TypeDef(_, _, _, rhs) => rhs.tpe.isInstanceOf[TypeBounds] - case _ => false - } - - def isAliasTypeDef(tree: Tree) = tree match { - case TypeDef(_, _, _, _) => !isAbsTypeDef(tree) - case _ => false - } - - /** Some handy extractors for spotting trees through the - * the haze of irrelevant braces: i.e. Block(Nil, SomeTree) - * should not keep us from seeing SomeTree. - */ - abstract class SeeThroughBlocks[T] { - protected def unapplyImpl(x: Tree): T - def unapply(x: Tree): T = x match { - case Block(Nil, expr) => unapply(expr) - case _ => unapplyImpl(x) - } - } - object IsTrue extends SeeThroughBlocks[Boolean] { - protected def unapplyImpl(x: Tree): Boolean = x match { - case Literal(Constant(true)) => true - case _ => false - } - } - object IsFalse extends SeeThroughBlocks[Boolean] { - protected def unapplyImpl(x: Tree): Boolean = x match { - case Literal(Constant(false)) => true - case _ => false - } - } - object IsIf extends SeeThroughBlocks[Option[(Tree, Tree, Tree)]] { - protected def unapplyImpl(x: Tree) = x match { - case If(cond, thenp, elsep) => Some((cond, thenp, elsep)) - case _ => None - } - } - - object MacroImplReference { - private def refPart(tree: Tree): Tree = tree match { - case TypeApply(fun, _) => refPart(fun) - case ref: RefTree => ref - case _ => EmptyTree() - } - - def unapply(tree: Tree) = refPart(tree) match { - case ref: RefTree => Some((ref.qualifier.symbol, ref.symbol, dissectApplied(tree).targs)) - case _ => None - } - } - - def isNullaryInvocation(tree: Tree): Boolean = - tree.symbol != null && tree.symbol.isMethod && (tree match { - case TypeApply(fun, _) => isNullaryInvocation(fun) - case tree: RefTree => true - case _ => false - })*/ - - - +} \ No newline at end of file diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 0e7cecb0f360..fd57d0c398d0 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -48,7 +48,6 @@ trait NamerContextOps { this: Context => val elem = scope.lastEntry if (elem.name == name) return elem.sym.denot // return self } - assert(scope.size <= 1, scope) owner.thisType.member(name) } else // we are in the outermost context belonging to a class; self is invisible here. See inClassContext. diff --git a/tests/neg/i3702.scala b/tests/neg/i3702.scala new file mode 100644 index 000000000000..1809e2ae7e75 --- /dev/null +++ b/tests/neg/i3702.scala @@ -0,0 +1,8 @@ +object test { + class annot extends scala.annotation.Annotation + def foo = { + def bar(i: Int): Int = i + @annot class Silly {} // error: not found + bar(5) + } +}