Skip to content

Commit

Permalink
Merge pull request #3707 from dotty-staging/fix-#3702
Browse files Browse the repository at this point in the history
Fix #3702: Drop failing assertion
  • Loading branch information
odersky authored Jan 13, 2018
2 parents f22c662 + 71a9b4e commit 6d91ef2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 102 deletions.
102 changes: 1 addition & 101 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
})*/



}
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions tests/neg/i3702.scala
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit 6d91ef2

Please sign in to comment.