summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.xml4
-rw-r--r--src/compiler/scala/tools/nsc/symtab/Definitions.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala25
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Duplicators.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala14
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Namers.scala15
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala102
-rw-r--r--src/intellij/actors.iml.SAMPLE (renamed from src/intellij/actors.iml)0
-rw-r--r--src/intellij/compiler.iml.SAMPLE (renamed from src/intellij/compiler.iml)0
-rw-r--r--src/intellij/dbc.iml.SAMPLE (renamed from src/intellij/dbc.iml)0
-rw-r--r--src/intellij/library.iml.SAMPLE (renamed from src/intellij/library.iml)0
-rw-r--r--src/intellij/manual.iml.SAMPLE (renamed from src/intellij/manual.iml)0
-rw-r--r--src/intellij/partest.iml.SAMPLE (renamed from src/intellij/partest.iml)0
-rw-r--r--src/intellij/scala-lang.ipr.SAMPLE (renamed from src/intellij/scala-lang.ipr)0
-rw-r--r--src/intellij/scalap.iml.SAMPLE (renamed from src/intellij/scalap.iml)0
-rw-r--r--src/intellij/swing.iml.SAMPLE (renamed from src/intellij/swing.iml)0
-rw-r--r--src/library/scala/collection/mutable/StringBuilder.scala3
-rw-r--r--src/library/scala/runtime/ScalaRunTime.scala5
-rw-r--r--test/files/pos/spec-asseenfrom.scala29
-rw-r--r--test/files/pos/spec-partialmap.scala17
-rw-r--r--test/files/pos/spec-private.scala10
-rw-r--r--test/files/pos/spec-sparsearray.scala24
-rw-r--r--test/files/pos/spec-vector.scala4
-rw-r--r--test/files/pos/t3177.scala39
-rw-r--r--test/files/pos/t3274.scala9
-rw-r--r--test/files/pos/t3373.scala11
-rw-r--r--test/files/pos/t3384.scala14
29 files changed, 260 insertions, 90 deletions
diff --git a/build.xml b/build.xml
index 58373ea69b..4df52769ec 100644
--- a/build.xml
+++ b/build.xml
@@ -1503,8 +1503,8 @@ BOOTRAPING TEST AND TEST SUITE
<partest classpathref="pack.classpath">
<env key="PATH" path="${build-pack.dir}/bin:${env.PATH}" />
<sysproperty key="partest.timeout" value="36000" />
- <sysproperty key="partest.test-warning" value="300" />
- <sysproperty key="partest.test-timeout" value="1800" />
+ <sysproperty key="partest.test-warning" value="600" />
+ <sysproperty key="partest.test-timeout" value="5400" />
<sysproperty key="partest.srcdir" value="files" />
<sysproperty key="partest.scalacopts" value="${scalac.args.all}" />
<sysproperty key="partest.javacopts" value="${javac.args}" />
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
index ed26ebac03..3511565326 100644
--- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala
+++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala
@@ -514,7 +514,7 @@ trait Definitions extends reflect.generic.StandardDefinitions {
else sym.info.member(fullname.subName(i, j).toTypeName)
if (result == NoSymbol) {
if (settings.debug.value)
- { Console.println(sym.info); Console.println(sym.info.members) }//debug
+ { log(sym.info); log(sym.info.members) }//debug
throw new MissingRequirementError((if (module) "object " else "class ") + fullname)
}
result
diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
index f2b896dc96..ee5bc040f5 100644
--- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -324,7 +324,9 @@ abstract class ExplicitOuter extends InfoTransform
val path =
if (mixinClass.owner.isTerm) THIS(mixinClass.owner.enclClass)
else gen.mkAttributedQualifier(currentClass.thisType baseType mixinClass prefix)
- val rhs = ExplicitOuterTransformer.this.transform(path)
+ // Need to cast for nested outer refs in presence of self-types. See ticket #3274.
+ val rhs = gen.mkAsInstanceOf(ExplicitOuterTransformer.this.transform(path),
+ outerAcc.info.resultType)
// @S: atPos not good enough because of nested atPos in DefDef method, which gives position from wrong class!
rhs setPos currentClass.pos
diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
index 1ab310282d..9215064856 100644
--- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
+++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
@@ -389,7 +389,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
def specializedParents(parents: List[Type]): List[Type] = {
val res = new mutable.ListBuffer[Type]
for (p <- parents) {
- val stp = specializedType(p)
+ val stp = atPhase(phase.next)(specializedType(p))
if (stp != p)
if (p.typeSymbol.isTrait) res += stp
else if (currentRun.compiles(clazz))
@@ -697,8 +697,8 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
log("Added specialized overload for " + overriding.fullName + " in env: " + env)
val om = specializedOverload(clazz, overridden, env)
typeEnv(om) = env
+ concreteSpecMethods += overriding
if (!overriding.isDeferred) {
- concreteSpecMethods += overriding
// if the override is a normalized member, 'om' gets the implementation from
// its original target, and adds the environment of the normalized member (that is,
// any specialized /method/ type parameter bindings)
@@ -711,6 +711,10 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
info(overriding) = Forward(om)
log("typeEnv(om) = " + typeEnv(om))
om setPos overriding.pos // set the position of the concrete, overriding member
+ } else {
+ // abstract override
+ log("abstract override " + overriding.fullName + " with specialized " + om.fullName)
+ info(om) = Forward(overriding)
}
overloads(overriding) = Overload(om, env) :: overloads(overriding)
oms += om
@@ -996,9 +1000,9 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
localTyper.typedOperator(atPos(tree.pos)(Select(transform(qual), specMember.get.sym.name)))
} else {
val qual1 = transform(qual)
- val specMember = qual1.tpe.member(specializedName(symbol, env))
+ val specMember = qual1.tpe.member(specializedName(symbol, env)).suchThat(_.tpe matches subst(env, symbol.tpe))
if (specMember ne NoSymbol) {
- log("** using spec member " + specMember)
+ log("** using spec member " + specMember + ": " + specMember.tpe)
val tree1 = atPos(tree.pos)(Select(qual1, specMember))
if (specMember.isMethod)
localTyper.typedOperator(tree1)
@@ -1205,7 +1209,8 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
// replace value and type parameters of the old method with the new ones
val symSubstituter = new ImplementationAdapter(
parameters(source).flatten ::: origtparams,
- vparamss1.flatten.map(_.symbol) ::: newtparams)
+ vparamss1.flatten.map(_.symbol) ::: newtparams,
+ source.enclClass)
val tmp = symSubstituter(body(source).duplicate)
tpt.tpe = tpt.tpe.substSym(oldtparams, newtparams)
@@ -1221,21 +1226,25 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers {
* All private members are made protected in order to be accessible from
* specialized classes.
*/
- class ImplementationAdapter(from: List[Symbol], to: List[Symbol]) extends TreeSymSubstituter(from, to) {
+ class ImplementationAdapter(from: List[Symbol], to: List[Symbol], targetClass: Symbol) extends TreeSymSubstituter(from, to) {
override val symSubst = new SubstSymMap(from, to) {
override def matches(sym1: Symbol, sym2: Symbol) =
if (sym2.isTypeSkolem) sym2.deSkolemize eq sym1
else sym1 eq sym2
}
+ private def isAccessible(sym: Symbol): Boolean =
+ (currentClass == sym.owner.enclClass) && (currentClass != targetClass)
+
/** All private members that are referenced are made protected,
* in order to be accessible from specialized subclasses.
*/
override def transform(tree: Tree): Tree = tree match {
case Select(qual, name) =>
val sym = tree.symbol
- if (sym.hasFlag(PRIVATE | PROTECTED) && !nme.isLocalName(sym.name)
- && (currentClass != sym.owner.enclClass)) {
+ if (sym.hasFlag(PRIVATE))
+ log("seeing private member " + sym + " targetClass: " + currentClass + " owner: " + sym.owner.enclClass)
+ if (sym.hasFlag(PRIVATE | PROTECTED) && !nme.isLocalName(sym.name) && !isAccessible(sym)) {
log("changing private flag of " + sym)
// tree.symbol.resetFlag(PRIVATE).setFlag(PROTECTED)
sym.makeNotPrivate(sym.owner)
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 8758dd834c..82c4c01b79 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -487,6 +487,15 @@ trait Contexts { self: Analyzer =>
implicitsCache
}
+ /**
+ * Find a symbol in this context or one of its outers.
+ *
+ * Used to find symbols are owned by methods (or fields), they can't be
+ * found in some scope.
+ *
+ * Examples: companion module of classes owned by a method, default getter
+ * methods of nested methods. See NamesDefaults.scala
+ */
def lookup(name: Name, expectedOwner: Symbol) = {
var res: Symbol = NoSymbol
var ctx = this
diff --git a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
index de9318d6b6..7096a38531 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Duplicators.scala
@@ -113,12 +113,10 @@ abstract class Duplicators extends Analyzer {
val tpe1 = envSubstitution(tpe)
log("tpe1: " + tpe1)
val tpe2: Type = (new FixInvalidSyms)(tpe1)
- val tpe3 = tpe2 match {
- case TypeRef(_, sym, _) if (sym.owner == oldClassOwner) =>
- log("seeing " + sym.fullName + " from a different angle")
- tpe2.asSeenFrom(newClassOwner.thisType, oldClassOwner)
- case _ => tpe2
- }
+ val tpe3 = if (newClassOwner ne null) {
+ log("seeing it from a different angle: " + tpe2 + " nco: " + newClassOwner + " oco: " + oldClassOwner)
+ tpe2.asSeenFrom(newClassOwner.thisType, oldClassOwner)
+ } else tpe2
log("tpe2: " + tpe3)
tpe3
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 9a6c4cc401..e503d721f9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -520,7 +520,7 @@ self: Analyzer =>
* - the symbol's type is initialized
* - the symbol comes from a classfile
* - the symbol comes from a different sourcefile than the current one
- * - the symbol's definition comes before, and does not contain the closest enclosing definition,
+ * - the symbol and the accessed symbol's definitions come before, and do not contain the closest enclosing definition, // see #3373
* - the symbol's definition is a val, var, or def with an explicit result type
* The aim of this method is to prevent premature cyclic reference errors
* by computing the types of only those implicits for which one of these
@@ -539,9 +539,15 @@ self: Analyzer =>
case _ => true
}
}
- def comesBefore(sym: Symbol, owner: Symbol) =
- sym.pos.pointOrElse(0) < owner.pos.pointOrElse(Integer.MAX_VALUE) &&
- !(owner.ownerChain contains sym)
+ def comesBefore(sym: Symbol, owner: Symbol) = {
+ val ownerPos = owner.pos.pointOrElse(Integer.MAX_VALUE)
+ sym.pos.pointOrElse(0) < ownerPos && (
+ if(sym isGetterOrSetter) {
+ val symAcc = sym.accessed // #3373
+ symAcc.pos.pointOrElse(0) < ownerPos &&
+ !(owner.ownerChain exists (o => (o eq sym) || (o eq symAcc))) // probably faster to iterate only once, don't feel like duplicating hasTransOwner for this case
+ } else !(owner hasTransOwner sym)) // faster than owner.ownerChain contains sym
+ }
sym.isInitialized ||
sym.sourceFile == null ||
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
index a7f573f98b..37f8a21bf8 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala
@@ -607,17 +607,6 @@ trait Namers { self: Analyzer =>
vparamss.map(_.map(enterValueParam))
}
- /**
- * Finds the companion module of a class symbol. Calling .companionModule
- * does not work for classes defined inside methods.
- */
- private def companionModuleOf(clazz: Symbol) = {
- var res = clazz.companionModule
- if (res == NoSymbol)
- res = context.lookup(clazz.name.toTermName, clazz.owner)
- res
- }
-
private def templateSig(templ: Template): Type = {
val clazz = context.owner
def checkParent(tpt: Tree): Type = {
@@ -738,7 +727,7 @@ trait Namers { self: Analyzer =>
// @check: this seems to work only if the type completer of the class runs before the one of the
// module class: the one from the module class removes the entry form caseClassOfModuleClass (see above).
if (clazz.isClass && !clazz.hasFlag(MODULE)) {
- Namers.this.caseClassOfModuleClass get companionModuleOf(clazz).moduleClass match {
+ Namers.this.caseClassOfModuleClass get companionModuleOf(clazz, context).moduleClass match {
case Some(cdef) =>
def hasCopy(decls: Scope) = {
decls.iterator exists (_.name == nme.copy)
@@ -997,7 +986,7 @@ trait Namers { self: Analyzer =>
val parentNamer = if (isConstr) {
val (cdef, nmr) = moduleNamer.getOrElse {
- val module = companionModuleOf(meth.owner)
+ val module = companionModuleOf(meth.owner, context)
module.initialize // call type completer (typedTemplate), adds the
// module's templateNamer to classAndNamerOfModule
val (cdef, nmr) = classAndNamerOfModule(module)
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
index 18102a8bb4..ef2c3c3071 100644
--- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala
@@ -178,60 +178,52 @@ trait NamesDefaults { self: Analyzer =>
b
}
- def moduleQual(pos: Position, tree: Symbol => Tree) = {
- val module = baseFun.symbol.owner.companionModule
- if (module == NoSymbol) None
- else Some(atPos(pos.focus)(tree(module)))
+ def moduleQual(pos: Position, classType: Type) = {
+ // prefix does 'normalize', which fixes #3384
+ val pre = classType.prefix
+ if (pre == NoType) {
+ None
+ } else {
+ val module = companionModuleOf(baseFun.symbol.owner, context)
+ if (module == NoSymbol) None
+ else Some(atPos(pos.focus)(gen.mkAttributedRef(pre, module)))
+ }
}
baseFun1 match {
// constructor calls
case Select(New(tp @ TypeTree()), _) if isConstr =>
- // fixes #3338. Same qualifier for selecting the companion object as for the class.
- val dq = tp.tpe match {
- case TypeRef(pre, _, _) if (!pre.typeSymbol.isEmptyPackageClass) =>
- moduleQual(tp.pos, mod => gen.mkAttributedSelect(gen.mkAttributedQualifier(pre), mod))
- case _ => None
- }
- blockWithoutQualifier(dq)
+ // 'moduleQual' fixes #3338. Same qualifier for selecting the companion object as for the class.
+ blockWithoutQualifier(moduleQual(tp.pos, tp.tpe))
case Select(TypeApply(New(tp @ TypeTree()), _), _) if isConstr =>
- val dq = tp.tpe match {
- case TypeRef(pre, _, _) if (!pre.typeSymbol.isEmptyPackageClass) =>
- moduleQual(tp.pos, mod => gen.mkAttributedSelect(gen.mkAttributedQualifier(pre), mod))
- case _ => None
- }
- blockWithoutQualifier(dq)
+ blockWithoutQualifier(moduleQual(tp.pos, tp.tpe))
- case Select(New(Ident(_)), _) if isConstr =>
- blockWithoutQualifier(None)
- case Select(TypeApply(New(Ident(_)), _), _) if isConstr =>
- blockWithoutQualifier(None)
+ case Select(New(tp @ Ident(_)), _) if isConstr =>
+ // 'moduleQual' fixes #3344
+ blockWithoutQualifier(moduleQual(tp.pos, tp.tpe))
+ case Select(TypeApply(New(tp @ Ident(_)), _), _) if isConstr =>
+ blockWithoutQualifier(moduleQual(tp.pos, tp.tpe))
- case Select(New(Select(qual, _)), _) if isConstr =>
+ case Select(New(tp @ Select(qual, _)), _) if isConstr =>
// in `new q.C()', q is always stable
assert(treeInfo.isPureExpr(qual), qual)
- // #2057
- val defaultQual = moduleQual(qual.pos, mod => gen.mkAttributedSelect(qual.duplicate, mod))
- blockWithoutQualifier(defaultQual)
-
- case Select(TypeApply(New(Select(qual, _)), _), _) if isConstr =>
+ // 'moduleQual' fixes #2057
+ blockWithoutQualifier(moduleQual(tp.pos, tp.tpe))
+ case Select(TypeApply(New(tp @ Select(qual, _)), _), _) if isConstr =>
assert(treeInfo.isPureExpr(qual), qual)
- val defaultQual = moduleQual(qual.pos, mod => gen.mkAttributedSelect(qual.duplicate, mod))
- blockWithoutQualifier(defaultQual)
+ blockWithoutQualifier(moduleQual(tp.pos, tp.tpe))
// super constructor calls
case Select(sp @ Super(_, _), _) if isConstr =>
- // fix for #3207. selection of the companion module of the superclass
- // needs to have the same prefix as the the superclass.
- val superprefix = sp.symbol.tpe.parents.head.prefix
- val defaultQual = moduleQual(baseFun.pos, mod => gen.mkAttributedRef(superprefix, mod))
- blockWithoutQualifier(defaultQual)
+ // 'moduleQual' fixes #3207. selection of the companion module of the
+ // superclass needs to have the same prefix as the the superclass.
+ blockWithoutQualifier(moduleQual(baseFun.pos, sp.symbol.tpe.parents.head))
// self constructor calls (in secondary constructors)
- case Select(qual, name) if isConstr =>
- assert(treeInfo.isPureExpr(qual), qual)
- blockWithoutQualifier(None)
+ case Select(tp, name) if isConstr =>
+ assert(treeInfo.isPureExpr(tp), tp)
+ blockWithoutQualifier(moduleQual(tp.pos, tp.tpe))
// other method calls
@@ -361,11 +353,8 @@ trait NamesDefaults { self: Analyzer =>
if (missing forall (_.hasFlag(DEFAULTPARAM))) {
val defaultArgs = missing map (p => {
var default1 = qual match {
- case Some(q) => gen.mkAttributedSelect(q.duplicate, defaultGetter(p, context)._1)
- case None =>
- val (m, q) = defaultGetter(p, context)
- if (q.isDefined) gen.mkAttributedSelect(q.get, m)
- else gen.mkAttributedRef(m)
+ case Some(q) => gen.mkAttributedSelect(q.duplicate, defaultGetter(p, context))
+ case None => gen.mkAttributedRef(defaultGetter(p, context))
}
default1 = if (targs.isEmpty) default1
else TypeApply(default1, targs.map(_.duplicate))
@@ -383,32 +372,28 @@ trait NamesDefaults { self: Analyzer =>
/**
* For a parameter with default argument, find the method symbol of
- * the default getter. Can return a qualifier tree for the selecting
- * the method's symbol (part of #3334 fix).
+ * the default getter.
*/
- def defaultGetter(param: Symbol, context: Context): (Symbol, Option[Tree]) = {
+ def defaultGetter(param: Symbol, context: Context): Symbol = {
val i = param.owner.paramss.flatten.findIndexOf(p => p.name == param.name) + 1
if (i > 0) {
if (param.owner.isConstructor) {
val defGetterName = "init$default$"+ i
- var mod = param.owner.owner.companionModule
- // if the class's owner is a method, .companionModule does not work
- if (mod == NoSymbol)
- mod = context.lookup(param.owner.owner.name.toTermName, param.owner.owner.owner)
- (mod.info.member(defGetterName), Some(gen.mkAttributedRef(mod)))
+ val mod = companionModuleOf(param.owner.owner, context)
+ mod.info.member(defGetterName)
} else {
val defGetterName = param.owner.name +"$default$"+ i
// isClass also works for methods in objects, owner is the ModuleClassSymbol
if (param.owner.owner.isClass) {
// .toInterface: otherwise we get the method symbol of the impl class
- (param.owner.owner.toInterface.info.member(defGetterName), None)
+ param.owner.owner.toInterface.info.member(defGetterName)
} else {
// the owner of the method is another method. find the default
// getter in the context.
- (context.lookup(defGetterName, param.owner.owner), None)
+ context.lookup(defGetterName, param.owner.owner)
}
}
- } else (NoSymbol, None)
+ } else NoSymbol
}
/**
@@ -487,4 +472,15 @@ trait NamesDefaults { self: Analyzer =>
}
(namelessArgs, argPos)
}
+
+ /**
+ * Finds the companion module of a class symbol. Calling .companionModule
+ * does not work for classes defined inside methods.
+ */
+ def companionModuleOf(clazz: Symbol, context: Context) = {
+ var res = clazz.companionModule
+ if (res == NoSymbol)
+ res = context.lookup(clazz.name.toTermName, clazz.owner)
+ res
+ }
}
diff --git a/src/intellij/actors.iml b/src/intellij/actors.iml.SAMPLE
index ace6ec7f62..ace6ec7f62 100644
--- a/src/intellij/actors.iml
+++ b/src/intellij/actors.iml.SAMPLE
diff --git a/src/intellij/compiler.iml b/src/intellij/compiler.iml.SAMPLE
index cc0b64e735..cc0b64e735 100644
--- a/src/intellij/compiler.iml
+++ b/src/intellij/compiler.iml.SAMPLE
diff --git a/src/intellij/dbc.iml b/src/intellij/dbc.iml.SAMPLE
index d82bda72b4..d82bda72b4 100644
--- a/src/intellij/dbc.iml
+++ b/src/intellij/dbc.iml.SAMPLE
diff --git a/src/intellij/library.iml b/src/intellij/library.iml.SAMPLE
index a8719634aa..a8719634aa 100644
--- a/src/intellij/library.iml
+++ b/src/intellij/library.iml.SAMPLE
diff --git a/src/intellij/manual.iml b/src/intellij/manual.iml.SAMPLE
index bbdcfbebc2..bbdcfbebc2 100644
--- a/src/intellij/manual.iml
+++ b/src/intellij/manual.iml.SAMPLE
diff --git a/src/intellij/partest.iml b/src/intellij/partest.iml.SAMPLE
index 3df457abdb..3df457abdb 100644
--- a/src/intellij/partest.iml
+++ b/src/intellij/partest.iml.SAMPLE
diff --git a/src/intellij/scala-lang.ipr b/src/intellij/scala-lang.ipr.SAMPLE
index 2506c74f6a..2506c74f6a 100644
--- a/src/intellij/scala-lang.ipr
+++ b/src/intellij/scala-lang.ipr.SAMPLE
diff --git a/src/intellij/scalap.iml b/src/intellij/scalap.iml.SAMPLE
index 48f98a0b1e..48f98a0b1e 100644
--- a/src/intellij/scalap.iml
+++ b/src/intellij/scalap.iml.SAMPLE
diff --git a/src/intellij/swing.iml b/src/intellij/swing.iml.SAMPLE
index c623fe0e72..c623fe0e72 100644
--- a/src/intellij/swing.iml
+++ b/src/intellij/swing.iml.SAMPLE
diff --git a/src/library/scala/collection/mutable/StringBuilder.scala b/src/library/scala/collection/mutable/StringBuilder.scala
index f43acdc796..9673e59486 100644
--- a/src/library/scala/collection/mutable/StringBuilder.scala
+++ b/src/library/scala/collection/mutable/StringBuilder.scala
@@ -31,7 +31,8 @@ import StringBuilder._
@SerialVersionUID(0 - 8525408645367278351L)
final class StringBuilder(initCapacity: Int, private val initValue: String)
extends Builder[Char, String]
- with IndexedSeq[Char] {
+ with IndexedSeq[Char]
+ with IndexedSeqOptimized[Char, IndexedSeq[Char]] {
require(initCapacity >= 0)
diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala
index dffebfc892..a0bdd122e6 100644
--- a/src/library/scala/runtime/ScalaRunTime.scala
+++ b/src/library/scala/runtime/ScalaRunTime.scala
@@ -14,7 +14,7 @@ package scala.runtime
import scala.reflect.ClassManifest
import scala.collection.{ Seq, IndexedSeq, TraversableView }
import scala.collection.mutable.WrappedArray
-import scala.collection.immutable.{ List, Stream, Nil, :: }
+import scala.collection.immutable.{ NumericRange, List, Stream, Nil, :: }
import scala.xml.{ Node, MetaData }
import scala.util.control.ControlThrowable
@@ -239,6 +239,9 @@ object ScalaRunTime {
case x: Node => x toString
// Not to mention MetaData extends Iterable[MetaData]
case x: MetaData => x toString
+ // Range/NumericRange have a custom toString to avoid walking a gazillion elements
+ case x: Range => x toString
+ case x: NumericRange[_] => x toString
case x: AnyRef if isArray(x) => WrappedArray make x map inner mkString ("Array(", ", ", ")")
case x: TraversableView[_, _] => x.toString
case x: Traversable[_] if !x.hasDefiniteSize => x.toString
diff --git a/test/files/pos/spec-asseenfrom.scala b/test/files/pos/spec-asseenfrom.scala
new file mode 100644
index 0000000000..edd801071a
--- /dev/null
+++ b/test/files/pos/spec-asseenfrom.scala
@@ -0,0 +1,29 @@
+class Automaton[@specialized(Double) W,State] {
+
+ def finalWeight(s: State): W = error("todo");
+
+ def allStates: Set[State] = error("toodo");
+
+ /**
+ * Returns a map from states to its final weight. may expand all nodes.
+ */
+ def finalStateWeights = Map.empty ++ allStates.map { s => (s,finalWeight(s)) }
+
+ // This works fine:
+ /*
+ def finalStateWeights() = {
+ val it = allStates.iterator;
+ while(it.hasNext) {
+ finalWeight(it.next);
+ }
+ }
+ */
+
+}
+
+abstract class Automaton2[@specialized T1, T2] {
+ def finalWeight(s: T2): T1
+ def allStates: Set[T2]
+
+ def f = allStates map finalWeight
+}
diff --git a/test/files/pos/spec-partialmap.scala b/test/files/pos/spec-partialmap.scala
new file mode 100644
index 0000000000..09684e0242
--- /dev/null
+++ b/test/files/pos/spec-partialmap.scala
@@ -0,0 +1,17 @@
+
+// ticket #3378, overloaded specialized variants
+import scala.collection.{Traversable,TraversableLike};
+import scala.collection.generic.CanBuildFrom;
+
+trait PartialMap[@specialized A,@specialized B]
+extends PartialFunction[A,B] with Iterable[(A,B)] {
+
+ // commenting out this declaration gives a different exception.
+ /** Getter for all values for which the given key function returns true. */
+ def apply(f : (A => Boolean)) : Iterator[B] =
+ for ((k,v) <- iterator; if f(k)) yield v;
+
+ // if this is commented, it compiles fine:
+ def apply[This <: Traversable[A], That](keys : TraversableLike[A,This])
+ (implicit bf: CanBuildFrom[This, B, That]) : That = keys.map(apply);
+}
diff --git a/test/files/pos/spec-private.scala b/test/files/pos/spec-private.scala
new file mode 100644
index 0000000000..7d53bad955
--- /dev/null
+++ b/test/files/pos/spec-private.scala
@@ -0,0 +1,10 @@
+class Foo {
+
+ def foo[@specialized(Int) T](x: T) = new Object {
+ private final val myEdges = List(1, 2 , 3)
+
+ def boo {
+ myEdges
+ }
+ }
+}
diff --git a/test/files/pos/spec-sparsearray.scala b/test/files/pos/spec-sparsearray.scala
new file mode 100644
index 0000000000..ea7710a785
--- /dev/null
+++ b/test/files/pos/spec-sparsearray.scala
@@ -0,0 +1,24 @@
+import scala.collection.mutable.MapLike
+
+class SparseArray[@specialized(Int) T:ClassManifest] extends collection.mutable.Map[Int,T] with collection.mutable.MapLike[Int,T,SparseArray[T]] {
+ override def get(x: Int) = {
+ val ind = findOffset(x)
+ if(ind < 0) None else Some(error("ignore"))
+ }
+
+ /**
+ * Returns the offset into index and data for the requested vector
+ * index. If the requested index is not found, the return value is
+ * negative and can be converted into an insertion point with -(rv+1).
+ */
+ private def findOffset(i : Int) : Int = {
+ error("impl doesn't matter")
+ }
+
+ override def apply(i : Int) : T = { error("ignore") }
+ override def update(i : Int, value : T) = error("ignore")
+ override def empty = new SparseArray[T]
+ def -=(ind: Int) = error("ignore")
+ def +=(kv: (Int,T)) = error("ignore")
+ override final def iterator = error("ignore")
+}
diff --git a/test/files/pos/spec-vector.scala b/test/files/pos/spec-vector.scala
new file mode 100644
index 0000000000..392949c669
--- /dev/null
+++ b/test/files/pos/spec-vector.scala
@@ -0,0 +1,4 @@
+// ticket #3379, abstract overrides
+trait Vector extends (Int=>Double) {
+ override def apply(i: Int): Double
+}
diff --git a/test/files/pos/t3177.scala b/test/files/pos/t3177.scala
new file mode 100644
index 0000000000..9f9528faec
--- /dev/null
+++ b/test/files/pos/t3177.scala
@@ -0,0 +1,39 @@
+trait InvariantFunctor[F[_]] {
+ def xmap[A, B](ma: F[A], f: A => B, g: B => A): F[B]
+}
+
+object InvariantFunctor {
+ import Endo._
+
+ implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] {
+ def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b)))
+ }
+
+ // The definition about fails with:
+ // anon-type.scala:9: error: not found: value b
+ // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b)))
+ // ^
+ // anon-type.scala:8: error: not found: type $anon
+ // implicit val EndoInvariantFunctor = new InvariantFunctor[Endo] {
+ // ^
+
+
+ // These both work:
+ // implicit val EndoInvariantFunctorAscribed: InvariantFunctor[Endo] = new InvariantFunctor[Endo] {
+ // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = (b: B) => f(ma(g(b)))
+ // }
+ //
+ // implicit val EndoInvariantFunctorStubbed = new InvariantFunctor[Endo] {
+ // def xmap[A, B](ma: Endo[A], f: A => B, g: B => A): Endo[B] = error("stub")
+ // }
+}
+
+trait Endo[X]
+
+object Endo {
+ implicit def EndoTo[A](f: A => A): Endo[A] = new Endo[A] {
+ def apply(a: A) = f(a)
+ }
+
+ implicit def EndoFrom[A](e: Endo[A]): A => A = e.apply(_)
+} \ No newline at end of file
diff --git a/test/files/pos/t3274.scala b/test/files/pos/t3274.scala
new file mode 100644
index 0000000000..15723184bb
--- /dev/null
+++ b/test/files/pos/t3274.scala
@@ -0,0 +1,9 @@
+trait A { this: B =>
+ trait X {
+ class Y1 extends Y
+ }
+}
+
+trait B extends A {
+ trait Y { def f {} }
+} \ No newline at end of file
diff --git a/test/files/pos/t3373.scala b/test/files/pos/t3373.scala
new file mode 100644
index 0000000000..b4af3610bb
--- /dev/null
+++ b/test/files/pos/t3373.scala
@@ -0,0 +1,11 @@
+class Entry(time: Long) {
+ def getTime: Long = time
+}
+
+object Test {
+ def extractTime(e: Entry) = e.getTime
+
+ implicit val orderEntries = new Ordering[Entry] {
+ def compare(first: Entry, second: Entry) = extractTime(first) compare extractTime(second)
+ }
+} \ No newline at end of file
diff --git a/test/files/pos/t3384.scala b/test/files/pos/t3384.scala
new file mode 100644
index 0000000000..4d4a81d69d
--- /dev/null
+++ b/test/files/pos/t3384.scala
@@ -0,0 +1,14 @@
+package test
+
+package p {
+ class A(a: String = "")
+}
+
+package object po {
+ type A = p.A
+}
+
+import po._
+class C {
+ val a = new A() //p.A.init$default$1)
+}