Skip to content

Backport "improvement: Remove workaround for Bloop and update docs" to 3.3 LTS #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions compiler/src/dotty/tools/dotc/config/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ object Settings:

def deprecated(msg: String, extraArgs: List[String] = Nil): Settings.ArgsSummary =
ArgsSummary(sstate, extraArgs ++ arguments.tail, errors, warnings :+ msg)

@unshared
val settingCharacters = "[a-zA-Z0-9_\\-]*".r
def validateSettingString(name: String): Unit =
assert(settingCharacters.matches(name), s"Setting string $name contains invalid characters")
}

/** List of setting-value pairs that are required for another setting to be valid.
* For example, `s = Setting(..., depends = List(YprofileEnabled -> true))`
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ object Phases {

// Test that we are in a state where we need to check if the phase should be skipped for a java file,
// this prevents checking the expensive `unit.typedAsJava` unnecessarily.
val doCheckJava = skipIfJava && !isAfterLastJavaPhase
for unit <- units do ctx.profiler.onUnit(this, unit):
given unitCtx: Context = runCtx.fresh.setPhase(this.start).setCompilationUnit(unit).withRootImports
if ctx.run.enterUnit(unit) then
Expand Down
3 changes: 1 addition & 2 deletions compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import java.nio.channels.ClosedByInterruptException

import scala.util.control.NonFatal

import dotty.tools.dotc.classpath.FileUtils.{hasTastyExtension, hasBetastyExtension}
import dotty.tools.io.{ ClassPath, ClassRepresentation, AbstractFile, NoAbstractFile }
import dotty.tools.backend.jvm.DottyBackendInterface.symExtensions

Expand Down Expand Up @@ -338,7 +337,7 @@ abstract class SymbolLoader extends LazyType { self =>
val sym = root.symbol
def associatedFile = root.symbol.associatedFile match
case file: AbstractFile => file
case _ => NoAbstractFile
case null => NoAbstractFile
ctx.profiler.onCompletion(sym, associatedFile)(body)
}

Expand Down
4 changes: 1 addition & 3 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -917,9 +917,7 @@ object TypeOps:
}

val inferThisMap = new InferPrefixMap
val tvars = tp1.etaExpand match
case eta: TypeLambda => constrained(eta)
case _ => Nil
val tvars = tp1.typeParams.map { tparam => newTypeVar(tparam.paramInfo.bounds, DepParamName.fresh(tparam.paramName)) }
val protoTp1 = inferThisMap.apply(tp1).appliedTo(tvars)

if gadtSyms.nonEmpty then
Expand Down
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4636,7 +4636,6 @@ object Types extends TypeUtils {
type BT <: LambdaType
def paramNum: Int
def paramName: binder.ThisName = binder.paramNames(paramNum)
def paramInfo: binder.PInfo = binder.paramInfos(paramNum)

override def underlying(using Context): Type = {
// TODO: update paramInfos's type to nullable
Expand Down
33 changes: 5 additions & 28 deletions compiler/src/dotty/tools/dotc/transform/patmat/Space.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package patmat

import core.*, Constants.*, Contexts.*, Decorators.*, Flags.*, Names.*, NameOps.*, StdNames.*, Symbols.*, Types.*
import ast.*, tpd.*
import config.Printers.exhaustivity
import config.Printers.*
import printing.{ Printer, * }, Texts.*
import reporting.*
import typer.*, Applications.*, Inferencing.*, ProtoTypes.*
Expand Down Expand Up @@ -531,37 +531,14 @@ object SpaceEngine {
val mt: MethodType = unapp.widen match {
case mt: MethodType => mt
case pt: PolyType =>
scrutineeTp match
case AppliedType(tycon, targs)
if unappSym.is(Synthetic)
&& (pt.resultType.asInstanceOf[MethodType].paramInfos.head.typeConstructor eq tycon) =>
// Special case synthetic unapply/unapplySeq's
// Provided the shapes of the types match:
// the scrutinee type being unapplied and
// the unapply parameter type
pt.instantiate(targs).asInstanceOf[MethodType]
case _ =>
val locked = ctx.typerState.ownedVars
val tvars = constrained(pt)
val mt = pt.instantiate(tvars).asInstanceOf[MethodType]
val unapplyArgType = mt.paramInfos.head
scrutineeTp <:< unapplyArgType
scrutineeTp <:< mt.paramInfos(0)
// force type inference to infer a narrower type: could be singleton
// see tests/patmat/i4227.scala
unapplyArgType <:< scrutineeTp
maximizeType(unapplyArgType, Spans.NoSpan)
if !(ctx.typerState.ownedVars -- locked).isEmpty then
// constraining can create type vars out of wildcard types
// (in legalBound, by using a LevelAvoidMap)
// maximise will only do one pass at maximising the type vars in the target type
// which means we can maximise to types that include other type vars
// this fails TreeChecker's "non-empty constraint at end of $fusedPhase" check
// e.g. run-macros/string-context-implicits
// I can't prove that a second call won't also create type vars,
// but I'd rather have an unassigned new-new type var, than an infinite loop.
// After all, there's nothing strictly "wrong" with unassigned type vars,
// it just fails TreeChecker's linting.
maximizeType(unapplyArgType, Spans.NoSpan)
mt.paramInfos(0) <:< scrutineeTp
instantiateSelected(mt, tvars)
isFullyDefined(mt, ForceDegree.all)
mt
}

Expand Down
13 changes: 0 additions & 13 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2490,19 +2490,6 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
if filters == List(MessageFilter.None) then sup.markUsed()
ctx.run.nn.suppressions.addSuppression(sup)

/** Run `typed` on `rhs` except if `rhs` is the right hand side of a deferred given,
* in which case the empty tree is returned.
*/
private inline def excludeDeferredGiven(
rhs: untpd.Tree, sym: Symbol)(
inline typed: untpd.Tree => Tree)(using Context): Tree =
rhs match
case rhs: RefTree
if rhs.name == nme.deferred && sym.isAllOf(DeferredGivenFlags, butNot = Param) =>
EmptyTree
case _ =>
typed(rhs)

