Skip to content

Commit 408ff2f

Browse files
authored
Merge branch 'main' into fix-wunused-false-positive-in-for
2 parents fb0efe5 + 73af81e commit 408ff2f

File tree

10 files changed

+62
-16
lines changed

10 files changed

+62
-16
lines changed

compiler/src/dotty/tools/dotc/staging/CrossStageSafety.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class CrossStageSafety extends TreeMapWithStages {
6060
val healedType = healType(tree.srcPos)(tp1)
6161
if healedType == tree.tpe then tree
6262
else TypeTree(healedType).withSpan(tree.span)
63-
case _: RefTree if tree.isType =>
63+
case _: RefTree | _: SingletonTypeTree if tree.isType =>
6464
val healedType = healType(tree.srcPos)(tree.tpe)
6565
if healedType == tree.tpe then tree
6666
else TypeTree(healedType).withSpan(tree.span)

compiler/src/dotty/tools/dotc/transform/CheckUnused.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,11 +605,13 @@ object CheckUnused:
605605
case (sel, sym) if dealias(sym) == dealiasedSym => sel
606606
}.headOption else None
607607
def wildcard = sels.find(sel => sel.isWildcard && ((sym.is(Given) == sel.isGiven) || sym.is(Implicit)))
608-
if qualHasSymbol && !isAccessible && sym.exists then
608+
if qualHasSymbol && (!isAccessible || sym.isRenamedSymbol(symName)) && sym.exists then
609609
selector.orElse(dealiasedSelector).orElse(wildcard) // selector with name or wildcard (or given)
610610
else
611611
None
612612

613+
private def isRenamedSymbol(symNameInScope: Option[Name])(using Context) =
614+
sym.name != nme.NO_NAME && symNameInScope.exists(_.toSimpleName != sym.name.toSimpleName)
613615

614616
private def dealias(symbol: Symbol)(using Context): Symbol =
615617
if(symbol.isType && symbol.asType.denot.isAliasType) then

docs/_docs/reference/changed-features/lazy-vals-init.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ title: Lazy Vals Initialization
44
nightlyOf: https://docs.scala-lang.org/scala3/reference/changed-features/lazy-vals-init.html
55
---
66

7-
Scala 3 implements [Version 6](https://docs.scala-lang.org/sips/improved-lazy-val-initialization.html#version-6---no-synchronization-on-this-and-concurrent-initialization-of-fields)
8-
of the [SIP-20] improved lazy vals initialization proposal.
7+
Scala 3 implements Version 6 of the [SIP-20] improved lazy vals initialization proposal.
98

109
## Motivation
1110

@@ -77,4 +76,4 @@ recursive lazy vals is undefined (initialization may result in a deadlock).
7776

7877
* [SIP-20]
7978

80-
[SIP-20]: https://docs.scala-lang.org/sips/improved-lazy-val-initialization.html
79+
[SIP-20]: https://github.com/scala/improvement-proposals/pull/19

docs/_docs/reference/metaprogramming/tasty-inspect.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,33 @@ title: "TASTy Inspection"
44
nightlyOf: https://docs.scala-lang.org/scala3/reference/metaprogramming/tasty-inspect.html
55
---
66

7-
```scala
8-
libraryDependencies += "org.scala-lang" %% "scala3-tasty-inspector" % scalaVersion.value
9-
```
10-
117
TASTy files contain the full typed tree of a class including source positions
128
and documentation. This is ideal for tools that analyze or extract semantic
13-
information from the code. To avoid the hassle of working directly with the TASTy
9+
information from the code.
10+
11+
To avoid the hassle of working directly with the TASTy
1412
file we provide the `Inspector` which loads the contents and exposes it
1513
through the TASTy reflect API.
1614

17-
## Inspecting TASTy files
15+
We also showcase TASTyViz, a visualiser for tasty, useful for debugging and checking your understanding of TASTy
16+
17+
## TASTyViz
18+
19+
<!-- Keep synced with https://github.com/scala/docs.scala-lang/blob/main/scala3/guides/tasty-overview.md -->
20+
21+
TASTyViz is a tool to inspect TASTy files visually.
22+
At the time of writing, it is still in the early stages of developement, therefore you can expect missing functionality and less-than-ideal user experience, but it could still prove useful when debugging.
23+
You can check it out [here](https://github.com/shardulc/tastyviz).
24+
25+
## `Inspector`
26+
27+
`Inspector` is a tool which provides API access to TASTy.
28+
29+
You can add the depency to your sbt build like so:
30+
```scala
31+
libraryDependencies += "org.scala-lang" %% "scala3-tasty-inspector" % scalaVersion.value
32+
```
33+
1834

1935
To inspect the trees of a TASTy file a consumer can be defined in the following way.
2036

docs/_docs/reference/new-types/union-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: "Union Types"
44
nightlyOf: https://docs.scala-lang.org/scala3/reference/new-types/union-types.html
55
---
66

7-
A union type `A | B` has as values all values of type `A` and also all values of type `B`.
7+
A union type `A | B` includes all values of both types.
88

99

1010
```scala

scaladoc/resources/dotty_res/styles/theme/layout/header.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@
6363
align-items: center;
6464
}
6565

66+
.logo-container .project-logo {
67+
max-width: 40px;
68+
}
69+
70+
.logo-container .project-logo img {
71+
max-width: 100%;
72+
}
73+
6674
#mobile-menu-toggle {
6775
display: none;
6876
}

tests/neg-custom-args/fatal-warnings/i15503i.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ package foo.test.i17156:
288288
import b.Xd
289289
trait Z derives Xd
290290

291+
291292
package foo.test.i17175:
292293
val continue = true
293294
def foo =
@@ -296,4 +297,18 @@ package foo.test.i17175:
296297
if continue
297298
} {
298299
println(i)
299-
}
300+
}
301+
302+
package foo.test.i17117:
303+
package example {
304+
object test1 {
305+
val test = "test"
306+
}
307+
308+
object test2 {
309+
310+
import example.test1 as t1
311+
312+
val test = t1.test
313+
}
314+
}

tests/neg-macros/i8887.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.quoted._
2+
3+
def expr[X](x: Any)(using Quotes): Expr[Any] =
4+
'{ foo[x.type] } // error
5+
def foo[X]: Any = ???

tests/neg-macros/quote-this-a.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ class Foo {
44

55
def f(using Quotes): Unit = '{
66
def bar[T](x: T): T = x
7-
bar[
8-
this.type // error
9-
] {
7+
bar[this.type] {
108
this // error
119
}
1210
}

tests/pos-macros/i8887.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import scala.quoted._
2+
inline def foo(x: Any): Any = ${ expr[x.type] }
3+
def expr[X](using Quotes): Expr[Any] = ???

0 commit comments

Comments
 (0)