diff options
71 files changed, 632 insertions, 343 deletions
diff --git a/project.SAMPLE b/project.SAMPLE index b1f7386a4a..0034c397ed 100644 --- a/project.SAMPLE +++ b/project.SAMPLE @@ -6,16 +6,6 @@ </projects> <buildSpec> <buildCommand> - <name>org.eclipse.pde.ManifestBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.pde.SchemaBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> <name>org.scala-ide.sdt.core.scalabuilder</name> <arguments> </arguments> @@ -23,7 +13,6 @@ </buildSpec> <natures> <nature>org.scala-ide.sdt.core.scalanature</nature> - <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> </natures> </projectDescription> diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index edafde1346..0612dcdfd4 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -1207,7 +1207,7 @@ trait Definitions extends reflect.api.StandardDefinitions { def isPrimitiveValueClass(sym: Symbol) = ScalaValueClasses contains sym def isNonUnitValueClass(sym: Symbol) = isPrimitiveValueClass(sym) && (sym != UnitClass) def isSpecializableClass(sym: Symbol) = isPrimitiveValueClass(sym) || (sym == AnyRefClass) - def isScalaValueType(tp: Type) = ScalaValueClasses contains tp.typeSymbol + def isPrimitiveValueType(tp: Type) = isPrimitiveValueClass(tp.typeSymbol) /** Is symbol a boxed value class, e.g. java.lang.Integer? */ def isBoxedValueClass(sym: Symbol) = boxedValueClassesSet(sym) diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala index 0cdf65bd8f..bd4d9a9f34 100644 --- a/src/compiler/scala/reflect/internal/StdNames.scala +++ b/src/compiler/scala/reflect/internal/StdNames.scala @@ -766,7 +766,6 @@ trait StdNames { object fulltpnme extends TypeNames { val RuntimeNothing: NameType = "scala.runtime.Nothing$" val RuntimeNull: NameType = "scala.runtime.Null$" - val JavaLangEnum: NameType = "java.lang.Enum" } /** Java binary names, like scala/runtime/Nothing$. diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index 2a5b759f94..724e5bf628 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -2088,7 +2088,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** String representation of symbol's definition key word */ final def keyString: String = if (isJavaInterface) "interface" - else if (isTrait) "trait" + else if (isTrait && !isImplClass) "trait" else if (isClass) "class" else if (isType && !isParameter) "type" else if (isVariable) "var" @@ -2116,6 +2116,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => else if (isSetter) ("setter", if (isSourceMethod) "method" else "value", "SET") else if (isTerm && isLazy) ("lazy value", "lazy value", "LAZ") else if (isVariable) ("field", "variable", "VAR") + else if (isImplClass) ("implementation class", "class", "IMPL") else if (isTrait) ("trait", "trait", "TRT") else if (isClass) ("class", "class", "CLS") else if (isType) ("type", "type", "TPE") @@ -2232,7 +2233,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => } def infosString = infos.toString - def debugLocationString = fullLocationString + " " + debugFlagString + def debugLocationString = fullLocationString + " (flags: " + debugFlagString + ")" private def defStringCompose(infoString: String) = compose( flagString, diff --git a/src/compiler/scala/reflect/internal/Trees.scala b/src/compiler/scala/reflect/internal/Trees.scala index e2d9310424..3e7f23800c 100644 --- a/src/compiler/scala/reflect/internal/Trees.scala +++ b/src/compiler/scala/reflect/internal/Trees.scala @@ -145,11 +145,12 @@ trait Trees extends api.Trees { self: SymbolTable => */ def summaryString: String = tree match { case Literal(const) => "Literal(" + const + ")" - case Select(qual, name) => qual.summaryString + "." + name.decode + case Ident(name) => "Ident(%s)".format(name.decode) + case Select(qual, name) => "Select(%s, %s)".format(qual.summaryString, name.decode) case t: NameTree => t.name.longString case t => t.shortClass + ( - if (t.symbol != null && t.symbol != NoSymbol) " " + t.symbol + if (t.symbol != null && t.symbol != NoSymbol) "(" + t.symbol + ")" else "" ) } diff --git a/src/compiler/scala/reflect/internal/Types.scala b/src/compiler/scala/reflect/internal/Types.scala index 09e7303b90..81582db5f2 100644 --- a/src/compiler/scala/reflect/internal/Types.scala +++ b/src/compiler/scala/reflect/internal/Types.scala @@ -2663,6 +2663,10 @@ trait Types extends api.Types { self: SymbolTable => override def kind = "OverloadedType" } + def overloadedType(pre: Type, alternatives: List[Symbol]): Type = + if (alternatives.tail.isEmpty) pre memberType alternatives.head + else OverloadedType(pre, alternatives) + /** A class remembering a type instantiation for some a set of overloaded * polymorphic symbols. * Not used after phase `typer`. diff --git a/src/compiler/scala/reflect/internal/transform/Erasure.scala b/src/compiler/scala/reflect/internal/transform/Erasure.scala index 1b323f839b..5beec70d62 100644 --- a/src/compiler/scala/reflect/internal/transform/Erasure.scala +++ b/src/compiler/scala/reflect/internal/transform/Erasure.scala @@ -17,7 +17,14 @@ trait Erasure { * with primitive as well as class types)?. */ private def genericCore(tp: Type): Type = tp.normalize match { - case TypeRef(_, sym, _) if sym.isAbstractType && !sym.owner.isJavaDefined => + /* A Java Array<T> is erased to Array[Object] (T can only be a reference type), where as a Scala Array[T] is + * erased to Object. However, there is only symbol for the Array class. So to make the distinction between + * a Java and a Scala array, we check if the owner of T comes from a Java class. + * This however caused issue SI-5654. The additional test for EXSITENTIAL fixes it, see the ticket comments. + * In short, members of an existential type (e.g. `T` in `forSome { type T }`) can have pretty arbitrary + * owners (e.g. when computing lubs, <root> is used). All packageClass symbols have `isJavaDefined == true`. + */ + case TypeRef(_, sym, _) if sym.isAbstractType && (!sym.owner.isJavaDefined || sym.hasFlag(Flags.EXISTENTIAL)) => tp case ExistentialType(tparams, restp) => genericCore(restp) diff --git a/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala b/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala index eb384f9a85..1424226042 100644 --- a/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala +++ b/src/compiler/scala/reflect/internal/util/TraceSymbolActivity.scala @@ -7,7 +7,7 @@ trait TraceSymbolActivity { val global: SymbolTable import global._ - if (traceSymbolActivity) + if (traceSymbolActivity && !global.inReflexiveMirror) scala.sys addShutdownHook showAllSymbols() private type Set[T] = scala.collection.immutable.Set[T] diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index d3564017f9..de270a76f1 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -162,7 +162,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb /** Register new context; called for every created context */ - def registerContext(c: analyzer.Context) {} + def registerContext(c: analyzer.Context) { + lastSeenContext = c + } /** Register top level class (called on entering the class) */ @@ -894,6 +896,10 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb curRun = null } + object typeDeconstruct extends { + val global: Global.this.type = Global.this + } with interpreter.StructuredTypeStrings + /** There are common error conditions where when the exception hits * here, currentRun.currentUnit is null. This robs us of the knowledge * of what file was being compiled when it broke. Since I really @@ -901,6 +907,11 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb */ private var lastSeenSourceFile: SourceFile = NoSourceFile + /** Let's share a lot more about why we crash all over the place. + * People will be very grateful. + */ + private var lastSeenContext: analyzer.Context = null + /** The currently active run */ def currentRun: Run = curRun @@ -929,25 +940,64 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb @inline final def beforeTyper[T](op: => T): T = beforePhase(currentRun.typerPhase)(op) @inline final def beforeUncurry[T](op: => T): T = beforePhase(currentRun.uncurryPhase)(op) + def explainContext(c: analyzer.Context): String = ( + if (c == null) "" else ( + """| context owners: %s + | + |Enclosing block or template: + |%s""".format( + c.owner.ownerChain.takeWhile(!_.isPackageClass).mkString(" -> "), + nodePrinters.nodeToString(c.enclClassOrMethod.tree) + ) + ) + ) + // Owners up to and including the first package class. + private def ownerChainString(sym: Symbol): String = ( + if (sym == null) "" + else sym.ownerChain.span(!_.isPackageClass) match { + case (xs, pkg :: _) => (xs :+ pkg) mkString " -> " + case _ => sym.ownerChain mkString " -> " // unlikely + } + ) + private def formatExplain(pairs: (String, Any)*): String = ( + pairs.toList collect { case (k, v) if v != null => "%20s: %s".format(k, v) } mkString "\n" + ) + + def explainTree(t: Tree): String = formatExplain( + ) + /** Don't want to introduce new errors trying to report errors, * so swallow exceptions. */ override def supplementErrorMessage(errorMessage: String): String = try { - """| - | while compiling: %s - | current phase: %s - | library version: %s - | compiler version: %s - | reconstructed args: %s - | - |%s""".stripMargin.format( - currentSource.path, - phase, - scala.util.Properties.versionString, - Properties.versionString, - settings.recreateArgs.mkString(" "), - if (opt.debug) "Current unit body:\n" + currentUnit.body + "\n" + errorMessage else errorMessage + val tree = analyzer.lastTreeToTyper + val sym = tree.symbol + val tpe = tree.tpe + val enclosing = lastSeenContext.enclClassOrMethod.tree + + val info1 = formatExplain( + "while compiling" -> currentSource.path, + "during phase" -> phase, + "library version" -> scala.util.Properties.versionString, + "compiler version" -> Properties.versionString, + "reconstructed args" -> settings.recreateArgs.mkString(" ") + ) + val info2 = formatExplain( + "last tree to typer" -> tree.summaryString, + "symbol" -> Option(sym).fold("null")(_.debugLocationString), + "symbol definition" -> Option(sym).fold("null")(_.defString), + "tpe" -> tpe, + "symbol owners" -> ownerChainString(sym), + "context owners" -> ownerChainString(lastSeenContext.owner) ) + val info3: List[String] = ( + ( List("== Enclosing template or block ==", nodePrinters.nodeToString(enclosing).trim) ) + ++ ( if (tpe eq null) Nil else List("== Expanded type of tree ==", typeDeconstruct.show(tpe)) ) + ++ ( if (!opt.debug) Nil else List("== Current unit body ==", nodePrinters.nodeToString(currentUnit.body)) ) + ++ ( List(errorMessage) ) + ) + + ("\n" + info1) :: info2 :: info3 mkString "\n\n" } catch { case x: Exception => errorMessage } diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala index a93d9efded..23fcffd657 100644 --- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala +++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala @@ -236,7 +236,7 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { mkMethodCall( PredefModule, wrapArrayMethodName(elemtp), - if (isScalaValueType(elemtp)) Nil else List(elemtp), + if (isPrimitiveValueType(elemtp)) Nil else List(elemtp), List(tree) ) } @@ -261,7 +261,7 @@ abstract class TreeGen extends reflect.internal.TreeGen with TreeDSL { * elem type elemtp to expected type pt. */ def mkCastArray(tree: Tree, elemtp: Type, pt: Type) = - if (elemtp.typeSymbol == AnyClass && isScalaValueType(tree.tpe.typeArgs.head)) + if (elemtp.typeSymbol == AnyClass && isPrimitiveValueType(tree.tpe.typeArgs.head)) mkCast(mkRuntimeCall(nme.toObjectArray, List(tree)), pt) else mkCast(tree, pt) diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala index 4aeb537f9b..f7541a4739 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala @@ -1208,7 +1208,7 @@ abstract class GenICode extends SubComponent { if (!tree.symbol.isPackageClass) tree.symbol else tree.symbol.info.member(nme.PACKAGE) match { case NoSymbol => assert(false, "Cannot use package as value: " + tree) ; NoSymbol - case s => Console.err.println("Bug: found package class where package object expected. Converting.") ; s.moduleClass + case s => debugwarn("Bug: found package class where package object expected. Converting.") ; s.moduleClass } ) debuglog("LOAD_MODULE from %s: %s".format(tree.shortClass, sym)) diff --git a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala index 042e739abe..7d3249a7d3 100644 --- a/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala +++ b/src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala @@ -1159,6 +1159,27 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with */ def generateMirrorClass(clasz: Symbol, sourceFile: SourceFile) { import JAccessFlags._ + /* We need to save inner classes buffer and create a new one to make sure + * that we do confuse inner classes of the class we mirror with inner + * classes of the class we are mirroring. These two sets can be different + * as seen in this case: + * + * class A { + * class B + * def b: B = new B + * } + * object C extends A + * + * Here mirror class of C has a static forwarder for (inherited) method `b` + * therefore it refers to class `B` and needs InnerClasses entry. However, + * the real class for `C` (named `C$`) is empty and does not refer to `B` + * thus does not need InnerClasses entry it. + * + * NOTE: This logic has been refactored in GenASM and everything is + * implemented in a much cleaner way by having two separate buffers. + */ + val savedInnerClasses = innerClassBuffer + innerClassBuffer = mutable.LinkedHashSet[Symbol]() val moduleName = javaName(clasz) // + "$" val mirrorName = moduleName.substring(0, moduleName.length() - 1) val mirrorClass = fjbgContext.JClass(ACC_SUPER | ACC_PUBLIC | ACC_FINAL, @@ -1172,6 +1193,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid with val ssa = scalaSignatureAddingMarker(mirrorClass, clasz.companionSymbol) addAnnotations(mirrorClass, clasz.annotations ++ ssa) emitClass(mirrorClass, clasz) + innerClassBuffer = savedInnerClasses } var linearization: List[BasicBlock] = Nil diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala index 61f3670f5f..c3525037cd 100644 --- a/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala +++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactoryImplicitSupport.scala @@ -179,7 +179,7 @@ trait ModelFactoryImplicitSupport { hardcoded.arraySkipConversions.contains(conv.conversionQualifiedName)) // Filter out non-sensical conversions from value types - if (isScalaValueType(sym.tpe)) + if (isPrimitiveValueType(sym.tpe)) conversions = conversions.filter((ic: ImplicitConversion) => hardcoded.valueClassFilter(sym.nameString, ic.conversionQualifiedName)) diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index cf80570563..edf0108e58 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -930,7 +930,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") val implicitlyAdded = viaView != NoSymbol members.add(sym, pre, implicitlyAdded) { (s, st) => new TypeMember(s, st, - context.isAccessible(s, pre, superAccess && !implicitlyAdded), + context.isAccessible(if (s.hasGetter) s.getter(s.owner) else s, pre, superAccess && !implicitlyAdded), inherited, viaView) } diff --git a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala index 5c413243e8..f71e067366 100644 --- a/src/compiler/scala/tools/nsc/javac/JavaParsers.scala +++ b/src/compiler/scala/tools/nsc/javac/JavaParsers.scala @@ -872,7 +872,10 @@ trait JavaParsers extends ast.parser.ParsersCommon with JavaScanners { skipAhead() accept(RBRACE) } - ValDef(Modifiers(Flags.JAVA | Flags.STATIC), name, enumType, blankExpr) + // The STABLE flag is to signal to namer that this was read from a + // java enum, and so should be given a Constant type (thereby making + // it usable in annotations.) + ValDef(Modifiers(Flags.STABLE | Flags.JAVA | Flags.STATIC), name, enumType, blankExpr) } } diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index 055d5d9c39..3de287e58c 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -625,7 +625,7 @@ abstract class Erasure extends AddInterfaces tree.duplicate setType pt } else if (tree.tpe != null && tree.tpe.typeSymbol == ArrayClass && pt.typeSymbol == ArrayClass) { // See SI-2386 for one example of when this might be necessary. - val needsExtraCast = isScalaValueType(tree.tpe.typeArgs.head) && !isScalaValueType(pt.typeArgs.head) + val needsExtraCast = isPrimitiveValueType(tree.tpe.typeArgs.head) && !isPrimitiveValueType(pt.typeArgs.head) val tree1 = if (needsExtraCast) gen.mkRuntimeCall(nme.toObjectArray, List(tree)) else tree gen.mkAttributedCast(tree1, pt) } else gen.mkAttributedCast(tree, pt) diff --git a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala index aea29a27dd..7e780304e7 100644 --- a/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala +++ b/src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala @@ -67,7 +67,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { import definitions.{ RootClass, BooleanClass, UnitClass, ArrayClass, - ScalaValueClasses, isPrimitiveValueClass, isScalaValueType, + ScalaValueClasses, isPrimitiveValueClass, isPrimitiveValueType, SpecializedClass, UnspecializedClass, AnyRefClass, ObjectClass, AnyRefModule, GroupOfSpecializable, uncheckedVarianceClass, ScalaInlineClass } @@ -145,7 +145,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { def includes(t1: TypeEnv, t2: TypeEnv) = t1 forall { case (sym, tpe) => t2 get sym exists { t2tp => - (tpe == t2tp) || !(isScalaValueType(tpe) || isScalaValueType(t2tp)) // u.t.b. (t2tp <:< AnyRefClass.tpe) + (tpe == t2tp) || !(isPrimitiveValueType(tpe) || isPrimitiveValueType(t2tp)) // u.t.b. (t2tp <:< AnyRefClass.tpe) } } @@ -266,7 +266,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { * specialized type. */ def survivingArgs(sym: Symbol, args: List[Type]): List[Type] = - for ((tvar, tpe) <- sym.info.typeParams.zip(args) if !tvar.isSpecialized || !isScalaValueType(tpe)) + for ((tvar, tpe) <- sym.info.typeParams.zip(args) if !tvar.isSpecialized || !isPrimitiveValueType(tpe)) yield tpe val specializedType = new TypeMap { @@ -448,7 +448,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { /** Type parameters that survive when specializing in the specified environment. */ def survivingParams(params: List[Symbol], env: TypeEnv) = - params.filter(p => !p.isSpecialized || !isScalaValueType(env(p))) + params.filter(p => !p.isSpecialized || !isPrimitiveValueType(env(p))) /** Produces the symbols from type parameters `syms` of the original owner, * in the given type environment `env`. The new owner is `nowner`. @@ -1588,7 +1588,7 @@ abstract class SpecializeTypes extends InfoTransform with TypingTransformers { // val (_, origtparams) = splitParams(source.typeParams) val env = typeEnv(symbol) val boundTvars = env.keySet - val origtparams = source.typeParams.filter(tparam => !boundTvars(tparam) || !isScalaValueType(env(tparam))) + val origtparams = source.typeParams.filter(tparam => !boundTvars(tparam) || !isPrimitiveValueType(env(tparam))) if (origtparams.nonEmpty || symbol.typeParams.nonEmpty) debuglog("substituting " + origtparams + " for " + symbol.typeParams) diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index ca4b1d3de8..e4b744dffc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -567,7 +567,15 @@ trait Namers extends MethodSynthesis { assignAndEnterFinishedSymbol(tree) else enterGetterSetter(tree) + + // When java enums are read from bytecode, they are known to have + // constant types by the jvm flag and assigned accordingly. When + // they are read from source, the java parser marks them with the + // STABLE flag, and now we receive that signal. + if (tree.symbol hasAllFlags STABLE | JAVA) + tree.symbol setInfo ConstantType(Constant(tree.symbol)) } + def enterLazyVal(tree: ValDef, lazyAccessor: Symbol): TermSymbol = { // If the owner is not a class, this is a lazy val from a method, // with no associated field. It has an accessor with $lzy appended to its name and diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 6bed0b1228..b878ce3a53 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1279,6 +1279,15 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R } def transformStat(tree: Tree, index: Int): List[Tree] = tree match { + case t if treeInfo.isSelfConstrCall(t) => + assert(index == 0, index) + val t = transform(tree) + if (currentLevel.maxindex > 0) { + // An implementation restriction to avoid VerifyErrors and lazyvals mishaps; see SI-4717 + debuglog("refsym = " + currentLevel.refsym) + unit.error(currentLevel.refpos, "forward reference not allowed from self constructor invocation") + } + List(t) case ModuleDef(_, _, _) => eliminateModuleDefs(tree) case ValDef(_, _, _, _) => val tree1 @ ValDef(_, _, _, rhs) = transform(tree) // important to do before forward reference check diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 484c8beb1b..6faa9a3cb7 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -254,6 +254,12 @@ trait SyntheticMethods extends ast.TreeDSL { Block(valdef :: mixes, finish) } } + def chooseHashcode = { + if (accessors exists (x => isPrimitiveValueType(x.tpe.finalResultType))) + specializedHashcode + else + forwardToRuntime(Object_hashCode) + } def valueClassMethods = List( Any_hashCode -> (() => hashCodeDerivedValueClassMethod), @@ -261,7 +267,7 @@ trait SyntheticMethods extends ast.TreeDSL { ) def caseClassMethods = productMethods ++ productNMethods ++ Seq( - Object_hashCode -> (() => specializedHashcode), + Object_hashCode -> (() => chooseHashcode), Object_toString -> (() => forwardToRuntime(Object_toString)), Object_equals -> (() => equalsCaseClassMethod) ) diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 343636ff1e..b5e58efaff 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -31,7 +31,6 @@ trait Typers extends Modes with Adaptations with Taggings { import global._ import definitions._ - import patmat.DefaultOverrideMatchAttachment final def forArgMode(fun: Tree, mode: Int) = @@ -85,6 +84,12 @@ trait Typers extends Modes with Adaptations with Taggings { private def isPastTyper = phase.id > currentRun.typerPhase.id + // To enable decent error messages when the typer crashes. + // TODO - this only catches trees which go through def typed, + // but there are all kinds of back ways - typedClassDef, etc. etc. + // Funnel everything through one doorway. + var lastTreeToTyper: Tree = EmptyTree + // when true: // - we may virtualize matches (if -Xexperimental and there's a suitable __match in scope) // - we synthesize PartialFunction implementations for `x => x match {...}` and `match {...}` when the expected type is PartialFunction @@ -953,9 +958,14 @@ trait Typers extends Modes with Adaptations with Taggings { * see test/files/../t5189*.scala */ def adaptConstrPattern(): Tree = { // (5) - val extractor = tree.symbol.filter(sym => reallyExists(unapplyMember(sym.tpe))) + def isExtractor(sym: Symbol) = reallyExists(unapplyMember(sym.tpe)) + val extractor = tree.symbol filter isExtractor if (extractor != NoSymbol) { tree setSymbol extractor + tree.tpe match { + case OverloadedType(pre, alts) => tree.tpe = overloadedType(pre, alts filter isExtractor) + case _ => + } val unapply = unapplyMember(extractor.tpe) val clazz = unapplyParameterType(unapply) @@ -4972,6 +4982,7 @@ trait Typers extends Modes with Adaptations with Taggings { * @return ... */ def typed(tree: Tree, mode: Int, pt: Type): Tree = { + lastTreeToTyper = tree indentTyping() var alreadyTyped = false diff --git a/src/library/scala/concurrent/ConcurrentPackageObject.scala b/src/library/scala/concurrent/ConcurrentPackageObject.scala index a3d985733e..c3c329121c 100644 --- a/src/library/scala/concurrent/ConcurrentPackageObject.scala +++ b/src/library/scala/concurrent/ConcurrentPackageObject.scala @@ -11,7 +11,6 @@ package scala.concurrent import java.util.concurrent.{ Executors, ExecutorService, ThreadFactory } import scala.concurrent.forkjoin.{ ForkJoinPool, ForkJoinWorkerThread } import scala.concurrent.util.Duration -import ConcurrentPackageObject._ import language.implicitConversions @@ -36,19 +35,6 @@ abstract class ConcurrentPackageObject { case _ => true } - private[concurrent] def resolveEither[T](source: Either[Throwable, T]): Either[Throwable, T] = source match { - case Left(t) => resolver(t) - case _ => source - } - - private[concurrent] def resolver[T](throwable: Throwable): Either[Throwable, T] = throwable match { - case t: scala.runtime.NonLocalReturnControl[_] => Right(t.value.asInstanceOf[T]) - case t: scala.util.control.ControlThrowable => Left(new ExecutionException("Boxed ControlThrowable", t)) - case t: InterruptedException => Left(new ExecutionException("Boxed InterruptedException", t)) - case e: Error => Left(new ExecutionException("Boxed Error", e)) - case t => Left(t) - } - /* concurrency constructs */ /** Starts an asynchronous computation and returns a `Future` object with the result of that computation. @@ -102,18 +88,3 @@ abstract class ConcurrentPackageObject { @inline implicit final def int2durationops(x: Int): DurationOps = new DurationOps(x) } - -private[concurrent] object ConcurrentPackageObject { - // TODO, docs, return type - // Note that having this in the package object led to failures when - // compiling a subset of sources; it seems that the wildcard is not - // properly handled, and you get messages like "type _$1 defined twice". - // This is consistent with other package object breakdowns. - // private val resolverFunction: PartialFunction[Throwable, Either[Throwable, _]] = { - // case t: scala.runtime.NonLocalReturnControl[_] => Right(t.value) - // case t: scala.util.control.ControlThrowable => Left(new ExecutionException("Boxed ControlThrowable", t)) - // case t: InterruptedException => Left(new ExecutionException("Boxed InterruptedException", t)) - // case e: Error => Left(new ExecutionException("Boxed Error", e)) - // case t => Left(t) - // } -} diff --git a/src/library/scala/concurrent/ExecutionContext.scala b/src/library/scala/concurrent/ExecutionContext.scala index 4666674b5b..d2a2d5e8a8 100644 --- a/src/library/scala/concurrent/ExecutionContext.scala +++ b/src/library/scala/concurrent/ExecutionContext.scala @@ -54,8 +54,7 @@ object ExecutionContext { def fromExecutor(e: Executor, reporter: Throwable => Unit = defaultReporter): ExecutionContext with Executor = new impl.ExecutionContextImpl(e, reporter) def defaultReporter: Throwable => Unit = { - // `Error`s are currently wrapped by `resolver`. - // Also, re-throwing `Error`s here causes an exception handling test to fail. + // re-throwing `Error`s here causes an exception handling test to fail. //case e: Error => throw e case t => t.printStackTrace() } diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 70b3c3dbbb..496e4698d4 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -201,7 +201,7 @@ trait Future[+T] extends Awaitable[T] { case Right(v) => try p success f(v) catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } } @@ -227,7 +227,7 @@ trait Future[+T] extends Awaitable[T] { case Right(v) => p success v } } catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } } @@ -260,7 +260,7 @@ trait Future[+T] extends Awaitable[T] { if (pred(v)) p success v else p failure new NoSuchElementException("Future.filter predicate is not satisfied by: " + v) } catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } } @@ -309,7 +309,7 @@ trait Future[+T] extends Awaitable[T] { if (pf.isDefinedAt(v)) p success pf(v) else p failure new NoSuchElementException("Future.collect partial function is not defined at: " + v) } catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } } @@ -334,7 +334,9 @@ trait Future[+T] extends Awaitable[T] { onComplete { case Left(t) if pf isDefinedAt t => try { p success pf(t) } - catch { case NonFatal(t) => p complete resolver(t) } + catch { + case NonFatal(t) => p failure t + } case otherwise => p complete otherwise } @@ -362,7 +364,7 @@ trait Future[+T] extends Awaitable[T] { try { p completeWith pf(t) } catch { - case NonFatal(t) => p complete resolver(t) + case NonFatal(t) => p failure t } case otherwise => p complete otherwise } diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala index 7dc3ed2988..3ed960c7ab 100644 --- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala +++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala @@ -10,10 +10,10 @@ package scala.concurrent.impl -import java.util.concurrent.{Callable, Executor, ExecutorService, Executors, ThreadFactory} +import java.util.concurrent.{ Callable, Executor, ExecutorService, Executors, ThreadFactory } import scala.concurrent.forkjoin._ -import scala.concurrent.{ExecutionContext, resolver, Awaitable} -import scala.concurrent.util.{ Duration } +import scala.concurrent.{ ExecutionContext, Awaitable } +import scala.concurrent.util.Duration diff --git a/src/library/scala/concurrent/impl/Future.scala b/src/library/scala/concurrent/impl/Future.scala index 20d4122e8f..bf136b6195 100644 --- a/src/library/scala/concurrent/impl/Future.scala +++ b/src/library/scala/concurrent/impl/Future.scala @@ -57,7 +57,7 @@ private[concurrent] object Future { case NonFatal(e) => // Commenting out reporting for now, since it produces too much output in the tests //executor.reportFailure(e) - scala.concurrent.resolver(e) + Left(e) } } }) diff --git a/src/library/scala/concurrent/impl/Promise.scala b/src/library/scala/concurrent/impl/Promise.scala index da70b3dea5..5a5b893f16 100644 --- a/src/library/scala/concurrent/impl/Promise.scala +++ b/src/library/scala/concurrent/impl/Promise.scala @@ -11,7 +11,7 @@ package scala.concurrent.impl import java.util.concurrent.TimeUnit.{ NANOSECONDS, MILLISECONDS } -import scala.concurrent.{Awaitable, ExecutionContext, resolveEither, resolver, blocking, CanAwait, TimeoutException} +import scala.concurrent.{ Awaitable, ExecutionContext, blocking, CanAwait, TimeoutException, ExecutionException } //import scala.util.continuations._ import scala.concurrent.util.Duration import scala.util @@ -26,6 +26,20 @@ private[concurrent] trait Promise[T] extends scala.concurrent.Promise[T] with Fu object Promise { + + private def resolveEither[T](source: Either[Throwable, T]): Either[Throwable, T] = source match { + case Left(t) => resolver(t) + case _ => source + } + + private def resolver[T](throwable: Throwable): Either[Throwable, T] = throwable match { + case t: scala.runtime.NonLocalReturnControl[_] => Right(t.value.asInstanceOf[T]) + case t: scala.util.control.ControlThrowable => Left(new ExecutionException("Boxed ControlThrowable", t)) + case t: InterruptedException => Left(new ExecutionException("Boxed InterruptedException", t)) + case e: Error => Left(new ExecutionException("Boxed Error", e)) + case t => Left(t) + } + /** Default promise implementation. */ class DefaultPromise[T](implicit val executor: ExecutionContext) extends AbstractPromise with Promise[T] { self => diff --git a/test/files/neg/t4098.check b/test/files/neg/t4098.check new file mode 100644 index 0000000000..7d69cf151c --- /dev/null +++ b/test/files/neg/t4098.check @@ -0,0 +1,13 @@ +t4098.scala:3: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:8: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:13: error: forward reference not allowed from self constructor invocation + this(b) + ^ +t4098.scala:18: error: forward reference not allowed from self constructor invocation + this(b) + ^ +four errors found diff --git a/test/files/neg/t4098.scala b/test/files/neg/t4098.scala new file mode 100644 index 0000000000..744d6191b5 --- /dev/null +++ b/test/files/neg/t4098.scala @@ -0,0 +1,22 @@ +class A(a: Any) { + def this() = { + this(b) + def b = new {} + } + + def this(x: Int) = { + this(b) + lazy val b = new {} + } + + def this(x: Int, y: Int) = { + this(b) + val b = new {} + } + + def this(x: Int, y: Int, z: Int) = { + this(b) + println(".") + def b = new {} + } +} diff --git a/test/files/pos/overloaded_extractor_and_regular_def.scala b/test/files/pos/overloaded_extractor_and_regular_def.scala new file mode 100644 index 0000000000..c8e7da5cad --- /dev/null +++ b/test/files/pos/overloaded_extractor_and_regular_def.scala @@ -0,0 +1,32 @@ +trait TreesBase { + type Tree + + type Apply <: Tree + + val Apply: ApplyExtractor + + abstract class ApplyExtractor { + def apply(x: Int): Apply + def unapply(apply: Apply): Option[Int] + } +} + +trait TreesApi extends TreesBase { + def Apply(x: String) +} + +class Universe extends TreesApi { + abstract class Tree + case class Apply(x: Int) extends Tree + object Apply extends ApplyExtractor + def Apply(x: String) = Apply(x.toInt) +} + +object Test extends App { + def foo(tapi: TreesApi) { + import tapi._ + def bar(tree: Tree) { + val Apply(x) = tree + } + } +}
\ No newline at end of file diff --git a/test/files/pos/t1987.scala b/test/files/pos/t1987a.scala index ccab133716..ccab133716 100644 --- a/test/files/pos/t1987.scala +++ b/test/files/pos/t1987a.scala diff --git a/test/files/pos/t2435.scala b/test/files/pos/t2435.scala new file mode 100644 index 0000000000..2db931b99f --- /dev/null +++ b/test/files/pos/t2435.scala @@ -0,0 +1,27 @@ +object Bug { + abstract class FChain { + type T + + def chain(constant:String) = + new FConstant[this.type](constant, this) //removing [this.type], everything compiles + } + + case class FConstant[E <: FChain](constant:String, tail:E) extends FChain { + type T = tail.T + } + + object FNil extends FChain { + type T = Unit + } + +} + +object Test { + import Bug._ + println("Compiles:") + val a1 = FNil.chain("a").chain("a") + val a2 = a1.chain("a") + + println("\nDoesn't compile:") + val a = FNil.chain("a").chain("a").chain("a") +} diff --git a/test/files/pos/t2764/Ann.java b/test/files/pos/t2764/Ann.java new file mode 100644 index 0000000000..184fc6e864 --- /dev/null +++ b/test/files/pos/t2764/Ann.java @@ -0,0 +1,5 @@ +package bippy; + +public @interface Ann { + Enum value(); +} diff --git a/test/files/pos/t2764/Enum.java b/test/files/pos/t2764/Enum.java new file mode 100644 index 0000000000..fe07559535 --- /dev/null +++ b/test/files/pos/t2764/Enum.java @@ -0,0 +1,5 @@ +package bippy; + +public enum Enum { + VALUE; +} diff --git a/test/files/pos/t2764/Use.scala b/test/files/pos/t2764/Use.scala new file mode 100644 index 0000000000..8cf8102709 --- /dev/null +++ b/test/files/pos/t2764/Use.scala @@ -0,0 +1,6 @@ +package bippy + +class Use { + @Ann(Enum.VALUE) + def foo {} +} diff --git a/test/files/pos/t4651.scala b/test/files/pos/t4651.scala new file mode 100644 index 0000000000..0612a8fcfb --- /dev/null +++ b/test/files/pos/t4651.scala @@ -0,0 +1,12 @@ +object Test { + def analyze(x: Any) = x match { + case s: String => println("It's a string: " + s) + case 1 => println("It's a one") + case (a: Int, b) => println("It's a pair of and int " + a + + " and something " + b) + case 1 :: 2 :: _ => println("It's a list starting with 1, 2") + case List(a, b, c) => println("It's a three-element list with " + + a + ", " + b + ", " + c) + case _ => println("It's something different") + } +} diff --git a/test/files/pos/t5165/TestAnnotation.java b/test/files/pos/t5165/TestAnnotation.java new file mode 100644 index 0000000000..90886b7537 --- /dev/null +++ b/test/files/pos/t5165/TestAnnotation.java @@ -0,0 +1,11 @@ +import java.lang.annotation.*; + +@Retention(RetentionPolicy.RUNTIME) +public @interface TestAnnotation { + public enum TestEnumOne { A, B } + public enum TestEnumTwo { C, D } + + public TestEnumOne one(); + public TestEnumTwo two(); + public String strVal(); +} diff --git a/test/files/pos/t5165/TestObject.scala b/test/files/pos/t5165/TestObject.scala new file mode 100644 index 0000000000..eaf244e9d0 --- /dev/null +++ b/test/files/pos/t5165/TestObject.scala @@ -0,0 +1,3 @@ + +object TestObject extends TestTrait + diff --git a/test/files/pos/t5165/TestTrait.scala b/test/files/pos/t5165/TestTrait.scala new file mode 100644 index 0000000000..b317e6c6a3 --- /dev/null +++ b/test/files/pos/t5165/TestTrait.scala @@ -0,0 +1,3 @@ + +@TestAnnotation(one=TestAnnotation.TestEnumOne.A, two=TestAnnotation.TestEnumTwo.C, strVal="something") +trait TestTrait diff --git a/test/files/pos/t5654.scala b/test/files/pos/t5654.scala new file mode 100644 index 0000000000..1f8d05bfed --- /dev/null +++ b/test/files/pos/t5654.scala @@ -0,0 +1,13 @@ +class T(val a: Array[_]) + +class U { + val a = Array(Array(1, 2), Array("a","b")) +} + +class T1 { val a: Array[_] = Array(1) } + +case class Bomb(a: Array[_]) +case class Bomb2(a: Array[T] forSome { type T }) +class Okay1(a: Array[_]) +case class Okay2(s: Seq[_]) + diff --git a/test/files/presentation/callcc-interpreter.check b/test/files/presentation/callcc-interpreter.check index 68ac904b18..3a08e2a2ea 100644 --- a/test/files/presentation/callcc-interpreter.check +++ b/test/files/presentation/callcc-interpreter.check @@ -58,12 +58,12 @@ retrieved 64 members [accessible: true] `type AnswercallccInterpreter.Answer` [accessible: true] `type EnvironmentcallccInterpreter.Environment` [accessible: true] `type NamecallccInterpreter.Name` +[accessible: true] `value __leftOfArrowcallccInterpreter.type` +[accessible: true] `value __resultOfEnsuringcallccInterpreter.type` +[accessible: true] `value selfAny` [accessible: true] `value term0callccInterpreter.App` [accessible: true] `value term1callccInterpreter.App` [accessible: true] `value term2callccInterpreter.Add` -[accessible: false] `value __leftOfArrowcallccInterpreter.type` -[accessible: false] `value __resultOfEnsuringcallccInterpreter.type` -[accessible: false] `value selfAny` ================================================================================ askType at CallccInterpreter.scala(14,21) diff --git a/test/files/presentation/ide-bug-1000349.check b/test/files/presentation/ide-bug-1000349.check index d643f82a25..44a3207d75 100644 --- a/test/files/presentation/ide-bug-1000349.check +++ b/test/files/presentation/ide-bug-1000349.check @@ -34,7 +34,7 @@ retrieved 37 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Foo` [accessible: true] `method →[B](y: B)(Foo, B)` -[accessible: false] `value __leftOfArrowFoo` -[accessible: false] `value __resultOfEnsuringFoo` -[accessible: false] `value selfAny` +[accessible: true] `value __leftOfArrowFoo` +[accessible: true] `value __resultOfEnsuringFoo` +[accessible: true] `value selfAny` ================================================================================ diff --git a/test/files/presentation/ide-bug-1000475.check b/test/files/presentation/ide-bug-1000475.check index 2410ebf71d..34c3b557d8 100644 --- a/test/files/presentation/ide-bug-1000475.check +++ b/test/files/presentation/ide-bug-1000475.check @@ -31,11 +31,11 @@ retrieved 36 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Object` [accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowObject` -[accessible: false] `value __resultOfEnsuringObject` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Foo.scala(6,10) @@ -69,11 +69,11 @@ retrieved 36 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Object` [accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowObject` -[accessible: false] `value __resultOfEnsuringObject` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Foo.scala(7,7) @@ -107,9 +107,9 @@ retrieved 36 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Object` [accessible: true] `method →[B](y: B)(Object, B)` +[accessible: true] `value __leftOfArrowObject` +[accessible: true] `value __resultOfEnsuringObject` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowObject` -[accessible: false] `value __resultOfEnsuringObject` -[accessible: false] `value selfAny` ================================================================================ diff --git a/test/files/presentation/ide-bug-1000531.check b/test/files/presentation/ide-bug-1000531.check index 2ae0158a13..dcbd440801 100644 --- a/test/files/presentation/ide-bug-1000531.check +++ b/test/files/presentation/ide-bug-1000531.check @@ -118,10 +118,10 @@ retrieved 124 members [accessible: true] `method zipWithIndex=> Iterator[(B, Int)]` [accessible: true] `method zip[B](that: Iterator[B])Iterator[(B, B)]` [accessible: true] `method →[B](y: B)(java.util.Iterator[B], B)` +[accessible: true] `value __leftOfArrowjava.util.Iterator[B]` +[accessible: true] `value __resultOfEnsuringjava.util.Iterator[B]` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method reversed=> List[B]` -[accessible: false] `value __leftOfArrowjava.util.Iterator[B]` -[accessible: false] `value __resultOfEnsuringjava.util.Iterator[B]` -[accessible: false] `value selfAny` ================================================================================ diff --git a/test/files/presentation/implicit-member.check b/test/files/presentation/implicit-member.check index ce21293ae5..05d6f61699 100644 --- a/test/files/presentation/implicit-member.check +++ b/test/files/presentation/implicit-member.check @@ -35,8 +35,8 @@ retrieved 39 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Implicit.type` [accessible: true] `method →[B](y: B)(Implicit.type, B)` -[accessible: false] `value __leftOfArrowImplicit.type` -[accessible: false] `value __resultOfEnsuringImplicit.type` -[accessible: false] `value selfAny` -[accessible: false] `value xImplicit.type` +[accessible: true] `value __leftOfArrowImplicit.type` +[accessible: true] `value __resultOfEnsuringImplicit.type` +[accessible: true] `value selfAny` +[accessible: true] `value xImplicit.type` ================================================================================ diff --git a/test/files/presentation/ping-pong.check b/test/files/presentation/ping-pong.check index 1f02274736..b666d51de5 100644 --- a/test/files/presentation/ping-pong.check +++ b/test/files/presentation/ping-pong.check @@ -32,13 +32,13 @@ retrieved 40 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Pong` [accessible: true] `method →[B](y: B)(Pong, B)` +[accessible: true] `value __leftOfArrowPong` +[accessible: true] `value __resultOfEnsuringPong` +[accessible: true] `value nameString` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowPong` -[accessible: false] `value __resultOfEnsuringPong` -[accessible: false] `value nameString` [accessible: false] `value pingPing` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at PingPong.scala(19,20) @@ -75,12 +75,12 @@ retrieved 40 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> Ping` [accessible: true] `method →[B](y: B)(Ping, B)` +[accessible: true] `value __leftOfArrowPing` +[accessible: true] `value __resultOfEnsuringPing` +[accessible: true] `value pongPong` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` -[accessible: false] `value __leftOfArrowPing` -[accessible: false] `value __resultOfEnsuringPing` -[accessible: false] `value pongPong` -[accessible: false] `value selfAny` ================================================================================ askType at PingPong.scala(8,10) diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check new file mode 100644 index 0000000000..c6d4762635 --- /dev/null +++ b/test/files/presentation/t5708.check @@ -0,0 +1,47 @@ +reload: Completions.scala + +askTypeCompletion at Completions.scala(17,9) +================================================================================ +[response] aksTypeCompletion at (17,9) +retrieved 44 members +[accessible: true] `lazy value fooInt` +[accessible: true] `method !=(x$1: Any)Boolean` +[accessible: true] `method !=(x$1: AnyRef)Boolean` +[accessible: true] `method ##()Int` +[accessible: true] `method +(other: String)String` +[accessible: true] `method ->[B](y: B)(test.Compat.type, B)` +[accessible: true] `method ==(x$1: Any)Boolean` +[accessible: true] `method ==(x$1: AnyRef)Boolean` +[accessible: true] `method asInstanceOf[T0]=> T0` +[accessible: true] `method ensuring(cond: Boolean)test.Compat.type` +[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type` +[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type` +[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type` +[accessible: true] `method eq(x$1: AnyRef)Boolean` +[accessible: true] `method equals(x$1: Any)Boolean` +[accessible: true] `method formatted(fmtstr: String)String` +[accessible: true] `method hashCode()Int` +[accessible: true] `method isInstanceOf[T0]=> Boolean` +[accessible: true] `method ne(x$1: AnyRef)Boolean` +[accessible: true] `method notify()Unit` +[accessible: true] `method notifyAll()Unit` +[accessible: true] `method pkgPrivateM=> String` +[accessible: true] `method synchronized[T0](x$1: T0)T0` +[accessible: true] `method toString()String` +[accessible: true] `method wait()Unit` +[accessible: true] `method wait(x$1: Long)Unit` +[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` +[accessible: true] `method x=> test.Compat.type` +[accessible: true] `method →[B](y: B)(test.Compat.type, B)` +[accessible: true] `value CONST_STRINGString("constant")` +[accessible: true] `value __leftOfArrowtest.Compat.type` +[accessible: true] `value __resultOfEnsuringtest.Compat.type` +[accessible: true] `value pkgPrivateVString` +[accessible: true] `value selfAny` +[accessible: false] `method clone()Object` +[accessible: false] `method finalize()Unit` +[accessible: false] `method privateM=> String` +[accessible: false] `method protectedValM=> String` +[accessible: false] `value privateVString` +[accessible: false] `value protectedVString` +================================================================================ diff --git a/test/pending/presentation/t5708/Test.scala b/test/files/presentation/t5708/Test.scala index 96e758d974..96e758d974 100644 --- a/test/pending/presentation/t5708/Test.scala +++ b/test/files/presentation/t5708/Test.scala diff --git a/test/files/presentation/t5708/src/Completions.scala b/test/files/presentation/t5708/src/Completions.scala new file mode 100644 index 0000000000..1e9e5d5eb1 --- /dev/null +++ b/test/files/presentation/t5708/src/Completions.scala @@ -0,0 +1,18 @@ +package test + +object Compat { + final val CONST_STRING = "constant" + lazy val foo = 4 + + private val privateV = "" + private[test] val pkgPrivateV = "" + protected val protectedV = "" + + private def privateM = "" + private[test] def pkgPrivateM = "" + protected def protectedValM = "" +} + +class Foo { + Compat./*!*/CONST_STRING // its 'accessible' flag is false +} diff --git a/test/files/presentation/visibility.check b/test/files/presentation/visibility.check index 290a5ac381..3026e58f7e 100644 --- a/test/files/presentation/visibility.check +++ b/test/files/presentation/visibility.check @@ -38,10 +38,10 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.Foo` [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` [accessible: false] `method secretPrivateThis()Unit` -[accessible: false] `value __leftOfArrowaccessibility.Foo` -[accessible: false] `value __resultOfEnsuringaccessibility.Foo` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Completions.scala(16,11) @@ -83,9 +83,9 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.Foo` [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` -[accessible: false] `value __leftOfArrowaccessibility.Foo` -[accessible: false] `value __resultOfEnsuringaccessibility.Foo` -[accessible: false] `value selfAny` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` ================================================================================ askTypeCompletion at Completions.scala(22,11) @@ -126,10 +126,10 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.AccessibilityChecks` [accessible: true] `method →[B](y: B)(accessibility.AccessibilityChecks, B)` +[accessible: true] `value __leftOfArrowaccessibility.AccessibilityChecks` +[accessible: true] `value __resultOfEnsuringaccessibility.AccessibilityChecks` +[accessible: true] `value selfAny` [accessible: false] `method secretPrivate()Unit` -[accessible: false] `value __leftOfArrowaccessibility.AccessibilityChecks` -[accessible: false] `value __resultOfEnsuringaccessibility.AccessibilityChecks` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Completions.scala(28,10) @@ -166,14 +166,14 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.Foo` [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method secretPrivate()Unit` [accessible: false] `method secretPrivateThis()Unit` [accessible: false] `method secretProtected()Unit` -[accessible: false] `value __leftOfArrowaccessibility.Foo` -[accessible: false] `value __resultOfEnsuringaccessibility.Foo` -[accessible: false] `value selfAny` ================================================================================ askTypeCompletion at Completions.scala(37,8) @@ -209,13 +209,13 @@ retrieved 42 members [accessible: true] `method wait(x$1: Long, x$2: Int)Unit` [accessible: true] `method x=> accessibility.Foo` [accessible: true] `method →[B](y: B)(accessibility.Foo, B)` +[accessible: true] `value __leftOfArrowaccessibility.Foo` +[accessible: true] `value __resultOfEnsuringaccessibility.Foo` +[accessible: true] `value selfAny` [accessible: false] `method clone()Object` [accessible: false] `method finalize()Unit` [accessible: false] `method secretPrivate()Unit` [accessible: false] `method secretPrivateThis()Unit` [accessible: false] `method secretProtected()Unit` [accessible: false] `method secretProtectedInPackage()Unit` -[accessible: false] `value __leftOfArrowaccessibility.Foo` -[accessible: false] `value __resultOfEnsuringaccessibility.Foo` -[accessible: false] `value selfAny` ================================================================================ diff --git a/test/files/run/backreferences.check b/test/files/run/backreferences.check new file mode 100644 index 0000000000..1d474d5255 --- /dev/null +++ b/test/files/run/backreferences.check @@ -0,0 +1,2 @@ +false +true diff --git a/test/files/run/backreferences.scala b/test/files/run/backreferences.scala new file mode 100644 index 0000000000..335cd6c7de --- /dev/null +++ b/test/files/run/backreferences.scala @@ -0,0 +1,13 @@ +case class Elem[T](x: T, y: T) + +object Test { + def unrolled[T](x: Any, y: Any, z: Any) = (x, y, z) match { + case (el: Elem[_], el.x, el.y) => true + case _ => false + } + + def main(args: Array[String]): Unit = { + println(unrolled(Elem("bippy", 5), "bippy", 6)) + println(unrolled(Elem("bippy", 5), "bippy", 5)) + } +} diff --git a/test/files/run/inline-ex-handlers.check b/test/files/run/inline-ex-handlers.check index dbd778d8b1..a5d7e93334 100644 --- a/test/files/run/inline-ex-handlers.check +++ b/test/files/run/inline-ex-handlers.check @@ -17,11 +17,11 @@ 204a199,200 > 92 STORE_LOCAL(variable boxed1) > 92 LOAD_LOCAL(variable boxed1) -405c401 +395c391 < blocks: [1,2,3,4,5,8,11,13,14,16] --- > blocks: [1,2,3,5,8,11,13,14,16,17] -429c425,434 +419c415,424 < 103 THROW(MyException) --- > ? STORE_LOCAL(value ex5) @@ -34,15 +34,15 @@ > 106 LOAD_LOCAL(value x3) > 106 IS_INSTANCE REF(class MyException) > 106 CZJUMP (BOOL)NE ? 5 : 11 -442,444d446 +432,434d436 < 101 JUMP 4 < < 4: -532c534 +522c524 < blocks: [1,2,3,4,6,7,8,9,10] --- > blocks: [1,2,3,4,6,7,8,9,10,11,12,13] -561c563,568 +551c553,558 < 306 THROW(MyException) --- > ? JUMP 11 @@ -51,7 +51,7 @@ > ? LOAD_LOCAL(variable monitor4) > 305 MONITOR_EXIT > ? JUMP 12 -567c574,580 +557c564,570 < ? THROW(Throwable) --- > ? JUMP 12 @@ -61,7 +61,7 @@ > 304 MONITOR_EXIT > ? STORE_LOCAL(value t) > ? JUMP 13 -573c586,599 +563c576,589 < ? THROW(Throwable) --- > ? STORE_LOCAL(value t) @@ -78,30 +78,30 @@ > 310 CALL_PRIMITIVE(EndConcat) > 310 CALL_METHOD scala.Predef.println (dynamic) > 310 JUMP 2 -597c623 +587c613 < catch (Throwable) in ArrayBuffer(7, 8, 9, 10) starting at: 6 --- > catch (Throwable) in ArrayBuffer(7, 8, 9, 10, 11) starting at: 6 -600c626 +590c616 < catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10) starting at: 3 --- > catch (Throwable) in ArrayBuffer(4, 6, 7, 8, 9, 10, 11, 12) starting at: 3 -632c658 +622c648 < blocks: [1,2,3,4,5,6,7,9,10] --- > blocks: [1,2,3,4,5,6,7,9,10,11,12] -656c682,683 +646c672,673 < 78 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) > ? JUMP 11 -657a685,689 +647a675,679 > 11: > 81 LOAD_LOCAL(value e) > ? STORE_LOCAL(variable exc1) > ? JUMP 12 > -685c717,731 +675c707,721 < 81 THROW(Exception) --- > ? STORE_LOCAL(variable exc1) @@ -119,15 +119,15 @@ > 84 STORE_LOCAL(variable result) > 84 LOAD_LOCAL(variable exc1) > 84 THROW(Throwable) -707c753 +697c743 < catch (<none>) in ArrayBuffer(4, 6, 7, 9) starting at: 3 --- > catch (<none>) in ArrayBuffer(4, 6, 7, 9, 11) starting at: 3 -733c779 +723c769 < blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31] --- > blocks: [1,2,3,4,5,6,9,12,14,17,18,19,22,25,27,28,30,31,32,33,34] -757c803,810 +747c793,800 < 172 THROW(MyException) --- > ? STORE_LOCAL(value ex5) @@ -138,12 +138,12 @@ > 170 STORE_LOCAL(value x3) > 170 SCOPE_ENTER value x3 > 170 JUMP 18 -813c866,867 +803c856,857 < 177 THROW(MyException) --- > ? STORE_LOCAL(value ex5) > ? JUMP 33 -817c871,878 +807c861,868 < 170 THROW(Throwable) --- > ? STORE_LOCAL(value ex5) @@ -154,17 +154,17 @@ > 169 STORE_LOCAL(value x3) > 169 SCOPE_ENTER value x3 > 169 JUMP 5 -850c911,912 +840c901,902 < 182 THROW(MyException) --- > ? STORE_LOCAL(variable exc2) > ? JUMP 34 -854c916,917 +844c906,907 < 169 THROW(Throwable) --- > ? STORE_LOCAL(variable exc2) > ? JUMP 34 -855a919,931 +845a909,921 > 34: > 184 LOAD_MODULE object Predef > 184 CONSTANT("finally") @@ -178,19 +178,19 @@ > 185 LOAD_LOCAL(variable exc2) > 185 THROW(Throwable) > -876c952 +866c942 < catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30) starting at: 4 --- > catch (Throwable) in ArrayBuffer(17, 18, 19, 22, 25, 27, 28, 30, 32) starting at: 4 -879c955 +869c945 < catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30) starting at: 3 --- > catch (<none>) in ArrayBuffer(4, 5, 6, 9, 12, 17, 18, 19, 22, 25, 27, 28, 30, 32, 33) starting at: 3 -905c981 +895c971 < blocks: [1,2,3,6,7,8,11,14,16,17,19] --- > blocks: [1,2,3,6,7,8,11,14,16,17,19,20] -929c1005,1012 +919c995,1002 < 124 THROW(MyException) --- > ? STORE_LOCAL(value ex5) @@ -201,15 +201,15 @@ > 122 STORE_LOCAL(value x3) > 122 SCOPE_ENTER value x3 > 122 JUMP 7 -989c1072 +979c1062 < catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19) starting at: 3 --- > catch (IllegalArgumentException) in ArrayBuffer(6, 7, 8, 11, 14, 16, 17, 19, 20) starting at: 3 -1015c1098 +1005c1088 < blocks: [1,2,3,4,5,8,11,15,16,17,19] --- > blocks: [1,2,3,5,8,11,15,16,17,19,20] -1039c1122,1131 +1029c1112,1121 < 148 THROW(MyException) --- > ? STORE_LOCAL(value ex5) @@ -222,15 +222,15 @@ > 154 LOAD_LOCAL(value x3) > 154 IS_INSTANCE REF(class MyException) > 154 CZJUMP (BOOL)NE ? 5 : 11 -1060,1062d1151 +1050,1052d1141 < 145 JUMP 4 < < 4: -1295c1384 +1285c1374 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1319c1408,1415 +1309c1398,1405 < 38 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) @@ -241,16 +241,16 @@ > 42 CONSTANT("IllegalArgumentException") > 42 CALL_METHOD scala.Predef.println (dynamic) > 42 JUMP 2 -1368c1464 +1358c1454 < blocks: [1,2,3,4,5,8,11,13,14,16,17,19] --- > blocks: [1,2,3,5,8,11,13,14,16,17,19,20] -1392c1488,1489 +1382c1478,1479 < 203 THROW(MyException) --- > ? STORE_LOCAL(value ex5) > ? JUMP 20 -1412c1509,1518 +1402c1499,1508 < 209 THROW(MyException) --- > ? STORE_LOCAL(value ex5) @@ -263,15 +263,15 @@ > 212 LOAD_LOCAL(value x3) > 212 IS_INSTANCE REF(class MyException) > 212 CZJUMP (BOOL)NE ? 5 : 11 -1425,1427d1530 +1415,1417d1520 < 200 JUMP 4 < < 4: -1487c1590 +1477c1580 < blocks: [1,2,3,4,5,7] --- > blocks: [1,2,3,4,5,7,8] -1511c1614,1621 +1501c1604,1611 < 58 THROW(IllegalArgumentException) --- > ? STORE_LOCAL(value e) @@ -282,11 +282,11 @@ > 62 CONSTANT("RuntimeException") > 62 CALL_METHOD scala.Predef.println (dynamic) > 62 JUMP 2 -1560c1670 +1550c1660 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1580c1690,1695 +1570c1680,1685 < 229 THROW(MyException) --- > ? JUMP 5 @@ -295,19 +295,19 @@ > ? LOAD_LOCAL(variable monitor1) > 228 MONITOR_EXIT > 228 THROW(Throwable) -1586c1701 +1576c1691 < ? THROW(Throwable) --- > 228 THROW(Throwable) -1614c1729 +1604c1719 < locals: value args, variable result, variable monitor2, variable monitorResult1 --- > locals: value exception$1, value args, variable result, variable monitor2, variable monitorResult1 -1616c1731 +1606c1721 < blocks: [1,2,3,4] --- > blocks: [1,2,3,4,5] -1639c1754,1762 +1629c1744,1752 < 245 THROW(MyException) --- > ? STORE_LOCAL(value exception$1) @@ -319,7 +319,7 @@ > ? LOAD_LOCAL(variable monitor2) > 244 MONITOR_EXIT > 244 THROW(Throwable) -1645c1768 +1635c1758 < ? THROW(Throwable) --- > 244 THROW(Throwable) diff --git a/test/files/run/t3702.check b/test/files/run/t3702.check new file mode 100644 index 0000000000..31c2ac4ed1 --- /dev/null +++ b/test/files/run/t3702.check @@ -0,0 +1,2 @@ +() +6 diff --git a/test/files/run/t3702.scala b/test/files/run/t3702.scala new file mode 100644 index 0000000000..021abcb625 --- /dev/null +++ b/test/files/run/t3702.scala @@ -0,0 +1,11 @@ +object Test { + def foo(h: Any, t: List[Any]) = h match { + case 5 :: _ => () + case List(from) => from + } + + def main(args: Array[String]): Unit = { + println(foo(5 :: Nil, List(1,2,3))) + println(foo(6 :: Nil, List(1,2,3))) + } +} diff --git a/test/files/run/t4124.check b/test/files/run/t4124.check new file mode 100644 index 0000000000..66a0092d93 --- /dev/null +++ b/test/files/run/t4124.check @@ -0,0 +1,4 @@ +hi +hi +bye +bye diff --git a/test/files/run/t4124.scala b/test/files/run/t4124.scala new file mode 100644 index 0000000000..9f35b57ce3 --- /dev/null +++ b/test/files/run/t4124.scala @@ -0,0 +1,24 @@ +import xml.Node + +object Test extends App { + val body: Node = <elem>hi</elem> + println ((body: AnyRef, "foo") match { + case (node: Node, "bar") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body, "foo") match { + case (node: Node, "bar") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body: AnyRef, "foo") match { + case (node: Node, "foo") => "bye" + case (ser: Serializable, "foo") => "hi" + }) + + println ((body: AnyRef, "foo") match { + case (node: Node, "foo") => "bye" + case (ser: Serializable, "foo") => "hi" + }) +} diff --git a/test/files/run/t4482.check b/test/files/run/t4482.check new file mode 100644 index 0000000000..0cfbf08886 --- /dev/null +++ b/test/files/run/t4482.check @@ -0,0 +1 @@ +2 diff --git a/test/files/run/t4482.scala b/test/files/run/t4482.scala new file mode 100644 index 0000000000..392861c22e --- /dev/null +++ b/test/files/run/t4482.scala @@ -0,0 +1,15 @@ +trait Foo { def i: Int } +trait Bar + +case class Spam(i: Int) extends Foo with Bar + +object Test { + def matchParent(p:Any) = p match { + case f:Foo if f.i == 1 => 1 + case _:Bar => 2 + case _:Foo => 3 + } + def main(args: Array[String]): Unit = { + println(matchParent(Spam(3))) + } +} diff --git a/test/pending/neg/t796.scala b/test/pending/neg/t796.scala deleted file mode 100644 index c013f49686..0000000000 --- a/test/pending/neg/t796.scala +++ /dev/null @@ -1,20 +0,0 @@ -case class CaseClass( value: Int ); - -object PatternMatchBug { - def matcher( a: AnyRef, b: Any ) { - (a, b) match { - case ( instance: CaseClass, instance.value ) => - System.out.println( "Match succeeded!" ); - case _ => - System.out.println( "Match failed!" ); - } - } - - def main( args : Array[String] ) { - val caseClassInstance = CaseClass( 42 ) - - matcher( caseClassInstance, 13 ) - matcher( caseClassInstance, 42 ) - } -} - diff --git a/test/pending/pos/t1832.scala b/test/pending/pos/t1832.scala new file mode 100644 index 0000000000..bca863f4bd --- /dev/null +++ b/test/pending/pos/t1832.scala @@ -0,0 +1,10 @@ +// Edit by paulp: reduced. +trait Cloning { + trait Foo + def fn(g: Int => Unit): Foo + + implicit def mkStar(i: Int) = new { def *(a: Foo): Foo = null } + + val pool1 = 4 * fn { case i => i * 2 } + val pool2 = 4 * fn { case i: Int => i * 2 } +} diff --git a/test/pending/pos/t3439.scala b/test/pending/pos/t3439.scala new file mode 100644 index 0000000000..425f1aeeb5 --- /dev/null +++ b/test/pending/pos/t3439.scala @@ -0,0 +1,2 @@ +abstract class ParametricMessage[M: Manifest](msg: M) { def message = msg } +case class ParametricMessage1[M: Manifest](msg: M, p1: Class[_]) extends ParametricMessage(msg) diff --git a/test/pending/pos/t4717.scala b/test/pending/pos/t4717.scala index 43cf412bc6..7eaa3dd487 100644 --- a/test/pending/pos/t4717.scala +++ b/test/pending/pos/t4717.scala @@ -1,7 +1,7 @@ -trait Bug1[@specialized +A] extends TraversableOnce[A] { - def ++[B >: A](that: TraversableOnce[B]): Iterator[B] = new Iterator[B] { - lazy val it = that.toIterator - def hasNext = it.hasNext - def next = it.next +trait Bounds[@specialized A] { + // okay without `>: A` + def x[B >: A]: Unit = new Bounds[B] { + lazy val it = ??? // def or val okay + it } }
\ No newline at end of file diff --git a/test/pending/pos/t5091.scala b/test/pending/pos/t5091.scala new file mode 100644 index 0000000000..217e83f66d --- /dev/null +++ b/test/pending/pos/t5091.scala @@ -0,0 +1,11 @@ +object RecursiveValueNeedsType { + + def foo(param: String) = 42 + def bar(n: Int) = 42 + + { + val xxx = foo(param = null) + val param = bar(xxx) + } + +} diff --git a/test/pending/pos/t5231.scala b/test/pending/pos/t5231.scala new file mode 100644 index 0000000000..77e6631ebb --- /dev/null +++ b/test/pending/pos/t5231.scala @@ -0,0 +1,18 @@ +object Client { + sealed trait ConfigLike { + def clientID: Int + } + + object Config { + def apply() : ConfigBuilder = new ConfigBuilder() + implicit def build( cb: ConfigBuilder ) : Config = cb.build + } + + final class Config private[Client]( val clientID: Int ) + extends ConfigLike + + final class ConfigBuilder private () extends ConfigLike { + var clientID: Int = 0 + def build : Config = new Config( clientID ) + } +} diff --git a/test/pending/pos/t5265.scala b/test/pending/pos/t5265.scala new file mode 100644 index 0000000000..3be7d2187e --- /dev/null +++ b/test/pending/pos/t5265.scala @@ -0,0 +1,21 @@ +import java.util.Date + +trait TDate + +trait TT[A1,T1] + +trait TTFactory[F,G] { + def create(f: F) : TT[F,G] + def sample: F +} + +object Impls { + + // If the c1 is declared before c2, it compiles fine + implicit def c2(s: Date) = c1.create(s) + + implicit val c1 = new TTFactory[Date,TDate] { + def create(v: Date): TT[Date,TDate] = sys.error("") + def sample = new Date + } +}
\ No newline at end of file diff --git a/test/pending/pos/unapplyGeneric.scala b/test/pending/pos/unapplyGeneric.scala deleted file mode 100644 index bf88816885..0000000000 --- a/test/pending/pos/unapplyGeneric.scala +++ /dev/null @@ -1,11 +0,0 @@ -object Bar { - def unapply[A,B](bar:Bar[A,B]) = Some(bar) -} - -class Bar[A,B](val _1:A, val _2:B) extends Product2[A,B] - -object Test { - new Bar(2, 'a') match { - case Bar(x,y) => - } -} diff --git a/test/pending/presentation/t5708.check b/test/pending/presentation/t5708.check deleted file mode 100644 index 9d944d6cfc..0000000000 --- a/test/pending/presentation/t5708.check +++ /dev/null @@ -1,81 +0,0 @@ -reload: Completions.scala - -askTypeCompletion at Completions.scala(9,9) -================================================================================ -[response] aksTypeCompletion at (9,9) -retrieved 38 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(test.Compat.type, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> test.Compat.type` -[accessible: true] `method →[B](y: B)(test.Compat.type, B)` -[accessible: true] `lazy value fooInt` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: true] `value CONST_STRINGString("constant")` -[accessible: false] `value __leftOfArrowtest.Compat.type` -[accessible: false] `value __resultOfEnsuringtest.Compat.type` -[accessible: false] `value selfAny` -================================================================================ - -askTypeCompletion at Completions.scala(10,9) -================================================================================ -[response] aksTypeCompletion at (10,9) -retrieved 38 members -[accessible: true] `method !=(x$1: Any)Boolean` -[accessible: true] `method !=(x$1: AnyRef)Boolean` -[accessible: true] `method ##()Int` -[accessible: true] `method +(other: String)String` -[accessible: true] `method ->[B](y: B)(test.Compat.type, B)` -[accessible: true] `method ==(x$1: Any)Boolean` -[accessible: true] `method ==(x$1: AnyRef)Boolean` -[accessible: true] `method asInstanceOf[T0]=> T0` -[accessible: true] `method ensuring(cond: Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean)test.Compat.type` -[accessible: true] `method ensuring(cond: test.Compat.type => Boolean, msg: => Any)test.Compat.type` -[accessible: true] `method eq(x$1: AnyRef)Boolean` -[accessible: true] `method equals(x$1: Any)Boolean` -[accessible: true] `method formatted(fmtstr: String)String` -[accessible: true] `method hashCode()Int` -[accessible: true] `method isInstanceOf[T0]=> Boolean` -[accessible: true] `method ne(x$1: AnyRef)Boolean` -[accessible: true] `method notify()Unit` -[accessible: true] `method notifyAll()Unit` -[accessible: true] `method synchronized[T0](x$1: T0)T0` -[accessible: true] `method toString()String` -[accessible: true] `method wait()Unit` -[accessible: true] `method wait(x$1: Long)Unit` -[accessible: true] `method wait(x$1: Long, x$2: Int)Unit` -[accessible: true] `method x=> test.Compat.type` -[accessible: true] `method →[B](y: B)(test.Compat.type, B)` -[accessible: true] `lazy value fooInt` -[accessible: false] `method clone()Object` -[accessible: false] `method finalize()Unit` -[accessible: true] `value CONST_STRINGString("constant")` -[accessible: false] `value __leftOfArrowtest.Compat.type` -[accessible: false] `value __resultOfEnsuringtest.Compat.type` -[accessible: false] `value selfAny` -================================================================================ diff --git a/test/pending/presentation/t5708/src/Completions.scala b/test/pending/presentation/t5708/src/Completions.scala deleted file mode 100644 index cc41492df7..0000000000 --- a/test/pending/presentation/t5708/src/Completions.scala +++ /dev/null @@ -1,11 +0,0 @@ -package test - -object Compat { - final val CONST_STRING = "constant" - lazy val foo = 4 -} - -class Foo { - Compat./*!*/CONST_STRING // its 'accessible' flag is false - Compat./*!*/foo // its 'accessible' flag is false -} diff --git a/test/pending/run/t3702.scala b/test/pending/run/t3702.scala deleted file mode 100644 index e08fc12e76..0000000000 --- a/test/pending/run/t3702.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test { - def main(args: Array[String]) { - foo(Nil, Nil) - } - - def foo(h: Any, t: List[Any]) = h match { - case 5 :: _ => () - case List(from) => List(from, from, from) - } -} diff --git a/test/pending/run/t5629.scala b/test/pending/run/t5629.scala deleted file mode 100644 index 28e74a1c94..0000000000 --- a/test/pending/run/t5629.scala +++ /dev/null @@ -1,25 +0,0 @@ -import scala.{specialized => spec} - -trait GrandParent[@spec(Int) -A] { - def foo(a:A): Unit - def bar[B <: A](b:B): Unit = println("grandparent got: %s" format b) -} - -trait Parent[@spec(Int) -A] extends GrandParent[A] { - def foo(a:A) = bar(a) -} - -class IntChild extends Parent[Int] { - override def bar[B <: Int](b:B): Unit = println("int child got: %s" format b) -} - -class AnyChild extends Parent[Any] { - override def bar[B <: Any](b:B): Unit = println("any child got: %s" format b) -} - -object Test { - def main(args:Array[String]) { - new IntChild().foo(33) - new AnyChild().foo(33) - } -} |