summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2007-11-05 16:53:05 +0000
committerMartin Odersky <odersky@gmail.com>2007-11-05 16:53:05 +0000
commitff082b58c65467ffa90651aaae87a2f552cb48ec (patch)
tree8c60926cb36deba587446bda6c17af5edd6ecdbd /src
parent14553bf9fea023f6f78cbf83f1a6c4827752bd50 (diff)
downloadscala-ff082b58c65467ffa90651aaae87a2f552cb48ec.tar.gz
scala-ff082b58c65467ffa90651aaae87a2f552cb48ec.tar.bz2
scala-ff082b58c65467ffa90651aaae87a2f552cb48ec.zip
Fixed tickets 87 and 117.
generateIDEMaps only when inIDE is true.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala7
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala48
-rw-r--r--src/library/scala/Seq.scala2
4 files changed, 36 insertions, 25 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index b59a4eac70..2d1aa28a67 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -380,7 +380,9 @@ class Global(var settings: Settings, var reporter: Reporter) extends Trees
protected def builtInPhaseDescriptors: List[SubComponent] = List(
analyzer.namerFactory: SubComponent, // note: types are there because otherwise
analyzer.typerFactory: SubComponent, // consistency check after refchecks would fail.
- generateIdeMaps, // optionally generate .ide files from symbol info that can be used in the IDE
+ ) :::
+ (if (inIDE) List(generateIdeMaps) else List()) ::: // optionally generate .ide files from symbol info that can be used in the IDE
+ List(
superAccessors, // add super accessors
pickler, // serializes symbol tables
refchecks, // perform reference and override checking, translate nested objects
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index eaa1e59b05..14c805254a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -828,7 +828,9 @@ trait Infer {
* @param undetparams ...
* @param pt ...
*/
- def inferConstructorInstance(tree: Tree, undetparams: List[Symbol], pt: Type) {
+ def inferConstructorInstance(tree: Tree, undetparams: List[Symbol], pt0: Type) {
+ val pt = widen(pt0)
+ //println("infer constr inst "+tree+"/"+undetparams+"/"+pt0)
var restpe = tree.tpe.finalResultType
var tvars = undetparams map freshVar
@@ -968,7 +970,8 @@ trait Infer {
}
}
- def inferTypedPattern(pos: Position, pattp: Type, pt: Type): Type = {
+ def inferTypedPattern(pos: Position, pattp: Type, pt0: Type): Type = {
+ val pt = widen(pt0)
checkCheckable(pos, pattp, " pattern")
if (!(pattp <:< pt)) {
val tpparams = freeTypeParamsOfTerms.collect(pattp)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index ef56d827c4..e7493a999e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -705,7 +705,7 @@ trait Typers { self: Analyzer =>
val prefix = tree.tpe.finalResultType.prefix
val tree1 = TypeTree(clazz.primaryConstructor.tpe.asSeenFrom(prefix, clazz.owner)) setOriginal tree
try {
- inferConstructorInstance(tree1, clazz.typeParams, widen(pt))
+ inferConstructorInstance(tree1, clazz.typeParams, pt)
} catch {
case tpe : TypeError => throw tpe
case t : Exception =>
@@ -1512,7 +1512,7 @@ trait Typers { self: Analyzer =>
(accessed hasFlag LOCAL) && (accessed hasFlag PARAMACCESSOR) ||
(accessor hasFlag ACCESSOR) &&
!(accessed hasFlag ACCESSOR) && accessed.isPrivateLocal
- def checkNoDoubleDefs(stats: List[Tree]) = {
+ def checkNoDoubleDefs(stats: List[Tree]) {
val scope = if (inBlock) context.scope else context.owner.info.decls;
var e = scope.elems;
while ((e ne null) && e.owner == scope) {
@@ -1522,14 +1522,15 @@ trait Typers { self: Analyzer =>
(e.sym.isType || inBlock || (e.sym.tpe matches e1.sym.tpe)))
if (!e.sym.isErroneous && !e1.sym.isErroneous && !inIDE)
error(e.sym.pos, e1.sym+" is defined twice"+
- {if(!settings.debug.value) "" else " in "+unit.toString});
+ {if(!settings.debug.value) "" else " in "+unit.toString})
e1 = scope.lookupNextEntry(e1);
}
e = e.next
}
- stats
}
- checkNoDoubleDefs(List.mapConserve(stats)(typedStat))
+ val result = List.mapConserve(stats)(typedStat)
+ if (!phase.erasedTypes) checkNoDoubleDefs(result)
+ result
}
def typedArg(arg: Tree, mode: Int, newmode: Int, pt: Type): Tree =
@@ -2412,23 +2413,30 @@ trait Typers { self: Analyzer =>
}
if (clazz == NoSymbol) setError(tree)
else {
+ def findMixinSuper(site: Type): Type = {
+ val ps = site.parents filter (p => compare(p.typeSymbol, mix))
+ if (ps.isEmpty) {
+ if (settings.debug.value)
+ Console.println(site.parents map (_.typeSymbol.name))//debug
+ error(tree.pos, mix+" does not name a parent class of "+clazz)
+ ErrorType
+ } else if (!ps.tail.isEmpty) {
+ error(tree.pos, "ambiguous parent class qualifier")
+ ErrorType
+ } else if (ps.head.typeSymbol.isClass && !ps.head.typeSymbol.isTrait &&
+ context.enclClass.owner.isTrait) {
+ error(tree.pos, "traits may not refer to super[C] where C is a class")
+ ErrorType
+ } else {
+ ps.head
+ }
+ }
val owntype =
- if (mix.isEmpty)
+ if (mix.isEmpty) {
if ((mode & SUPERCONSTRmode) != 0) clazz.info.parents.head
else intersectionType(clazz.info.parents)
- else {
- val ps = clazz.info.parents filter (p => compare(p.typeSymbol, mix))
- if (ps.isEmpty) {
- if (settings.debug.value)
- Console.println(clazz.info.parents map (_.typeSymbol.name))//debug
- error(tree.pos, mix+" does not name a parent class of "+clazz)
- ErrorType
- } else if (ps.tail.isEmpty) {
- ps.head
- } else {
- error(tree.pos, "ambiguous parent class qualifier")
- ErrorType
- }
+ } else {
+ findMixinSuper(clazz.info)
}
tree setSymbol clazz setType mkSuperType(selftype, owntype)
}
@@ -2859,7 +2867,7 @@ trait Typers { self: Analyzer =>
val tpt1 = typedType(tpt)
val expr1 = typed(expr, mode & stickyModes, tpt1.tpe.deconst)
val owntype =
- if ((mode & PATTERNmode) != 0) inferTypedPattern(tpt1.pos, tpt1.tpe, widen(pt))
+ if ((mode & PATTERNmode) != 0) inferTypedPattern(tpt1.pos, tpt1.tpe, pt)
else tpt1.tpe
//Console.println(typed pattern: "+tree+":"+", tp = "+tpt1.tpe+", pt = "+pt+" ==> "+owntype)//DEBUG
copy.Typed(tree, expr1, tpt1) setType owntype
diff --git a/src/library/scala/Seq.scala b/src/library/scala/Seq.scala
index dd59ddfa81..c801900343 100644
--- a/src/library/scala/Seq.scala
+++ b/src/library/scala/Seq.scala
@@ -368,8 +368,6 @@ trait Seq[+A] extends AnyRef with PartialFunction[Int, A] with Collection[A] {
@deprecated
def subseq(from: Int, end: Int): Seq[A] = slice(from, end - from)
-
-
/** Converts this sequence to a fresh Array with <code>length</code> elements.
*/
override def toArray[B >: A]: Array[B] = {