Skip to content

Commit 6d91ef2

Browse files
authored
Merge pull request #3707 from dotty-staging/fix-#3702
Fix #3702: Drop failing assertion
2 parents f22c662 + 71a9b4e commit 6d91ef2

File tree

3 files changed

+9
-102
lines changed

3 files changed

+9
-102
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

Lines changed: 1 addition & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -718,104 +718,4 @@ object TreeInfo {
718718
val Pure = new PurityLevel(2)
719719
val Idempotent = new PurityLevel(1)
720720
val Impure = new PurityLevel(0)
721-
}
722-
723-
/** a Match(Typed(_, tpt), _) must be translated into a switch if isSwitchAnnotation(tpt.tpe)
724-
def isSwitchAnnotation(tpe: Type) = tpe hasAnnotation defn.SwitchClass
725-
*/
726-
727-
/** Does list of trees start with a definition of
728-
* a class of module with given name (ignoring imports)
729-
def firstDefinesClassOrObject(trees: List[Tree], name: Name): Boolean = trees match {
730-
case Import(_, _) :: xs => firstDefinesClassOrObject(xs, name)
731-
case Annotated(_, tree1) :: Nil => firstDefinesClassOrObject(List(tree1), name)
732-
case ModuleDef(_, `name`, _) :: Nil => true
733-
case ClassDef(_, `name`, _, _) :: Nil => true
734-
case _ => false
735-
}
736-
737-
738-
/** Is this file the body of a compilation unit which should not
739-
* have Predef imported?
740-
*/
741-
def noPredefImportForUnit(body: Tree) = {
742-
// Top-level definition whose leading imports include Predef.
743-
def isLeadingPredefImport(defn: Tree): Boolean = defn match {
744-
case PackageDef(_, defs1) => defs1 exists isLeadingPredefImport
745-
case Import(expr, _) => isReferenceToPredef(expr)
746-
case _ => false
747-
}
748-
// Compilation unit is class or object 'name' in package 'scala'
749-
def isUnitInScala(tree: Tree, name: Name) = tree match {
750-
case PackageDef(Ident(nme.scala_), defs) => firstDefinesClassOrObject(defs, name)
751-
case _ => false
752-
}
753-
754-
isUnitInScala(body, nme.Predef) || isLeadingPredefImport(body)
755-
}
756-
*/
757-
758-
/*
759-
def isAbsTypeDef(tree: Tree) = tree match {
760-
case TypeDef(_, _, _, TypeBoundsTree(_, _)) => true
761-
case TypeDef(_, _, _, rhs) => rhs.tpe.isInstanceOf[TypeBounds]
762-
case _ => false
763-
}
764-
765-
def isAliasTypeDef(tree: Tree) = tree match {
766-
case TypeDef(_, _, _, _) => !isAbsTypeDef(tree)
767-
case _ => false
768-
}
769-
770-
/** Some handy extractors for spotting trees through the
771-
* the haze of irrelevant braces: i.e. Block(Nil, SomeTree)
772-
* should not keep us from seeing SomeTree.
773-
*/
774-
abstract class SeeThroughBlocks[T] {
775-
protected def unapplyImpl(x: Tree): T
776-
def unapply(x: Tree): T = x match {
777-
case Block(Nil, expr) => unapply(expr)
778-
case _ => unapplyImpl(x)
779-
}
780-
}
781-
object IsTrue extends SeeThroughBlocks[Boolean] {
782-
protected def unapplyImpl(x: Tree): Boolean = x match {
783-
case Literal(Constant(true)) => true
784-
case _ => false
785-
}
786-
}
787-
object IsFalse extends SeeThroughBlocks[Boolean] {
788-
protected def unapplyImpl(x: Tree): Boolean = x match {
789-
case Literal(Constant(false)) => true
790-
case _ => false
791-
}
792-
}
793-
object IsIf extends SeeThroughBlocks[Option[(Tree, Tree, Tree)]] {
794-
protected def unapplyImpl(x: Tree) = x match {
795-
case If(cond, thenp, elsep) => Some((cond, thenp, elsep))
796-
case _ => None
797-
}
798-
}
799-
800-
object MacroImplReference {
801-
private def refPart(tree: Tree): Tree = tree match {
802-
case TypeApply(fun, _) => refPart(fun)
803-
case ref: RefTree => ref
804-
case _ => EmptyTree()
805-
}
806-
807-
def unapply(tree: Tree) = refPart(tree) match {
808-
case ref: RefTree => Some((ref.qualifier.symbol, ref.symbol, dissectApplied(tree).targs))
809-
case _ => None
810-
}
811-
}
812-
813-
def isNullaryInvocation(tree: Tree): Boolean =
814-
tree.symbol != null && tree.symbol.isMethod && (tree match {
815-
case TypeApply(fun, _) => isNullaryInvocation(fun)
816-
case tree: RefTree => true
817-
case _ => false
818-
})*/
819-
820-
821-
721+
}

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ trait NamerContextOps { this: Context =>
4848
val elem = scope.lastEntry
4949
if (elem.name == name) return elem.sym.denot // return self
5050
}
51-
assert(scope.size <= 1, scope)
5251
owner.thisType.member(name)
5352
}
5453
else // we are in the outermost context belonging to a class; self is invisible here. See inClassContext.

tests/neg/i3702.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object test {
2+
class annot extends scala.annotation.Annotation
3+
def foo = {
4+
def bar(i: Int): Int = i
5+
@annot class Silly {} // error: not found
6+
bar(5)
7+
}
8+
}

0 commit comments

Comments
 (0)