From 0831ec9935544bce9057bbb764865983504651ce Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 7 Jun 2019 09:50:02 +0200 Subject: [PATCH 1/4] Fix WithBounds in 2.12 build --- library/src-2.x/scala/internal/WithBounds.scala | 8 ++++++++ .../scala}/internal/WithBounds.scala | 0 2 files changed, 8 insertions(+) create mode 100644 library/src-2.x/scala/internal/WithBounds.scala rename library/{src/scala/annotation => src-3.x/scala}/internal/WithBounds.scala (100%) diff --git a/library/src-2.x/scala/internal/WithBounds.scala b/library/src-2.x/scala/internal/WithBounds.scala new file mode 100644 index 000000000000..c104da55ad4c --- /dev/null +++ b/library/src-2.x/scala/internal/WithBounds.scala @@ -0,0 +1,8 @@ +package scala.annotation.internal + +import scala.annotation.Annotation + +/** An annotation to indicate a pair of type bounds that comes with a type. + * Used to indicate optional bounds of an opaque type + */ +class WithBounds[Lo /*<: AnyKind*/, Hi /*<: AnyKind*/] extends Annotation diff --git a/library/src/scala/annotation/internal/WithBounds.scala b/library/src-3.x/scala/internal/WithBounds.scala similarity index 100% rename from library/src/scala/annotation/internal/WithBounds.scala rename to library/src-3.x/scala/internal/WithBounds.scala From 748bf471afa60a85e5d5237fd2c144071cb4f0e6 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 7 Jun 2019 09:54:27 +0200 Subject: [PATCH 2/4] Fix for syntax for 2.12 build --- .../src/dotty/tools/dotc/core/CheckRealizable.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala b/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala index 0102cc0471d1..e4849bdf1c25 100644 --- a/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala +++ b/compiler/src/dotty/tools/dotc/core/CheckRealizable.scala @@ -146,16 +146,18 @@ class CheckRealizable(implicit ctx: Context) { private def boundsRealizability(tp: Type) = { val memberProblems = - for mbr <- tp.nonClassTypeMembers if !(mbr.info.loBound <:< mbr.info.hiBound) - yield new HasProblemBounds(mbr.name, mbr.info) + for { + mbr <- tp.nonClassTypeMembers + if !(mbr.info.loBound <:< mbr.info.hiBound) + } yield new HasProblemBounds(mbr.name, mbr.info) val refinementProblems = - for + for { name <- refinedNames(tp) if (name.isTypeName) mbr <- tp.member(name).alternatives if !(mbr.info.loBound <:< mbr.info.hiBound) - yield new HasProblemBounds(name, mbr.info) + } yield new HasProblemBounds(name, mbr.info) def baseTypeProblems(base: Type) = base match { case AndType(base1, base2) => From fa6ee0d5360a423c41a730e24ad28a7ec32f0045 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 7 Jun 2019 10:03:18 +0200 Subject: [PATCH 3/4] Add missing type and import for 2.12 build --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 2 +- compiler/src/dotty/tools/dotc/core/Annotations.scala | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index 541fd9ecfc3a..6521deaa1f70 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1017,7 +1017,7 @@ object desugar { var tested: MemberDef = tree def fail(msg: String) = ctx.error(msg, tree.sourcePos) def checkApplicable(flag: FlagSet, test: MemberDefTest): Unit = - if (tested.mods.is(flag) && !test.applyOrElse(tree, _ => false)) { + if (tested.mods.is(flag) && !test.applyOrElse(tree, (md: MemberDef) => false)) { fail(i"modifier `$flag` is not allowed for this definition") tested = tested.withMods(tested.mods.withoutFlags(flag)) } diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index b74603d8bd44..c21dadf3ed05 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -181,6 +181,7 @@ object Annotations { object WithBounds { def unapply(ann: Annotation)(implicit ctx: Context): Option[TypeBounds] = if (ann.symbol == defn.WithBoundsAnnot) { + import ast.Trees._ // We need to extract the type of the type tree in the New itself. // The annotation's type has been simplified as the type of an expression, // which means that `&` or `|` might have been lost. From 5513eacdd2346f9e353b7dceed47613c2030d329 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Fri, 7 Jun 2019 10:36:44 +0200 Subject: [PATCH 4/4] Remove src-2.x/scala/internal/WithBounds.scala --- library/src-2.x/scala/internal/WithBounds.scala | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 library/src-2.x/scala/internal/WithBounds.scala diff --git a/library/src-2.x/scala/internal/WithBounds.scala b/library/src-2.x/scala/internal/WithBounds.scala deleted file mode 100644 index c104da55ad4c..000000000000 --- a/library/src-2.x/scala/internal/WithBounds.scala +++ /dev/null @@ -1,8 +0,0 @@ -package scala.annotation.internal - -import scala.annotation.Annotation - -/** An annotation to indicate a pair of type bounds that comes with a type. - * Used to indicate optional bounds of an opaque type - */ -class WithBounds[Lo /*<: AnyKind*/, Hi /*<: AnyKind*/] extends Annotation