diff options
40 files changed, 237 insertions, 50 deletions
diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf index 2ece671638..3b61a02bce 100644 --- a/bincompat-forward.whitelist.conf +++ b/bincompat-forward.whitelist.conf @@ -1431,6 +1431,10 @@ filter { { matchName="scala.reflect.internal.Trees#Modifiers.isDeferredNotDefault" problemName=MissingMethodProblem + }, + { + matchName="scala.reflect.internal.Symbols#Symbol.rawInfoIsNoType" + problemName=MissingMethodProblem } ] } diff --git a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala index af82957a2e..8d12581c9c 100644 --- a/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala +++ b/src/compiler/scala/tools/nsc/interactive/CompilerControl.scala @@ -202,15 +202,20 @@ trait CompilerControl { self: Global => postWorkItem(new AskToDoFirstItem(source)) /** If source is not yet loaded, loads it, and starts a new run, otherwise - * continues with current pass. - * Waits until source is fully type checked and returns body in response. - * @param source The source file that needs to be fully typed. - * @param response The response, which is set to the fully attributed tree of `source`. + * continues with current pass. + * Waits until source is fully type checked and returns body in response. + * @param source The source file that needs to be fully typed. + * @param keepLoaded Whether to keep that file in the PC if it was not loaded before. If + the file is already loaded, this flag is ignored. + * @param response The response, which is set to the fully attributed tree of `source`. * If the unit corresponding to `source` has been removed in the meantime * the a NoSuchUnitError is raised in the response. */ - def askLoadedTyped(source: SourceFile, response: Response[Tree]) = - postWorkItem(new AskLoadedTypedItem(source, response)) + def askLoadedTyped(source:SourceFile, keepLoaded: Boolean, response: Response[Tree]): Unit = + postWorkItem(new AskLoadedTypedItem(source, keepLoaded, response)) + + final def askLoadedTyped(source: SourceFile, response: Response[Tree]): Unit = + askLoadedTyped(source, false, response) /** If source if not yet loaded, get an outline view with askParseEntered. * If source is loaded, wait for it to be typechecked. @@ -219,7 +224,7 @@ trait CompilerControl { self: Global => */ def askStructure(keepSrcLoaded: Boolean)(source: SourceFile, response: Response[Tree]) = { getUnit(source) match { - case Some(_) => askLoadedTyped(source, response) + case Some(_) => askLoadedTyped(source, keepSrcLoaded, response) case None => askParsedEntered(source, keepSrcLoaded, response) } } @@ -403,8 +408,8 @@ trait CompilerControl { self: Global => response raise new MissingResponse } - case class AskLoadedTypedItem(val source: SourceFile, response: Response[Tree]) extends WorkItem { - def apply() = self.waitLoadedTyped(source, response, this.onCompilerThread) + case class AskLoadedTypedItem(val source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) extends WorkItem { + def apply() = self.waitLoadedTyped(source, response, keepLoaded, this.onCompilerThread) override def toString = "wait loaded & typed "+source def raiseMissing() = diff --git a/src/compiler/scala/tools/nsc/interactive/Global.scala b/src/compiler/scala/tools/nsc/interactive/Global.scala index a8d6f8977c..d6fa42b1cc 100644 --- a/src/compiler/scala/tools/nsc/interactive/Global.scala +++ b/src/compiler/scala/tools/nsc/interactive/Global.scala @@ -1076,7 +1076,7 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") } /** Implements CompilerControl.askLoadedTyped */ - private[interactive] def waitLoadedTyped(source: SourceFile, response: Response[Tree], onSameThread: Boolean = true) { + private[interactive] def waitLoadedTyped(source: SourceFile, response: Response[Tree], keepLoaded: Boolean = false, onSameThread: Boolean = true) { getUnit(source) match { case Some(unit) => if (unit.isUpToDate) { @@ -1094,7 +1094,10 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "") case None => debugLog("load unit and type") try reloadSources(List(source)) - finally waitLoadedTyped(source, response, onSameThread) + finally { + waitLoadedTyped(source, response, onSameThread) + if (!keepLoaded) removeUnitOf(source) + } } } diff --git a/src/compiler/scala/tools/nsc/interactive/Picklers.scala b/src/compiler/scala/tools/nsc/interactive/Picklers.scala index 2b389158c3..64e050e799 100644 --- a/src/compiler/scala/tools/nsc/interactive/Picklers.scala +++ b/src/compiler/scala/tools/nsc/interactive/Picklers.scala @@ -172,7 +172,7 @@ trait Picklers { self: Global => implicit def askLoadedTypedItem: CondPickler[AskLoadedTypedItem] = pkl[SourceFile] - .wrapped { source => new AskLoadedTypedItem(source, new Response) } { _.source } + .wrapped { source => new AskLoadedTypedItem(source, false, new Response) } { _.source } .asClass (classOf[AskLoadedTypedItem]) implicit def askParsedEnteredItem: CondPickler[AskParsedEnteredItem] = diff --git a/src/compiler/scala/tools/nsc/interactive/REPL.scala b/src/compiler/scala/tools/nsc/interactive/REPL.scala index 7b89d5b0aa..4b64313e1b 100644 --- a/src/compiler/scala/tools/nsc/interactive/REPL.scala +++ b/src/compiler/scala/tools/nsc/interactive/REPL.scala @@ -170,7 +170,7 @@ object REPL { comp.askReload(List(toSourceFile(file)), reloadResult) Thread.sleep(millis.toInt) println("ask type now") - comp.askLoadedTyped(toSourceFile(file), typedResult) + comp.askLoadedTyped(toSourceFile(file), keepLoaded = true, typedResult) typedResult.get case List("typeat", file, off1, off2) => doTypeAt(makePos(file, off1, off2)) diff --git a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala index 4f9df6808f..d5da52bc13 100644 --- a/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala +++ b/src/compiler/scala/tools/nsc/interactive/tests/core/AskCommand.scala @@ -113,9 +113,9 @@ trait AskTypeAt extends AskCommand { trait AskLoadedTyped extends AskCommand { import compiler.Tree - protected def askLoadedTyped(source: SourceFile)(implicit reporter: Reporter): Response[Tree] = { + protected def askLoadedTyped(source: SourceFile, keepLoaded: Boolean = false)(implicit reporter: Reporter): Response[Tree] = { ask { - compiler.askLoadedTyped(source, _) + compiler.askLoadedTyped(source, keepLoaded, _) } } diff --git a/src/compiler/scala/tools/nsc/transform/Erasure.scala b/src/compiler/scala/tools/nsc/transform/Erasure.scala index abd3262c56..df220b7381 100644 --- a/src/compiler/scala/tools/nsc/transform/Erasure.scala +++ b/src/compiler/scala/tools/nsc/transform/Erasure.scala @@ -918,11 +918,24 @@ abstract class Erasure extends AddInterfaces } val decls = root.info.decls + + // SI-8010 force infos, otherwise makeNotPrivate in ExplicitOuter info transformer can trigger + // a scope rehash while were iterating and we can see the same entry twice! + // Inspection of SymbolPairs (the basis of OverridingPairs), suggests that it is immune + // from this sort of bug as it copies the symbols into a temporary scope *before* any calls to `.info`, + // ie, no variant of it calls `info` or `tpe` in `SymbolPair#exclude`. + // + // Why not just create a temporary scope here? We need to force the name changes in any case before + // we do these checks, so that we're comparing same-named methods based on the expanded names that actually + // end up in the bytecode. + afterPostErasure(decls.foreach(_.info)) + var e = decls.elems while (e ne null) { if (e.sym.isTerm) { var e1 = decls.lookupNextEntry(e) while (e1 ne null) { + assert(e.sym ne e1.sym, s"Internal error: encountered ${e.sym.debugLocationString} twice during scope traversal. This might be related to SI-8010.") if (sameTypeAfterErasure(e1.sym, e.sym)) doubleDefError(e.sym, e1.sym) e1 = decls.lookupNextEntry(e1) } diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index 5d6d094b44..a7b0e47214 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -1294,7 +1294,7 @@ trait ContextErrors { private def compatibilityError(message: String) = implRefError( - "macro implementation has wrong shape:"+ + "macro implementation has incompatible shape:"+ "\n required: " + showMeth(rparamss, rret, abbreviate = true) + "\n found : " + showMeth(aparamss, aret, abbreviate = false) + "\n" + message) @@ -1328,7 +1328,11 @@ trait ContextErrors { def MacroImplOverloadedError() = implRefError("macro implementation cannot be overloaded") - def MacroImplWrongNumberOfTypeArgumentsError(macroImplRef: Tree) = implRefError(typer.TyperErrorGen.TypedApplyWrongNumberOfTpeParametersErrorMessage(macroImplRef)) + def MacroImplWrongNumberOfTypeArgumentsError(macroImplRef: Tree) = { + val MacroImplReference(owner, meth, targs) = macroImplRef + val diagnostic = if (meth.typeParams.length > targs.length) "has too few type arguments" else "has too many arguments" + implRefError(s"macro implementation reference $diagnostic for " + treeSymTypeMsg(macroImplRef)) + } def MacroImplNotStaticError() = implRefError("macro implementation must be in statically accessible object") @@ -1336,7 +1340,7 @@ trait ContextErrors { // aXXX (e.g. aparams) => characteristics of the macro impl ("a" stands for "actual") // rXXX (e.g. rparams) => characteristics of a reference macro impl signature synthesized from the macro def ("r" stands for "reference") - def MacroImplNonTagImplicitParameters(params: List[Symbol]) = compatibilityError("macro implementations cannot have implicit parameters other than WeakTypeTag evidences") + def MacroImplNonTagImplicitParameters(params: List[Symbol]) = implRefError("macro implementations cannot have implicit parameters other than WeakTypeTag evidences") def MacroImplParamssMismatchError() = compatibilityError("number of parameter sections differ") diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 39946e4472..b2c09ec53e 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -384,7 +384,10 @@ trait Future[+T] extends Awaitable[T] { val p = Promise[U]() onComplete { case s @ Success(_) => p complete s - case _ => p completeWith that + case f @ Failure(_) => that onComplete { + case s2 @ Success(_) => p complete s2 + case _ => p complete f // Use the first failure as the failure + } } p.future } diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 45c16b7302..579f7684fd 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -709,7 +709,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => final def isMonomorphicType = isType && { val info = originalInfo - info.isComplete && !info.isHigherKinded + ( (info eq null) + || (info.isComplete && !info.isHigherKinded) + ) } def isStrictFP = hasAnnotation(ScalaStrictFPAttr) || (enclClass hasAnnotation ScalaStrictFPAttr) @@ -1282,6 +1284,13 @@ trait Symbols extends api.Symbols { self: SymbolTable => def hasRawInfo: Boolean = infos ne null def hasCompleteInfo = hasRawInfo && rawInfo.isComplete + // does not run adaptToNewRun, which is prone to trigger cycles (SI-8029) + // TODO: give this a better name if you understand the intent of the caller. + // Is it something to do with `reallyExists` or `isStale`? + final def rawInfoIsNoType: Boolean = { + hasRawInfo && (infos.info eq NoType) + } + /** Return info without checking for initialization or completing */ def rawInfo: Type = { var infos = this.infos @@ -1928,7 +1937,7 @@ trait Symbols extends api.Symbols { self: SymbolTable => /** Is this symbol defined in the same scope and compilation unit as `that` symbol? */ def isCoDefinedWith(that: Symbol) = ( - (this.rawInfo ne NoType) + !rawInfoIsNoType && (this.effectiveOwner == that.effectiveOwner) && ( !this.effectiveOwner.isPackageClass || (this.sourceFile eq null) diff --git a/src/swing/scala/swing/Publisher.scala b/src/swing/scala/swing/Publisher.scala index 96207de808..578ef71e09 100644 --- a/src/swing/scala/swing/Publisher.scala +++ b/src/swing/scala/swing/Publisher.scala @@ -44,7 +44,7 @@ trait Publisher extends Reactor { /** * Notify all registered reactions. */ - def publish(e: Event) { for (l <- listeners) l(e) } + def publish(e: Event) { for (l <- listeners) if (l.isDefinedAt(e)) l(e) } listenTo(this) } diff --git a/test/files/jvm/future-spec/PromiseTests.scala b/test/files/jvm/future-spec/PromiseTests.scala index 8e07393900..48f94666ba 100644 --- a/test/files/jvm/future-spec/PromiseTests.scala +++ b/test/files/jvm/future-spec/PromiseTests.scala @@ -38,10 +38,10 @@ object PromiseTests extends MinimalScalaTest { Await.result(failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") Await.result(timedOut fallbackTo empty, defaultTimeout) mustBe ("Timedout") - Await.result(failure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") + Await.result(otherFailure fallbackTo failure fallbackTo timedOut, defaultTimeout) mustBe ("Timedout") intercept[RuntimeException] { Await.result(failure fallbackTo otherFailure, defaultTimeout) - }.getMessage mustBe ("last") + }.getMessage mustBe ("br0ken") } } diff --git a/test/files/jvm/scala-concurrent-tck.scala b/test/files/jvm/scala-concurrent-tck.scala index 6e2b8ca033..a306a7d15b 100644 --- a/test/files/jvm/scala-concurrent-tck.scala +++ b/test/files/jvm/scala-concurrent-tck.scala @@ -344,8 +344,8 @@ def testTransformFailure(): Unit = once { def testFallbackToFailure(): Unit = once { done => val cause = new Exception - val f = future { sys.error("failed") } - val g = future { throw cause } + val f = future { throw cause } + val g = future { sys.error("failed") } val h = f fallbackTo g h onSuccess { case _ => done(false) } diff --git a/test/files/neg/macro-invalidimpl-f.check b/test/files/neg/macro-invalidimpl-f.check index 4e5851f566..8820e05152 100644 --- a/test/files/neg/macro-invalidimpl-f.check +++ b/test/files/neg/macro-invalidimpl-f.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context)(): c.Expr[Unit] found : (c: scala.reflect.macros.Context): c.Expr[Unit] number of parameter sections differ diff --git a/test/files/neg/macro-invalidimpl-g.check b/test/files/neg/macro-invalidimpl-g.check index 7342f7336f..c063803723 100644 --- a/test/files/neg/macro-invalidimpl-g.check +++ b/test/files/neg/macro-invalidimpl-g.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context): c.Expr[Unit] found : (c: scala.reflect.macros.Context)(): c.Expr[Unit] number of parameter sections differ diff --git a/test/files/neg/macro-invalidret-nontree.check b/test/files/neg/macro-invalidret-nontree.check index 6d8336d06d..74e6f33339 100644 --- a/test/files/neg/macro-invalidret-nontree.check +++ b/test/files/neg/macro-invalidret-nontree.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context): c.Expr[Any] found : (c: scala.reflect.macros.Context): Int type mismatch for return type: Int does not conform to c.Expr[Any] diff --git a/test/files/neg/macro-invalidret-nonuniversetree.check b/test/files/neg/macro-invalidret-nonuniversetree.check index 089bfd0dc9..81c4114ce0 100644 --- a/test/files/neg/macro-invalidret-nonuniversetree.check +++ b/test/files/neg/macro-invalidret-nonuniversetree.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context): c.Expr[Any] found : (c: scala.reflect.macros.Context): reflect.runtime.universe.Literal type mismatch for return type: reflect.runtime.universe.Literal does not conform to c.Expr[Any] diff --git a/test/files/neg/macro-invalidsig-context-bounds.check b/test/files/neg/macro-invalidsig-context-bounds.check index 43b8c23b35..cbb2b06892 100644 --- a/test/files/neg/macro-invalidsig-context-bounds.check +++ b/test/files/neg/macro-invalidsig-context-bounds.check @@ -1,7 +1,4 @@ -Macros_Test_1.scala:2: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context): c.Expr[Any] - found : (c: scala.reflect.macros.Context)(implicit evidence$2: Numeric[U]): c.universe.Literal -macro implementations cannot have implicit parameters other than WeakTypeTag evidences +Macros_Test_1.scala:2: error: macro implementations cannot have implicit parameters other than WeakTypeTag evidences def foo[U] = macro Impls.foo[U] ^ one error found diff --git a/test/files/neg/macro-invalidsig-ctx-badargc.check b/test/files/neg/macro-invalidsig-ctx-badargc.check index 1c14072a94..7e8bcbaf74 100644 --- a/test/files/neg/macro-invalidsig-ctx-badargc.check +++ b/test/files/neg/macro-invalidsig-ctx-badargc.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context): c.Expr[Any] found : : Nothing number of parameter sections differ diff --git a/test/files/neg/macro-invalidsig-ctx-badtype.check b/test/files/neg/macro-invalidsig-ctx-badtype.check index 340ace6a38..837ec3e496 100644 --- a/test/files/neg/macro-invalidsig-ctx-badtype.check +++ b/test/files/neg/macro-invalidsig-ctx-badtype.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context): c.Expr[Any] found : (c: scala.reflect.api.Universe): Nothing type mismatch for parameter c: scala.reflect.macros.Context does not conform to scala.reflect.api.Universe diff --git a/test/files/neg/macro-invalidsig-ctx-badvarargs.check b/test/files/neg/macro-invalidsig-ctx-badvarargs.check index a6478f03e3..a96421a8c4 100644 --- a/test/files/neg/macro-invalidsig-ctx-badvarargs.check +++ b/test/files/neg/macro-invalidsig-ctx-badvarargs.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context): c.Expr[Any] found : (cs: scala.reflect.macros.Context*): Nothing types incompatible for parameter cs: corresponding is not a vararg parameter diff --git a/test/files/neg/macro-invalidsig-ctx-noctx.check b/test/files/neg/macro-invalidsig-ctx-noctx.check index b7dc9a449b..fd3632eb9b 100644 --- a/test/files/neg/macro-invalidsig-ctx-noctx.check +++ b/test/files/neg/macro-invalidsig-ctx-noctx.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context)(x: c.Expr[Any]): c.Expr[Any] found : (c: scala.reflect.macros.Context): Nothing number of parameter sections differ diff --git a/test/files/neg/macro-invalidsig-implicit-params.check b/test/files/neg/macro-invalidsig-implicit-params.check index f210eb8a32..900098fd98 100644 --- a/test/files/neg/macro-invalidsig-implicit-params.check +++ b/test/files/neg/macro-invalidsig-implicit-params.check @@ -1,7 +1,4 @@ -Impls_Macros_1.scala:18: error: macro implementation has wrong shape: - required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Unit] - found : (c: scala.reflect.macros.Context)(implicit x: c.Expr[Int]): c.Expr[Unit] -macro implementations cannot have implicit parameters other than WeakTypeTag evidences +Impls_Macros_1.scala:18: error: macro implementations cannot have implicit parameters other than WeakTypeTag evidences def foo_targs[U](x: Int) = macro Impls.foo_targs[T, U] ^ one error found diff --git a/test/files/neg/macro-invalidsig-params-badargc.check b/test/files/neg/macro-invalidsig-params-badargc.check index 3f6d815b8e..bb26b24f80 100644 --- a/test/files/neg/macro-invalidsig-params-badargc.check +++ b/test/files/neg/macro-invalidsig-params-badargc.check @@ -1,4 +1,4 @@ -Impls_Macros_1.scala:8: error: macro implementation has wrong shape: +Impls_Macros_1.scala:8: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any] found : (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): Nothing parameter lists have different length, found extra parameter y: c.Expr[Int] diff --git a/test/files/neg/macro-invalidsig-params-badtype.check b/test/files/neg/macro-invalidsig-params-badtype.check index 3ec40d7e5b..82276141a4 100644 --- a/test/files/neg/macro-invalidsig-params-badtype.check +++ b/test/files/neg/macro-invalidsig-params-badtype.check @@ -1,4 +1,4 @@ -Impls_Macros_1.scala:8: error: macro implementation has wrong shape: +Impls_Macros_1.scala:8: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context)(x: c.Expr[Int]): c.Expr[Any] found : (c: scala.reflect.macros.Context)(x: c.universe.Tree): Nothing type mismatch for parameter x: c.Expr[Int] does not conform to c.universe.Tree diff --git a/test/files/neg/macro-invalidsig-params-badvarargs.check b/test/files/neg/macro-invalidsig-params-badvarargs.check index 50607ff52d..cb4d2d91b1 100644 --- a/test/files/neg/macro-invalidsig-params-badvarargs.check +++ b/test/files/neg/macro-invalidsig-params-badvarargs.check @@ -1,4 +1,4 @@ -Impls_Macros_1.scala:8: error: macro implementation has wrong shape: +Impls_Macros_1.scala:8: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any] found : (c: scala.reflect.macros.Context)(xs: c.Expr[Int]*): Nothing parameter lists have different length, required extra parameter y: c.Expr[Int] diff --git a/test/files/neg/macro-invalidsig-params-namemismatch.check b/test/files/neg/macro-invalidsig-params-namemismatch.check index 4029bc8129..82612a94d3 100644 --- a/test/files/neg/macro-invalidsig-params-namemismatch.check +++ b/test/files/neg/macro-invalidsig-params-namemismatch.check @@ -1,4 +1,4 @@ -Impls_Macros_1.scala:8: error: macro implementation has wrong shape: +Impls_Macros_1.scala:8: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context)(x: c.Expr[Int], y: c.Expr[Int]): c.Expr[Any] found : (c: scala.reflect.macros.Context)(y: c.Expr[Int], x: c.Expr[Int]): Nothing parameter names differ: x != y diff --git a/test/files/neg/macro-invalidsig-tparams-badtype.check b/test/files/neg/macro-invalidsig-tparams-badtype.check index e9f3547133..273d011412 100644 --- a/test/files/neg/macro-invalidsig-tparams-badtype.check +++ b/test/files/neg/macro-invalidsig-tparams-badtype.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: macro implementation has wrong shape: +Macros_Test_2.scala:2: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context): c.Expr[Any] found : (c: scala.reflect.macros.Context)(U: c.universe.Type): Nothing number of parameter sections differ diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-a.check b/test/files/neg/macro-invalidsig-tparams-notparams-a.check index 61a5628b7e..c73125963f 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-a.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-a.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:2: error: wrong number of type parameters for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[U])Nothing +Macros_Test_2.scala:2: error: macro implementation reference has too few type arguments for method foo: [U](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[U])Nothing def foo = macro Impls.foo ^ one error found diff --git a/test/files/neg/macro-invalidsig-tparams-notparams-b.check b/test/files/neg/macro-invalidsig-tparams-notparams-b.check index a605af6beb..e3d45055de 100644 --- a/test/files/neg/macro-invalidsig-tparams-notparams-b.check +++ b/test/files/neg/macro-invalidsig-tparams-notparams-b.check @@ -1,4 +1,4 @@ -Macros_Test_2.scala:3: error: wrong number of type parameters for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] +Macros_Test_2.scala:3: error: macro implementation reference has too few type arguments for method foo: [T, U, V](c: scala.reflect.macros.Context)(implicit evidence$1: c.WeakTypeTag[T], implicit evidence$2: c.WeakTypeTag[U], implicit V: c.WeakTypeTag[V])c.Expr[Unit] def foo[V] = macro Impls.foo ^ one error found diff --git a/test/files/neg/t5689.check b/test/files/neg/t5689.check index 50aaa7dbfe..e497e3bb07 100644 --- a/test/files/neg/t5689.check +++ b/test/files/neg/t5689.check @@ -1,4 +1,4 @@ -t5689.scala:4: error: macro implementation has wrong shape: +t5689.scala:4: error: macro implementation has incompatible shape: required: (c: scala.reflect.macros.Context)(i: c.Expr[Double]): c.Expr[String] found : (c: scala.reflect.macros.Context)(i: c.Expr[Double]): c.Expr[Int] type mismatch for return type: c.Expr[Int] does not conform to c.Expr[String] diff --git a/test/files/presentation/ide-t1001388.check b/test/files/presentation/ide-t1001388.check new file mode 100644 index 0000000000..d58f86d6c6 --- /dev/null +++ b/test/files/presentation/ide-t1001388.check @@ -0,0 +1 @@ +Test OK
\ No newline at end of file diff --git a/test/files/presentation/ide-t1001388/Test.scala b/test/files/presentation/ide-t1001388/Test.scala new file mode 100644 index 0000000000..f6079cf0b2 --- /dev/null +++ b/test/files/presentation/ide-t1001388/Test.scala @@ -0,0 +1,28 @@ +import scala.tools.nsc.interactive.tests.InteractiveTest +import scala.reflect.internal.util.SourceFile +import scala.tools.nsc.interactive.Response + +object Test extends InteractiveTest { + override def execute(): Unit = { + val sourceA = loadSourceAndWaitUntilTypechecked("A.scala") + checkPresent(sourceA) + } + + private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = { + val sourceFile = sourceFiles.find(_.file.name == sourceName).head + askLoadedTyped(sourceFile).get + /* The response to `askLoadedType` may return before `interactive.Global.waitLoadedType` + * fully executes. Because this test expects `waitLoadedType` is fully executed before + * calling `checkPresent`, with the below no-op presentation compiler request we make + * sure this requirement is fulfilled. + */ + compiler.askForResponse(() => ()).get + sourceFile + } + + private def checkPresent(source: SourceFile): Unit = compiler.getUnitOf(source) match { + case Some(unit) => reporter.println("Compilation Unit for " + source.file.name + " still loaded after askLoadedTyped") + + case None => reporter.println("Test OK") + } +} diff --git a/test/files/presentation/ide-t1001388/src/a/A.scala b/test/files/presentation/ide-t1001388/src/a/A.scala new file mode 100644 index 0000000000..be09097598 --- /dev/null +++ b/test/files/presentation/ide-t1001388/src/a/A.scala @@ -0,0 +1,6 @@ +package a + +object A { + val tagString = "foo" + Seq.empty[Byte].toArray.toSeq +} diff --git a/test/files/run/t7439.check b/test/files/run/t7439.check new file mode 100644 index 0000000000..ce9e8b52ff --- /dev/null +++ b/test/files/run/t7439.check @@ -0,0 +1 @@ +pos: NoPosition Class A_1 not found - continuing with a stub. WARNING diff --git a/test/files/run/t7439/A_1.java b/test/files/run/t7439/A_1.java new file mode 100644 index 0000000000..4accd95d57 --- /dev/null +++ b/test/files/run/t7439/A_1.java @@ -0,0 +1,3 @@ +public class A_1 { + +}
\ No newline at end of file diff --git a/test/files/run/t7439/B_1.java b/test/files/run/t7439/B_1.java new file mode 100644 index 0000000000..5dd3b93d6f --- /dev/null +++ b/test/files/run/t7439/B_1.java @@ -0,0 +1,3 @@ +public class B_1 { + public void b(A_1[] a) {} +} diff --git a/test/files/run/t7439/Test_2.scala b/test/files/run/t7439/Test_2.scala new file mode 100644 index 0000000000..e00e9d1b68 --- /dev/null +++ b/test/files/run/t7439/Test_2.scala @@ -0,0 +1,31 @@ +import scala.tools.partest._ +import java.io.File + +object Test extends StoreReporterDirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def C = """ + class C { + new B_1 + } + """ + + def show(): Unit = { + //compileCode(C) + assert(filteredInfos.isEmpty, filteredInfos) + + // blow away the entire package + val a1Class = new File(testOutput.path, "A_1.class") + assert(a1Class.exists) + assert(a1Class.delete()) + + // bad symbolic reference error expected (but no stack trace!) + compileCode(C) + println(storeReporter.infos.mkString("\n")) // Included a NullPointerException before. + } +} diff --git a/test/files/run/t8010.scala b/test/files/run/t8010.scala new file mode 100644 index 0000000000..8636bbd12e --- /dev/null +++ b/test/files/run/t8010.scala @@ -0,0 +1,22 @@ +trait Base { + def t = 1 + def t(n: Int) = n + def bt = 2 + def bt(n: Int) = n +} +trait Derived extends Base { + // was: double defintion error + override def t = 1 + super.t + override def t(n: Int) = 1 + super.t(n) + override def bt = 1 + super.bt + override def bt(n: Int) = 1 + super.bt(n) +} + +object Test extends App { + val d = new Derived {} + // not the focus of thie bug, but let's just check the runtime behaviour while we're here. + assert(d.t == 2) + assert(d.t(1) == 2) + assert(d.bt == 3) + assert(d.bt(1) == 2) +} diff --git a/test/files/run/t8029.scala b/test/files/run/t8029.scala new file mode 100644 index 0000000000..dbd5c41387 --- /dev/null +++ b/test/files/run/t8029.scala @@ -0,0 +1,57 @@ +import scala.tools.partest._ +import scala.tools.nsc._ + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -nowarn -Ystop-after:typer" + + override def code = "" // not used + + def code1 = """ +package object p1 { + trait A + object A +} + """ + + def code2 = """ +package object p2 { + class A + object A +} + """ + + def code3 = """ +package object p3 { + object A + trait A +} + """ + + def code4 = """ +package object p4 { + object A + trait A +} + """ + + def show() { + val global = newCompiler() + import global._ + def typecheck(code: String): Unit = { + val r = new Run + val sourceFile = newSources(code).head + global.reporter.reset() + r.compileSources(sourceFile :: Nil) + assert(!global.reporter.hasErrors) + } + + def typecheckTwice(code: String): Unit = { + typecheck(code) + typecheck(code) + } + + // was: illegal cyclic reference involving package ... + Seq(code1, code2, code3, code4) foreach typecheckTwice + } +} |