Skip to content
Browse files

fixed case when indirect search cause search in uninitialized type.

  • Loading branch information...
1 parent f62a8e8 commit 9e07eac718091a198d18f5475ab04a62681e29b5 @rssh committed Dec 3, 2012
View
2 src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -1001,7 +1001,7 @@ trait Contexts { self: Analyzer =>
override def toString() = tree.toString()
}
- case class ImportType(expr: Tree) extends Type {
+ case class ImportType(val expr: Tree) extends Type {
override def safeToString = "ImportType("+expr+")"
}
}
View
22 src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -319,12 +319,23 @@ trait Namers extends MethodSynthesis {
private def createImportSymbol(tree: Tree) = {
tree match {
case Import(expr,selectors,annotations) =>
- NoSymbol.newImport(tree.pos,
+ val lazyType = completerOf(tree)
+ lazy val retval: Symbol = NoSymbol.newImport(tree.pos,
new SimpleTypeProxy {
+ var inCompleter = false
// expr.tpe will be set after call of completerOf to
// import tree, so use proxy for deffering
- override def underlying: Type = expr.tpe
+ override def underlying: Type = {
+ if (expr.tpe == null) {
+ if (!inCompleter) {
+ inCompleter = true
+ lazyType.complete(retval)
+ inCompleter = false
+ }
+ }
+ expr.tpe
+ }
// can be called from completerOf before initializing of tpe
// when resolving annotations in this import.
@@ -351,8 +362,6 @@ trait Namers extends MethodSynthesis {
else
List()
-
-
override def safeToString = "<["+
(if (underlying ne null)
@@ -363,9 +372,8 @@ trait Namers extends MethodSynthesis {
selectors.map(x=>(x.name,x.rename))
) withAnnotations(
annotations map( ann => AnnotationInfo lazily enteringTyper(typer typedAnnotation ann))
- ) setInfo completerOf(
- tree
- )
+ ) setInfo lazyType
+ retval
}
}

0 comments on commit 9e07eac

Please sign in to comment.
Something went wrong with that request. Please try again.