summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2010-10-16 14:47:44 +0000
committerMartin Odersky <odersky@gmail.com>2010-10-16 14:47:44 +0000
commite5cfe47a191bd0e5aaac07f8910dd0916b060d26 (patch)
tree8afc37c43e1d61c3e4a03bd38254f841a7bc1919 /src
parent9adc6d22c960c1b20c7cff88091c9aaecaaf9053 (diff)
downloadscala-e5cfe47a191bd0e5aaac07f8910dd0916b060d26.tar.gz
scala-e5cfe47a191bd0e5aaac07f8910dd0916b060d26.tar.bz2
scala-e5cfe47a191bd0e5aaac07f8910dd0916b060d26.zip
Closes #3614.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala7
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala29
2 files changed, 20 insertions, 16 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index 70d326ceb7..bf790301f5 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -278,6 +278,7 @@ trait Namers { self: Analyzer =>
/** Replace type parameters with their TypeSkolems, which can later be deskolemized to the original type param
* (a skolem is a representation of a bound variable when viewed inside its scope)
+ * !!!Adriaan: this does not work for hk types.
*/
def skolemize(tparams: List[TypeDef]) {
val tskolems = newTypeSkolems(tparams map (_.symbol))
@@ -378,7 +379,7 @@ trait Namers { self: Analyzer =>
case vd @ ValDef(mods, name, tp, rhs) =>
if ((!context.owner.isClass ||
(mods.flags & (PRIVATE | LOCAL | CASEACCESSOR)) == (PRIVATE | LOCAL) ||
- name.endsWith(nme.OUTER, nme.OUTER.length) ||
+ name.startsWith(nme.OUTER) ||
context.unit.isJava) &&
!mods.isLazy) {
val vsym = owner.newValue(tree.pos, name).setFlag(mods.flags);
@@ -1223,13 +1224,13 @@ trait Namers { self: Analyzer =>
checkSelectors(rest)
case Nil =>
}
-
checkSelectors(selectors)
+ transformed(tree) = treeCopy.Import(tree, expr1, selectors)
ImportType(expr1)
}
} catch {
case ex: TypeError =>
- //Console.println("caught " + ex + " in typeSig")//DEBUG
+ //Console.println("caught " + ex + " in typeSig")
typer.reportTypeError(tree.pos, ex)
ErrorType
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index e4ae8f680d..558e5107e8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -32,7 +32,8 @@ trait Typers { self: Analyzer =>
// namer calls typer.computeType(rhs) on DefDef / ValDef when tpt is empty. the result
// is cached here and re-used in typedDefDef / typedValDef
- private val transformed = new HashMap[Tree, Tree]
+ // Also used to cache imports type-checked by namer.
+ val transformed = new HashMap[Tree, Tree]
// currently not used at all (March 09)
private val superDefs = new HashMap[Symbol, ListBuffer[Tree]]
@@ -682,7 +683,7 @@ trait Typers { self: Analyzer =>
/** The member with given name of given qualifier tree */
def member(qual: Tree, name: Name) = qual.tpe match {
case ThisType(clazz) if (context.enclClass.owner.hasTransOwner(clazz)) =>
- // println("member")
+ // println("member "+qual.tpe+" . "+name+" "+qual.tpe.getClass)
qual.tpe.member(name)
case _ =>
if (phase.next.erasedTypes) qual.tpe.member(name)
@@ -1917,7 +1918,7 @@ trait Typers { self: Analyzer =>
// The cleanest way forward is if we would find a way to suppress
// structural type checking for these members and maybe defer
// type errors to the places where members are called. But that would
- // be a bug refactoring and also a big departure from existing code.
+ // be a big refactoring and also a big departure from existing code.
// The probably safest fix for 2.8 is to keep members of an anonymous
// class that are not mentioned in a parent type private (as before)
// but to disable escape checking for code that's in the same anonymous class.
@@ -2093,7 +2094,10 @@ trait Typers { self: Analyzer =>
namer.enterSyms(stats)
// need to delay rest of typedRefinement to avoid cyclic reference errors
unit.toCheck += { () =>
- val stats1 = typedStats(stats, NoSymbol)
+ // go to next outer context which is not silent, see #3614
+ var c = context
+ while (!c.reportGeneralErrors) c = c.outer
+ val stats1 = newTyper(c).typedStats(stats, NoSymbol)
for (stat <- stats1 if stat.isDef) {
val member = stat.symbol
if (!(context.owner.ancestors forall
@@ -2104,7 +2108,10 @@ trait Typers { self: Analyzer =>
}
}
- def typedImport(imp : Import) : Import = imp
+ def typedImport(imp : Import) : Import = (transformed remove imp) match {
+ case Some(imp1: Import) => imp1
+ case None => println("unhandled impoprt: "+imp+" in "+unit); imp
+ }
def typedStats(stats: List[Tree], exprOwner: Symbol): List[Tree] = {
val inBlock = exprOwner == context.owner
@@ -2117,13 +2124,9 @@ trait Typers { self: Analyzer =>
else
stat match {
case imp @ Import(_, _) =>
- val imp0 = typedImport(imp)
- if (imp0 ne null) {
- context = context.makeNewImport(imp0)
- imp0.symbol.initialize
- imp0
- } else
- EmptyTree
+ context = context.makeNewImport(imp)
+ imp.symbol.initialize
+ typedImport(imp)
case _ =>
if (localTarget && !includesTargetPos(stat)) {
// skip typechecking of statements in a sequence where some other statement includes
@@ -3916,7 +3919,7 @@ trait Typers { self: Analyzer =>
case Star(elem) =>
checkStarPatOK(tree.pos, mode)
val elem1 = typed(elem, mode, pt)
- treeCopy.Star(tree, elem1) setType pt
+ treeCopy.Star(tree, elem1) setType makeFullyDefined(pt)
case Bind(name, body) =>
typedBind(name, body)