def typedValDef(vdef: untpd.ValDef, sym: Symbol)(using Context): Tree = ctx.profiler.onTypedDef(sym) {
val ValDef(name, tpt, _) = vdef
completeAnnotations(vdef, sym)
Expand Down
9 changes: 0 additions & 9 deletions compiler/test/dotty/tools/repl/ReplCompilerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,6 @@ class ReplCompilerTests extends ReplTest:
assertTrue(last, last.startsWith("val res0: tpolecat.type = null"))
assertTrue(last, last.endsWith("""// result of "res0.toString" is null"""))

@Test def `i21431 filter out best effort options`: Unit =
initially:
run(":settings -Ybest-effort -Ywith-best-effort-tasty")
.andThen:
run("0") // check for crash
val last = lines()
assertTrue(last(0), last(0) == ("Options incompatible with repl will be ignored: -Ybest-effort, -Ywith-best-effort-tasty"))
assertTrue(last(1), last(1) == ("val res0: Int = 0"))

@Test def `i9879`: Unit = initially:
run {
"""|opaque type A = Int; def getA: A = 0
Expand Down
30 changes: 15 additions & 15 deletions docs/_docs/contributing/setting-up-your-ide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ layout: doc-page
title: Setting up your IDE
---

You can use either Metals with your favorite editor (VS Code, Neovim, Sublime)
or [IntelliJ IDEA for
Scala](https://www.jetbrains.com/help/idea/discover-intellij-idea-for-scala.html)
You can use either Metals with your favorite editor or
[IntelliJ IDEA for Scala](https://www.jetbrains.com/help/idea/discover-intellij-idea-for-scala.html)
to work on the Scala 3 codebase. There are however a few additional
considerations to take into account.

## Bootstrapping Projects

The sbt build for dotty implements bootstrapping within the same build, so each component has
two projects:
The sbt build for dotty implements bootstrapping within the same build, so each
component has two projects:

```
sbt:scala3> projects
Expand All @@ -32,23 +31,24 @@ Normally this is fine, but if you're working on certain modules like `scaladoc`
you'll actually want these modules exported. In order to achieve this you'll
want to make sure you do two things:

1. You'll want to find and change the following under
`commonBootstrappedSettings` which is found in the
[`Build.scala`](https://github.com/lampepfl/dotty/blob/main/project/Build.scala)
file.
1. You'll want to find and change the following above
`commonBootstrappedSettings` which is found in the
[`Build.scala`](https://github.com/scala/scala3/blob/main/project/Build.scala)
file.

```diff

- bspEnabled := false,
+ bspEnabled := true,
- val enableBspAllProjects = false,
+ val enableBspAllProjects = true,
```

2. Set `sbt` as your build server instead of the default, Bloop. You can achieve
this with the `Metals: Switch Build Server` command and then choosing sbt. In
VSCode, this looks like this:
2. Run `sbt publishLocal` to get the needed presentation compiler jars.

![bsp-switch](https://user-images.githubusercontent.com/777748/241986423-0724ae74-0ebd-42ef-a1b7-4d17678992b4.png)
By default Metals uses Bloop build server, however you can also use sbt
directly. You can achieve this with the `Metals: Switch Build Server` command
and then choosing sbt. In VSCode, this looks like this:

![bsp-switch](https://user-images.githubusercontent.com/777748/241986423-0724ae74-0ebd-42ef-a1b7-4d17678992b4.png)

### IntelliJ

Expand Down
16 changes: 13 additions & 3 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,20 @@ object Build {
) ++ extMap
}

/* These projects are irrelevant from IDE point of view and do not compile with Bloop*/
val fullyDisabledProjects = Set(
"scala2-library-cc",
"scala2-library-bootstrapped",
"scala2-library-cc-tasty",
"scala2-library-tasty"
)

val enableBspAllProjects = false

// Settings used when compiling dotty with a non-bootstrapped dotty
lazy val commonBootstrappedSettings = commonDottySettings ++ NoBloopExport.settings ++ Seq(
// To enable support of scaladoc and language-server projects you need to change this to true and use sbt as your build server
bspEnabled := false,
lazy val commonBootstrappedSettings = commonDottySettings ++ Seq(
// To enable support of scaladoc and language-server projects you need to change this to true
bspEnabled := { if(fullyDisabledProjects(name.value)) false else enableBspAllProjects },
(Compile / unmanagedSourceDirectories) += baseDirectory.value / "src-bootstrapped",

version := dottyVersion,
Expand Down
31 changes: 0 additions & 31 deletions project/NoBloopExport.scala

This file was deleted.

18 changes: 15 additions & 3 deletions tests/printing/lambdas.check
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@ package <empty> {
val f1: Int => Int = (x: Int) => x.+(1)
val f2: (Int, Int) => Int = (x: Int, y: Int) => x.+(y)
val f3: Int => Int => Int = (x: Int) => (y: Int) => x.+(y)
val f4: [T] => (x: Int) => Int = [T >: Nothing <: Any] => (x: Int) => x.+(1)
val f5: [T] => (x: Int) => Int => Int = [T >: Nothing <: Any] => (x: Int)
=> (y: Int) => x.+(y)
val f4: [T] => (x: Int) => Int =
{
final class $anon() extends Object(), PolyFunction {
def apply[T >: Nothing <: Any](x: Int): Int = x.+(1)
}
new $anon():([T] => (x: Int) => Int)
}
val f5: [T] => (x: Int) => Int => Int =
{
final class $anon() extends Object(), PolyFunction {
def apply[T >: Nothing <: Any](x: Int): Int => Int = (y: Int) =>
x.+(y)
}
new $anon():([T] => (x: Int) => Int => Int)
}
val f6: Int => Int = (x: Int) =>
{
val x2: Int = x.+(1)
Expand Down
Loading
Loading