diff options
40 files changed, 219 insertions, 33 deletions
diff --git a/bincompat-backward.whitelist.conf b/bincompat-backward.whitelist.conf index e82c0fd16d..ae31c286f3 100644 --- a/bincompat-backward.whitelist.conf +++ b/bincompat-backward.whitelist.conf @@ -122,6 +122,11 @@ filter { { matchName="scala.reflect.api.Internals#ReificationSupportApi.SyntacticSelectTerm" problemName=MissingMethodProblem + }, + // see SI-8366 + { + matchName="scala.reflect.api.Internals#ReificationSupportApi.SyntacticPartialFunction" + problemName=MissingMethodProblem } ] } diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf index f9bd0441a2..3eba1effc1 100644 --- a/bincompat-forward.whitelist.conf +++ b/bincompat-forward.whitelist.conf @@ -130,6 +130,15 @@ filter { { matchName="scala.reflect.api.Internals$ReificationSupportApi$SyntacticSelectTypeExtractor" problemName=MissingClassProblem - } + }, + // see SI-8366 + { + matchName="scala.reflect.api.Internals$ReificationSupportApi$SyntacticPartialFunctionExtractor" + problemName=MissingClassProblem + }, + { + matchName="scala.reflect.api.Internals#ReificationSupportApi.SyntacticPartialFunction" + problemName=MissingMethodProblem + } ] } diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index 194d92367b..d6dc167dd8 100644 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -156,7 +156,7 @@ while [[ $# -gt 0 ]]; do java_args=("${java_args[@@]}" "$1") scala_args=("${scala_args[@@]}" "$1") # respect user-supplied -Dscala.usejavacp - case "$1" in -Dscala.usejavacp) OVERRIDE_USEJAVACP="" esac + case "$1" in -Dscala.usejavacp) OVERRIDE_USEJAVACP="";; esac shift ;; -J*) diff --git a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl index 8441f3af23..9a2deb4da6 100644 --- a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl @@ -25,6 +25,10 @@ shift :notoolcp +rem SI-8358, SI-8368 -- the default should really be false, +rem but I don't want to flip the default during 2.11's RC cycle +set _OVERRIDE_USEJAVACP="-Dscala.usejavacp=true" + rem We keep in _JAVA_PARAMS all -J-prefixed and -D-prefixed arguments set _JAVA_PARAMS= @@ -45,6 +49,9 @@ if "%_TEST_PARAM:~0,2%"=="-J" ( ) if "%_TEST_PARAM:~0,2%"=="-D" ( + if "%_TEST_PARAM%"=="-Dscala.usejavacp" ( + set _OVERRIDE_USEJAVACP= + ) rem test if this was double-quoted property "-Dprop=42" for /F "delims== tokens=1-2" %%G in ("%_TEST_PARAM%") DO ( if not "%%G" == "%_TEST_PARAM%" ( @@ -126,7 +133,7 @@ if "%_TOOL_CLASSPATH%"=="" ( if not "%_LINE_TOOLCP%"=="" call :add_cpath "%_LINE_TOOLCP%" -set _PROPS=-Dscala.home="!_SCALA_HOME!" -Denv.emacs="%EMACS%" -Dscala.usejavacp=true @properties@ +set _PROPS=-Dscala.home="!_SCALA_HOME!" -Denv.emacs="%EMACS%" %_OVERRIDE_USEJAVACP% @properties@ rem echo "%_JAVACMD%" %_JAVA_OPTS% %_PROPS% -cp "%_TOOL_CLASSPATH%" @class@ @toolflags@ %* "%_JAVACMD%" %_JAVA_OPTS% %_PROPS% -cp "%_TOOL_CLASSPATH%" @class@ @toolflags@ %* diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index c5d0c8506a..35eab94333 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -236,6 +236,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) override def inform(msg: String) = inform(NoPosition, msg) override def globalError(msg: String) = globalError(NoPosition, msg) override def warning(msg: String) = warning(NoPosition, msg) + override def deprecationWarning(pos: Position, msg: String) = currentUnit.deprecationWarning(pos, msg) def globalError(pos: Position, msg: String) = reporter.error(pos, msg) def warning(pos: Position, msg: String) = if (settings.fatalWarnings) globalError(pos, msg) else reporter.warning(pos, msg) @@ -1236,7 +1237,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) } private val unitbuf = new SyncedCompilationBuffer - + val compiledFiles = new mutable.HashSet[String] /** A map from compiled top-level symbols to their source files */ @@ -1491,7 +1492,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter) made to the underlying structure. */ def units: Iterator[CompilationUnit] = unitbuf.iterator - + def registerPickle(sym: Symbol): Unit = () /** does this run compile given class, module, or case factory? */ diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index 8a7d30235f..d77c6b54a9 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -221,7 +221,9 @@ abstract class UnCurry extends InfoTransform def mkMethod(owner: Symbol, name: TermName, additionalFlags: FlagSet = NoFlags): DefDef = gen.mkMethodFromFunction(localTyper)(fun, owner, name, additionalFlags) - if (inlineFunctionExpansion) { + val canUseDelamdafyMethod = (inConstructorFlag == 0) // Avoiding synthesizing code prone to SI-6666, SI-8363 by using old-style lambda translation + + if (inlineFunctionExpansion || !canUseDelamdafyMethod) { val parents = addSerializable(abstractFunctionForFunctionType(fun.tpe)) val anonClass = fun.symbol.owner newAnonymousFunctionClass(fun.pos, inConstructorFlag) addAnnotation SerialVersionUIDAnnotation anonClass setInfo ClassInfoType(parents, newScope, anonClass) diff --git a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala index 699e98f963..4cf8980689 100644 --- a/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala +++ b/src/compiler/scala/tools/nsc/transform/patmat/MatchTranslation.scala @@ -81,14 +81,14 @@ trait MatchTranslation { object SymbolAndTypeBound { def unapply(tree: Tree): Option[(Symbol, Type)] = tree match { - case SymbolBound(sym, SymbolAndTypeBound(_, tpe)) => Some(sym -> tpe) - case TypeBound(tpe) => Some(binder -> tpe) - case _ => None + case SymbolBound(sym, TypeBound(tpe)) => Some(sym -> tpe) + case TypeBound(tpe) => Some(binder -> tpe) + case _ => None } } object TypeBound { - def unapply(tree: Tree): Option[Type] = unbind(tree) match { + def unapply(tree: Tree): Option[Type] = tree match { case Typed(Ident(_), _) if tree.tpe != null => Some(tree.tpe) case _ => None } diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 133e80788b..994a2a4f4f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -433,8 +433,10 @@ trait Contexts { self: Analyzer => case _ => false } val isImport = tree match { - case _: Import => true - case _ => false + // The guard is for SI-8403. It prevents adding imports again in the context created by + // `Namer#createInnerNamer` + case _: Import if tree != this.tree => true + case _ => false } val sameOwner = owner == this.owner val prefixInChild = diff --git a/src/compiler/scala/tools/reflect/FormatInterpolator.scala b/src/compiler/scala/tools/reflect/FormatInterpolator.scala index 0258002850..e0f9bb6044 100644 --- a/src/compiler/scala/tools/reflect/FormatInterpolator.scala +++ b/src/compiler/scala/tools/reflect/FormatInterpolator.scala @@ -93,7 +93,8 @@ abstract class FormatInterpolator { case '\n' => "\\n" case '\f' => "\\f" case '\r' => "\\r" - case '\"' => "\\u0022" // $" in future + case '\"' => "${'\"'}" /* avoid lint warn */ + + " or a triple-quoted literal \"\"\"with embedded \" or \\u0022\"\"\"" // $" in future case '\'' => "'" case '\\' => """\\""" case x => "\\u%04x" format x diff --git a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala index 850030e9ba..1b8b0686e8 100644 --- a/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala +++ b/src/compiler/scala/tools/reflect/quasiquotes/Reifiers.scala @@ -199,6 +199,10 @@ trait Reifiers { self: Quasiquotes => reifyBuildCall(nme.SyntacticEmptyTypeTree) case SyntacticImport(expr, selectors) => reifyBuildCall(nme.SyntacticImport, expr, selectors) + case SyntacticPartialFunction(cases) => + reifyBuildCall(nme.SyntacticPartialFunction, cases) + case SyntacticMatch(scrutinee, cases) => + reifyBuildCall(nme.SyntacticMatch, scrutinee, cases) case Q(tree) if fillListHole.isDefinedAt(tree) => mirrorBuildCall(nme.SyntacticBlock, fillListHole(tree)) case Q(other) => @@ -211,8 +215,6 @@ trait Reifiers { self: Quasiquotes => reifyBuildCall(nme.SyntacticBlock, Nil) case Try(block, catches, finalizer) => reifyBuildCall(nme.SyntacticTry, block, catches, finalizer) - case Match(selector, cases) => - reifyBuildCall(nme.SyntacticMatch, selector, cases) case CaseDef(pat, guard, body) if fillListHole.isDefinedAt(body) => mirrorCall(nme.CaseDef, reify(pat), reify(guard), mirrorBuildCall(nme.SyntacticBlock, fillListHole(body))) // parser emits trees with scala package symbol to ensure diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index 01d179aeb6..0cd91409cf 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -506,7 +506,6 @@ trait GenTraversableOnce[+A] extends Any { def toIndexedSeq: immutable.IndexedSeq[A] /** Converts this $coll to a stream. - * $willNotTerminateInf * @return a stream containing all elements of this $coll. */ def toStream: Stream[A] diff --git a/src/reflect/scala/reflect/api/Internals.scala b/src/reflect/scala/reflect/api/Internals.scala index d2e742726d..9faba7efd7 100644 --- a/src/reflect/scala/reflect/api/Internals.scala +++ b/src/reflect/scala/reflect/api/Internals.scala @@ -762,9 +762,15 @@ trait Internals { self: Universe => def unapply(lst: List[List[Tree]]): Option[List[List[T]]] } + val SyntacticPartialFunction: SyntacticPartialFunctionExtractor + trait SyntacticPartialFunctionExtractor { + def apply(cases: List[Tree]): Match + def unapply(tree: Match): Option[List[CaseDef]] + } + val SyntacticMatch: SyntacticMatchExtractor trait SyntacticMatchExtractor { - def apply(selector: Tree, cases: List[Tree]): Match + def apply(scrutinee: Tree, cases: List[Tree]): Match def unapply(tree: Match): Option[(Tree, List[CaseDef])] } diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index 558e1aa611..25d78f4e6f 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -410,7 +410,8 @@ trait Definitions extends api.StandardDefinitions { else if (isScalaRepeatedParamType(tp)) elementExtract(RepeatedParamClass, tp) orElse tp else tp ) - def repeatedToSingle(tp: Type): Type = elementExtract(RepeatedParamClass, tp) orElse tp + def repeatedToSingle(tp: Type): Type = elementExtract(RepeatedParamClass, tp) orElse elementExtract(JavaRepeatedParamClass, tp) orElse tp + // We don't need to deal with JavaRepeatedParamClass here, as `repeatedToSeq` is only called in the patmat translation for Scala sources. def repeatedToSeq(tp: Type): Type = elementTransform(RepeatedParamClass, tp)(seqType) orElse tp def seqToRepeated(tp: Type): Type = elementTransform(SeqClass, tp)(scalaRepeatedType) orElse tp def isReferenceArray(tp: Type) = elementTest(ArrayClass, tp)(_ <:< AnyRefTpe) @@ -501,7 +502,9 @@ trait Definitions extends api.StandardDefinitions { lazy val StringContextClass = requiredClass[scala.StringContext] - lazy val QuasiquoteClass = if (ApiUniverseClass != NoSymbol) getMember(ApiUniverseClass, tpnme.Quasiquote) else NoSymbol + // SI-8392 a reflection universe on classpath may not have + // quasiquotes, if e.g. crosstyping with -Xsource on + lazy val QuasiquoteClass = if (ApiUniverseClass != NoSymbol) getMemberIfDefined(ApiUniverseClass, tpnme.Quasiquote) else NoSymbol lazy val QuasiquoteClass_api = if (QuasiquoteClass != NoSymbol) getMember(QuasiquoteClass, tpnme.api) else NoSymbol lazy val QuasiquoteClass_api_apply = if (QuasiquoteClass_api != NoSymbol) getMember(QuasiquoteClass_api, nme.apply) else NoSymbol lazy val QuasiquoteClass_api_unapply = if (QuasiquoteClass_api != NoSymbol) getMember(QuasiquoteClass_api, nme.unapply) else NoSymbol diff --git a/src/reflect/scala/reflect/internal/ReificationSupport.scala b/src/reflect/scala/reflect/internal/ReificationSupport.scala index dfe1811ff0..9a130337b4 100644 --- a/src/reflect/scala/reflect/internal/ReificationSupport.scala +++ b/src/reflect/scala/reflect/internal/ReificationSupport.scala @@ -850,9 +850,24 @@ trait ReificationSupport { self: SymbolTable => case tree => throw new IllegalArgumentException("$tree is not valid representation of pattern match case") } + object SyntacticPartialFunction extends SyntacticPartialFunctionExtractor { + def apply(cases: List[Tree]): Match = Match(EmptyTree, mkCases(cases)) + def unapply(tree: Match): Option[List[CaseDef]] = tree match { + case Match(EmptyTree, cases) => Some(cases) + case _ => None + } + } + object SyntacticMatch extends SyntacticMatchExtractor { - def apply(selector: Tree, cases: List[Tree]) = Match(selector, mkCases(cases)) - def unapply(tree: Match): Option[(Tree, List[CaseDef])] = Match.unapply(tree) + def apply(scrutinee: Tree, cases: List[Tree]) = { + require(scrutinee.nonEmpty, "match's scrutinee may not be empty") + Match(scrutinee, mkCases(cases)) + } + + def unapply(tree: Match): Option[(Tree, List[CaseDef])] = tree match { + case Match(scrutinee, cases) if scrutinee.nonEmpty => Some((scrutinee, cases)) + case _ => None + } } object SyntacticTry extends SyntacticTryExtractor { diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala index 640e0606c7..10959ff41f 100644 --- a/src/reflect/scala/reflect/internal/StdNames.scala +++ b/src/reflect/scala/reflect/internal/StdNames.scala @@ -630,6 +630,7 @@ trait StdNames { val SyntacticNew: NameType = "SyntacticNew" val SyntacticObjectDef: NameType = "SyntacticObjectDef" val SyntacticPackageObjectDef: NameType = "SyntacticPackageObjectDef" + val SyntacticPartialFunction: NameType = "SyntacticPartialFunction" val SyntacticPatDef: NameType = "SyntacticPatDef" val SyntacticSelectType: NameType = "SyntacticSelectType" val SyntacticSelectTerm: NameType = "SyntacticSelectTerm" diff --git a/src/reflect/scala/reflect/internal/SymbolTable.scala b/src/reflect/scala/reflect/internal/SymbolTable.scala index e50c65c9ca..c76dedbff4 100644 --- a/src/reflect/scala/reflect/internal/SymbolTable.scala +++ b/src/reflect/scala/reflect/internal/SymbolTable.scala @@ -51,6 +51,7 @@ abstract class SymbolTable extends macros.Universe val gen = new InternalTreeGen { val global: SymbolTable.this.type = SymbolTable.this } def log(msg: => AnyRef): Unit + def deprecationWarning(pos: Position, msg: String): Unit = warning(msg) def warning(msg: String): Unit = Console.err.println(msg) def inform(msg: String): Unit = Console.err.println(msg) def globalError(msg: String): Unit = abort(msg) diff --git a/src/reflect/scala/reflect/internal/Symbols.scala b/src/reflect/scala/reflect/internal/Symbols.scala index 595d638c28..2ce54d2259 100644 --- a/src/reflect/scala/reflect/internal/Symbols.scala +++ b/src/reflect/scala/reflect/internal/Symbols.scala @@ -2343,7 +2343,11 @@ trait Symbols extends api.Symbols { self: SymbolTable => def localName: TermName = name.localName /** The setter of this value or getter definition, or NoSymbol if none exists */ + @deprecated("Use `setterIn` instead", "2.11.0") final def setter(base: Symbol, hasExpandedName: Boolean = needsExpandedSetterName): Symbol = + setterIn(base, hasExpandedName) + + final def setterIn(base: Symbol, hasExpandedName: Boolean = needsExpandedSetterName): Symbol = base.info decl setterNameInBase(base, hasExpandedName) filter (_.hasAccessorFlag) def needsExpandedSetterName = ( diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index e9e5a89aa7..eb56f4ba81 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -2271,7 +2271,7 @@ trait Types case _ => args.mkString("(", ", ", ")") } private def customToString = sym match { - case RepeatedParamClass => args.head + "*" + case RepeatedParamClass | JavaRepeatedParamClass => args.head + "*" case ByNameParamClass => "=> " + args.head case _ => if (isFunctionTypeDirect(this)) { diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala index 3bcfed7d34..cfe2ad8b87 100644 --- a/src/reflect/scala/reflect/internal/Variances.scala +++ b/src/reflect/scala/reflect/internal/Variances.scala @@ -75,7 +75,14 @@ trait Variances { def nextVariance(sym: Symbol, v: Variance): Variance = ( if (shouldFlip(sym, tvar)) v.flip else if (isLocalOnly(sym)) Bivariant - else if (sym.isAliasType) Invariant + else if (sym.isAliasType) ( + // Unsound pre-2.11 behavior preserved under -Xsource:2.10 + if (settings.isScala211 || sym.isOverridingSymbol) Invariant + else { + deprecationWarning(sym.pos, s"Construct depends on unsound variance analysis and will not compile in scala 2.11 and beyond") + Bivariant + } + ) else v ) def loop(sym: Symbol, v: Variance): Variance = ( diff --git a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala index 212f94c531..e5c64c6f45 100644 --- a/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala +++ b/src/scaladoc/scala/tools/nsc/doc/ScaladocAnalyzer.scala @@ -37,7 +37,7 @@ trait ScaladocAnalyzer extends Analyzer { comment.defineVariables(sym) val typer1 = newTyper(context.makeNewScope(docDef, context.owner)) for (useCase <- comment.useCases) { - typer1.silent(_ => typer1 defineUseCases useCase) match { + typer1.silent(_.asInstanceOf[ScaladocTyper].defineUseCases(useCase)) match { case SilentTypeError(err) => unit.warning(useCase.pos, err.errMsg) case _ => diff --git a/test/files/neg/t8265.check b/test/files/neg/t8265.check new file mode 100644 index 0000000000..7b1db1c4e5 --- /dev/null +++ b/test/files/neg/t8265.check @@ -0,0 +1,6 @@ +t8265.scala:1: warning: Construct depends on unsound variance analysis and will not compile in scala 2.11 and beyond +class Foo[+CC[X]] { type Coll = CC[_] } + ^ +error: No warnings can be incurred under -Xfatal-warnings. +one warning found +one error found diff --git a/test/files/neg/t8265.flags b/test/files/neg/t8265.flags new file mode 100644 index 0000000000..9d7ba7abd8 --- /dev/null +++ b/test/files/neg/t8265.flags @@ -0,0 +1 @@ +-Xsource:2.10 -deprecation -language:higherKinds -Xfatal-warnings diff --git a/test/files/neg/t8265.scala b/test/files/neg/t8265.scala new file mode 100644 index 0000000000..a215903ebc --- /dev/null +++ b/test/files/neg/t8265.scala @@ -0,0 +1 @@ +class Foo[+CC[X]] { type Coll = CC[_] } diff --git a/test/files/neg/t8376.check b/test/files/neg/t8376.check new file mode 100644 index 0000000000..22ed942d51 --- /dev/null +++ b/test/files/neg/t8376.check @@ -0,0 +1,7 @@ +S.scala:2: error: overloaded method value m with alternatives: + (a: J*)Unit <and> + (a: String*)Unit + cannot be applied to (Int) + J.m(0) + ^ +one error found diff --git a/test/files/neg/t8376/J.java b/test/files/neg/t8376/J.java new file mode 100644 index 0000000000..29aa23da84 --- /dev/null +++ b/test/files/neg/t8376/J.java @@ -0,0 +1,4 @@ +class J { + public static void m(String... a) { } + public static void m(J... a) { } +} diff --git a/test/files/neg/t8376/S.scala b/test/files/neg/t8376/S.scala new file mode 100644 index 0000000000..a19f0d3c06 --- /dev/null +++ b/test/files/neg/t8376/S.scala @@ -0,0 +1,4 @@ +object S { + J.m(0) + // the error message should show `T*` in the method signatures rather than `<repeated>[T]` +} diff --git a/test/files/pos/t8363.flags b/test/files/pos/t8363.flags new file mode 100644 index 0000000000..48b438ddf8 --- /dev/null +++ b/test/files/pos/t8363.flags @@ -0,0 +1 @@ +-Ydelambdafy:method diff --git a/test/files/pos/t8363.scala b/test/files/pos/t8363.scala new file mode 100644 index 0000000000..639faf4120 --- /dev/null +++ b/test/files/pos/t8363.scala @@ -0,0 +1,7 @@ +class C(a: Any) +class Test { + def foo: Any = { + def form = 0 + class C1 extends C(() => form) + } +} diff --git a/test/files/pos/t8376/BindingsX.java b/test/files/pos/t8376/BindingsX.java new file mode 100644 index 0000000000..165fdaf5f6 --- /dev/null +++ b/test/files/pos/t8376/BindingsX.java @@ -0,0 +1,13 @@ +/** + * A simple Java class implementing methods similar to new JavaFX `Bindings`. + */ +public final class BindingsX { + + public static void select(String root, String... steps) { + throw new UnsupportedOperationException("Not implemented"); + } + + public static void select(Object root, String... steps) { + throw new UnsupportedOperationException("Not implemented"); + } +} diff --git a/test/files/pos/t8376/Test.scala b/test/files/pos/t8376/Test.scala new file mode 100644 index 0000000000..ba078a3532 --- /dev/null +++ b/test/files/pos/t8376/Test.scala @@ -0,0 +1,10 @@ +class Test { + BindingsX.select("", "") // okay in 2.10, fails in 2.11 + + BindingsY.select1("", "") // okay in both +} + +object BindingsY { + def select1(root: String, steps: String*) = () + def select1(root: Any, steps: String*) = () +} diff --git a/test/files/pos/t8403.scala b/test/files/pos/t8403.scala new file mode 100644 index 0000000000..eea60ed7ff --- /dev/null +++ b/test/files/pos/t8403.scala @@ -0,0 +1,9 @@ +trait Bug { + val u: { type Amb } = ??? + import u._ + + class Amb { def x = 0 } + class C(x: Amb) { // after dbd8457e4, "reference to Amb is ambiguous" + x.x + } +} diff --git a/test/files/run/t6196.scala b/test/files/run/t6196.scala index 16c2c7409d..a75911fb9e 100644 --- a/test/files/run/t6196.scala +++ b/test/files/run/t6196.scala @@ -43,7 +43,7 @@ object Test extends App { override def equals(that:Any) = { equalsCount += 1 - this match { + that match { case HashCounter(value) => this.value == value case _ => false } diff --git a/test/files/run/t6200.scala b/test/files/run/t6200.scala index 9a5d91e042..75600cd557 100644 --- a/test/files/run/t6200.scala +++ b/test/files/run/t6200.scala @@ -43,7 +43,7 @@ object Test extends App { override def equals(that: Any) = { equalsCount += 1 - this match { + that match { case HashCounter(value) => this.value == value case _ => false } diff --git a/test/files/run/t8266-octal-interp.check b/test/files/run/t8266-octal-interp.check index 6e9454119b..66ecafddc2 100644 --- a/test/files/run/t8266-octal-interp.check +++ b/test/files/run/t8266-octal-interp.check @@ -10,7 +10,7 @@ t8266-octal-interp.scala:6: warning: Octal escape literals are deprecated, use \ t8266-octal-interp.scala:7: warning: Octal escape literals are deprecated, use \r instead. f"a\15c", ^ -t8266-octal-interp.scala:8: warning: Octal escape literals are deprecated, use \u0022 instead. +t8266-octal-interp.scala:8: warning: Octal escape literals are deprecated, use ${'"'} or a triple-quoted literal """with embedded " or \u0022""" instead. f"a\42c", ^ t8266-octal-interp.scala:9: warning: Octal escape literals are deprecated, use \\ instead. diff --git a/test/files/run/t8395.scala b/test/files/run/t8395.scala new file mode 100644 index 0000000000..2570550619 --- /dev/null +++ b/test/files/run/t8395.scala @@ -0,0 +1,9 @@ + object Test { + def baz(x: Object) = { + val s @ (_s: String) = x + x + } + def main(args: Array[String]) { + assert(baz("1") == "1") + } +} diff --git a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala index 74d0d54ea8..45392de582 100644 --- a/test/files/scalacheck/quasiquotes/TermConstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermConstructionProps.scala @@ -95,12 +95,6 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") { body1 ≈ body && cond1 ≈ cond } - property("unquote trees into alternative") = forAll { (c: Tree, A: Tree, B: Tree) => - q"$c match { case $A | $B => }" ≈ - Match(c, List( - CaseDef(Alternative(List(A, B)), EmptyTree, Literal(Constant(()))))) - } - def blockInvariant(quote: Tree, trees: List[Tree]) = quote ≈ (trees match { case Nil => q"{}" @@ -303,4 +297,17 @@ object TermConstructionProps extends QuasiquoteProperties("term construction") { property("SI-8385 b") = test { assertEqAst(q"(() => ())()", "(() => ())()") } + + property("match scrutinee may not be empty") = test { + assertThrows[IllegalArgumentException] { + val scrutinee = q"" + val cases = List(cq"_ =>") + q"$scrutinee match { case ..$cases }" + } + } + + property("construct partial function") = test { + val cases = List(cq"a => b", cq"c => d") + assertEqAst(q"{ case ..$cases }", "{ case a => b case c => d }") + } } diff --git a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala index f558a2f078..9e60729c09 100644 --- a/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala +++ b/test/files/scalacheck/quasiquotes/TermDeconstructionProps.scala @@ -211,4 +211,15 @@ object TermDeconstructionProps extends QuasiquoteProperties("term deconstruction val q"$f[..$targs]" = tq"foo[bar]" } } + + property("match doesn't match partial function") = test { + assertThrows[MatchError] { + val q"$_ match { case ..$_ }" = q"{ case _ => }" + } + } + + property("deconstruct partial function") = test { + val q"{ case ..$cases }" = q"{ case a => b case c => d }" + val List(cq"a => b", cq"c => d") = cases + } } diff --git a/test/pending/pos/t8363b.scala b/test/pending/pos/t8363b.scala new file mode 100644 index 0000000000..393e2a0237 --- /dev/null +++ b/test/pending/pos/t8363b.scala @@ -0,0 +1,7 @@ +class C(a: Any) +class Test { + def foo: Any = { + def form = 0 + class C1 extends C({def x = form; ()}) + } +} diff --git a/test/scaladoc/run/t8407.check b/test/scaladoc/run/t8407.check new file mode 100644 index 0000000000..06c860b3eb --- /dev/null +++ b/test/scaladoc/run/t8407.check @@ -0,0 +1,4 @@ +newSource:4: warning: not found: type $NotFound + * @usecase def zipWithIndex: $NotFound + ^ +Done. diff --git a/test/scaladoc/run/t8407.scala b/test/scaladoc/run/t8407.scala new file mode 100644 index 0000000000..2df9f4f1ac --- /dev/null +++ b/test/scaladoc/run/t8407.scala @@ -0,0 +1,20 @@ +import scala.tools.nsc.doc.model._ +import scala.tools.partest.ScaladocModelTest + +object Test extends ScaladocModelTest { + override def code = """ +class C { + /** + * @usecase def zipWithIndex: $NotFound + * + */ + def zipWithIndex: Int = ??? +} + """ + + def scaladocSettings = "" + + def testModel(root: Package) = { + // just testing that it doesn't error out. + } +} |