Skip to content

Commit

Permalink
Merge pull request #9 from larsrh/wip/dotty
Browse files Browse the repository at this point in the history
Dotty support
  • Loading branch information
Avasil authored Nov 16, 2020
2 parents 5a6e769 + 8afe9c5 commit 877eb52
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scala.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Set up JDK 8
uses: olafurpg/setup-scala@v2
uses: olafurpg/setup-scala@v10
with:
java-version: 8
- name: Cache Coursier
Expand Down
94 changes: 41 additions & 53 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,71 +5,59 @@ addCommandAlias("ci-all", ";+clean ;+test:compile ;+test ;+package")
addCommandAlias("release", ";+clean ;+publishSigned")

ThisBuild / scalaVersion := "2.13.1"
ThisBuild / crossScalaVersions := Seq("2.12.10", "2.13.1")
ThisBuild / crossScalaVersions := Seq("2.12.10", "2.13.1", "0.27.0-RC1", "3.0.0-M1")
ThisBuild / organization := "io.monix"
ThisBuild / organizationName := "monix"

lazy val scalaLinterOptions =
Seq(
// Enables linter options
"-Xlint:adapted-args", // warn if an argument list is modified to match the receiver
"-Xlint:nullary-unit", // warn when nullary methods return Unit
"-Xlint:inaccessible", // warn about inaccessible types in method signatures
"-Xlint:nullary-override", // warn when non-nullary `def f()' overrides nullary `def f'
"-Xlint:infer-any", // warn when a type argument is inferred to be `Any`
"-Xlint:missing-interpolator", // a string literal appears to be missing an interpolator id
"-Xlint:doc-detached", // a ScalaDoc comment appears to be detached from its element
"-Xlint:private-shadow", // a private field (or class parameter) shadows a superclass field
"-Xlint:type-parameter-shadow", // a local type parameter shadows a type already in scope
"-Xlint:poly-implicit-overload", // parameterized overloaded implicit methods are not visible as view bounds
"-Xlint:option-implicit", // Option.apply used implicit view
"-Xlint:delayedinit-select", // Selecting member of DelayedInit
"-Xlint:package-object-classes" // Class or object defined in package object
)

lazy val scalaTwoTwelvePlusOptions =
Seq(
// Options available from Scala 2.12 and up
"-Ywarn-unused:-implicits"
)

lazy val scalaTwoTwelveDeprecatedOptions =
Seq(
// Deprecated in 2.12, removed in 2.13
"-Ywarn-inaccessible",
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit"
)
ThisBuild / scalacOptions ++= Seq(
// Note, this is used by the doc-source-url feature to determine the
// relative path of a given source file. If it's not a prefix of a the
// absolute path of the source file, the absolute path of that file
// will be put into the FILE_SOURCE variable, which is
// definitely not what we want.
"-sourcepath", file(".").getAbsolutePath.replaceAll("[.]$", "")
)

lazy val sharedSettings = Seq(
scalacOptions in ThisBuild ++= Seq(
// Note, this is used by the doc-source-url feature to determine the
// relative path of a given source file. If it's not a prefix of a the
// absolute path of the source file, the absolute path of that file
// will be put into the FILE_SOURCE variable, which is
// definitely not what we want.
"-sourcepath", file(".").getAbsolutePath.replaceAll("[.]$", "")
),
// Version specific options
scalacOptions ++= (
if (isDotty.value)
Seq()
else
Seq(
"-unchecked", "-deprecation", "-feature", "-Xlint",
"-Ywarn-dead-code",
"-Xlog-free-terms",
// Enables linter options
"-Xlint:adapted-args", // warn if an argument list is modified to match the receiver
"-Xlint:nullary-unit", // warn when nullary methods return Unit
"-Xlint:inaccessible", // warn about inaccessible types in method signatures
"-Xlint:nullary-override", // warn when non-nullary `def f()' overrides nullary `def f'
"-Xlint:infer-any", // warn when a type argument is inferred to be `Any`
"-Xlint:missing-interpolator", // a string literal appears to be missing an interpolator id
"-Xlint:doc-detached", // a ScalaDoc comment appears to be detached from its element
"-Xlint:private-shadow", // a private field (or class parameter) shadows a superclass field
"-Xlint:type-parameter-shadow", // a local type parameter shadows a type already in scope
"-Xlint:poly-implicit-overload", // parameterized overloaded implicit methods are not visible as view bounds
"-Xlint:option-implicit", // Option.apply used implicit view
"-Xlint:delayedinit-select", // Selecting member of DelayedInit
"-Xlint:package-object-classes" // Class or object defined in package object
)

scalacOptions ++= Seq(
"-unchecked", "-deprecation", "-feature", "-Xlint",
"-Ywarn-dead-code",
"-Xlog-free-terms"
),

// Version specific options
scalacOptions ++= (CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, v)) if v > 12 =>
scalaLinterOptions ++ scalaTwoTwelvePlusOptions
case _ =>
scalaLinterOptions ++ scalaTwoTwelvePlusOptions ++ scalaTwoTwelveDeprecatedOptions
}),

unmanagedSourceDirectories in Compile += {
(baseDirectory in LocalRootProject).value / "shared/src/main/scala"
},

libraryDependencies += "io.monix" %%% "minitest" % "2.8.2" % "test",
Compile / unmanagedSourceDirectories += (
if (isDotty.value)
(ThisBuild / baseDirectory).value / "shared/src/main/scala-3"
else
(ThisBuild / baseDirectory).value / "shared/src/main/scala-2"
),

libraryDependencies += "io.monix" %%% "minitest" % "2.9.0" % "test",
testFrameworks += new TestFramework("minitest.runner.Framework"),

headerLicense := Some(HeaderLicense.Custom(
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.4
sbt.version=1.4.0
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.3")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.2.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.5")
addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.6")
File renamed without changes.
21 changes: 21 additions & 0 deletions shared/src/main/scala-3/implicitbox/Not.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright (c) 2014-2020 by The Monix Project Developers.
* See the project homepage at: https://monix.io
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package implicitbox

type Not[+A] = scala.util.Not[A]
val Not = scala.util.Not
2 changes: 1 addition & 1 deletion shared/src/test/scala/implicitbox/NotSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ object NotSuite extends SimpleTestSuite {
}

test("should fail if implicit is in scope") {
assertDoesNotCompile("implicitly[Not[MyType[String]]]", ".*?exists in scope.*?")
assertDoesNotCompile("implicitly[Not[MyType[String]]]")
}
}

0 comments on commit 877eb52

Please sign in to comment.