Skip to content

Commit d486eb9

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents ba3eb35 + 9396d57 commit d486eb9

File tree

23 files changed

+254
-80
lines changed

23 files changed

+254
-80
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
[submodule "community-build/community-projects/stdLib213"]
2626
path = community-build/community-projects/stdLib213
2727
url = https://github.com/dotty-staging/scala
28-
[submodule "community-build/community-projects/pdbp"]
29-
path = community-build/community-projects/pdbp
30-
url = https://github.com/dotty-staging/pdbp
3128
[submodule "community-build/community-projects/sourcecode"]
3229
path = community-build/community-projects/sourcecode
3330
url = https://github.com/dotty-staging/sourcecode
@@ -193,3 +190,6 @@
193190
[submodule "community-build/community-projects/cask"]
194191
path = community-build/community-projects/cask
195192
url = https://github.com/dotty-staging/cask.git
193+
[submodule "community-build/community-projects/psbp"]
194+
path = community-build/community-projects/psbp
195+
url = https://github.com/dotty-staging/psbp-library.github.io
Lines changed: 0 additions & 1 deletion
This file was deleted.
Submodule psbp added at 8f08f65

community-build/src/scala/dotty/communitybuild/projects.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,11 +362,10 @@ object projects:
362362
sbtDocCommand = "set ThisBuild / useEffpiPlugin := false; effpi/doc; benchmarks/doc; examples/doc; pluginBenchmarks/doc",
363363
)
364364

365-
// TODO @odersky? It got broken by #5458
366-
// val pdbp = test(
367-
// project = "pdbp",
368-
// sbtTestCommand = "compile",
369-
// )
365+
val psbp = SbtCommunityProject(
366+
project = "psbp",
367+
sbtTestCommand = "compile",
368+
)
370369

371370
lazy val sconfig = SbtCommunityProject(
372371
project = "sconfig",
@@ -709,6 +708,7 @@ def allProjects = List(
709708
projects.akka,
710709
projects.protoquill,
711710
projects.onnxScala,
711+
projects.psbp,
712712
)
713713

714714
lazy val projectMap = allProjects.groupBy(_.project)

community-build/test/scala/dotty/communitybuild/CommunityBuildTest.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class CommunityBuildTestA extends CommunityBuildTest:
102102
// @Test def scissSpan = projects.scissSpan .run()
103103
@Test def scissLucre = projects.scissLucre.run()
104104
@Test def zio = projects.zio.run()
105+
@Test def psbp = projects.psbp.run()
105106
end CommunityBuildTestA
106107

107108
@Category(Array(classOf[TestCategory]))

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,12 @@ class JSCodeGen()(using genCtx: Context) {
290290
"genScalaClass() must be called only for normal classes: "+sym)
291291
assert(sym.superClass != NoSymbol, sym)
292292

293-
/*if (hasDefaultCtorArgsAndRawJSModule(sym)) {
294-
reporter.error(pos,
295-
"Implementation restriction: constructors of " +
296-
"Scala classes cannot have default parameters " +
297-
"if their companion module is JS native.")
298-
}*/
293+
if (hasDefaultCtorArgsAndJSModule(sym)) {
294+
report.error(
295+
"Implementation restriction: " +
296+
"constructors of Scala classes cannot have default parameters if their companion module is JS native.",
297+
td)
298+
}
299299

300300
val classIdent = encodeClassNameIdent(sym)
301301
val originalName = originalNameOfClass(sym)
@@ -965,9 +965,8 @@ class JSCodeGen()(using genCtx: Context) {
965965

966966
if (hasDefaultCtorArgsAndJSModule(classSym)) {
967967
report.error(
968-
"Implementation restriction: constructors of " +
969-
"non-native JS classes cannot have default parameters " +
970-
"if their companion module is JS native.",
968+
"Implementation restriction: " +
969+
"constructors of non-native JS classes cannot have default parameters if their companion module is JS native.",
971970
classSym.srcPos)
972971
val ctorDef = js.JSMethodDef(js.MemberFlags.empty,
973972
js.StringLiteral("constructor"), Nil, None, js.Skip())(
@@ -1067,9 +1066,10 @@ class JSCodeGen()(using genCtx: Context) {
10671066
Some(js.MethodDef(js.MemberFlags.empty, methodName, originalName,
10681067
jsParams, toIRType(patchedResultType(sym)), None)(
10691068
OptimizerHints.empty, None))
1070-
} else /*if (isJSNativeCtorDefaultParam(sym)) {
1069+
} else if (sym.isJSNativeCtorDefaultParam) {
1070+
// #11592
10711071
None
1072-
} else if (sym.isClassConstructor && isHijackedBoxedClass(sym.owner)) {
1072+
} else /*if (sym.isClassConstructor && isHijackedBoxedClass(sym.owner)) {
10731073
None
10741074
} else*/ {
10751075
/*def isTraitImplForwarder = dd.rhs match {

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package transform
44

55
import dotty.tools.dotc.core.Contexts._
66
import dotty.tools.dotc.core.Decorators._
7+
import dotty.tools.dotc.core.Symbols._
78
import dotty.tools.dotc.core.Flags._
89
import dotty.tools.dotc.core.Types._
910
import dotty.tools.dotc.transform.MegaPhase.MiniPhase
@@ -37,7 +38,10 @@ class InlineVals extends MiniPhase:
3738
if !isPureExpr(rhs) then
3839
val details = if enclosingInlineds.isEmpty then "" else em"but was: $rhs"
3940
report.error(s"inline value must be pure$details", rhs.srcPos)
40-
case _ =>
41-
val pos = if tpt.span.isZeroExtent then rhs.srcPos else tpt.srcPos
42-
report.error(em"inline value must have a literal constant type", pos)
41+
case tp =>
42+
if tp.derivesFrom(defn.StringClass) || defn.ScalaValueClasses().exists(tp.derivesFrom(_)) then
43+
val pos = if tpt.span.isZeroExtent then rhs.srcPos else tpt.srcPos
44+
report.error(em"inline value must have a literal constant type", pos)
45+
else
46+
report.error(em"inline value must contain a literal constant value.\n\nTo inline more complex types consider using `inline def`", rhs)
4347
}

compiler/src/dotty/tools/dotc/transform/sjs/JSSymUtils.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ object JSSymUtils {
158158
}
159159
}
160160

161+
/** Is this symbol a default param accessor for the constructor of a native JS class? */
162+
def isJSNativeCtorDefaultParam(using Context): Boolean = {
163+
sym.name.is(DefaultGetterName)
164+
&& sym.name.exclude(DefaultGetterName) == nme.CONSTRUCTOR
165+
&& sym.owner.linkedClass.hasAnnotation(jsdefn.JSNativeAnnot)
166+
}
167+
161168
def jsCallingConvention(using Context): JSCallingConvention =
162169
JSCallingConvention.of(sym)
163170

library/src/scala/quoted/FromExpr.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ object FromExpr {
8484
def unapply(expr: Expr[T])(using Quotes) =
8585
import quotes.reflect._
8686
def rec(tree: Term): Option[T] = tree match {
87-
case Literal(c) if c.value != null => Some(c.value.asInstanceOf[T])
88-
case Block(Nil, e) => rec(e)
87+
case Block(stats, e) => if stats.isEmpty then rec(e) else None
88+
case Inlined(_, bindings, e) => if bindings.isEmpty then rec(e) else None
8989
case Typed(e, _) => rec(e)
90-
case Inlined(_, Nil, e) => rec(e)
91-
case _ => None
90+
case _ =>
91+
tree.tpe.widenTermRefByName match
92+
case ConstantType(c) => Some(c.value.asInstanceOf[T])
93+
case _ => None
9294
}
9395
rec(expr.asTerm)
9496
}

scaladoc-testcases/src/tests/links.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ object AnObject:
99
/**
1010
* Broken link, that should result a warning not break compilation
1111
* [[tests.links.AnObject]]
12-
1312
*/
1413
class LinksTest:
1514
def verifyIfLinksTestIsGenerated(b: Int): Int
16-
= 123
15+
= 123
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package tests
2+
package lookupInheritedMembers.pack1 {
3+
class A:
4+
def x = 1
5+
val y = 1
6+
type MyType
7+
8+
}
9+
package lookupInheritedMembers.pack2 {
10+
class B extends tests.lookupInheritedMembers.pack1.A
11+
}
12+
13+
package lookupInheritedMembers {
14+
/**
15+
* [[tests.lookupInheritedMembers.pack2.B.x]]
16+
* [[tests.lookupInheritedMembers.pack2.B.y]]
17+
* [[tests.lookupInheritedMembers.pack2.B.MyType]]
18+
*/
19+
class LookupInheritedMembers
20+
}

scaladoc-testcases/src/tests/tests.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ class B extends A {
131131
class BB
132132
}
133133

134+
class BModule {
135+
def foo = "foo"
136+
}
137+
134138
/** Companion object to test linking.
135139
*
136140
* This is my member: [[B$.Z]]
@@ -141,7 +145,7 @@ class B extends A {
141145
*
142146
* And this is my term member, addressed differently: [[this.Z$]]
143147
*/
144-
object B {
148+
object B extends BModule {
145149
type Z = Int
146150
val Z: Int = 0
147151
}

scaladoc/src/dotty/tools/scaladoc/tasty/SymOps.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,8 @@ class SymOps[Q <: Quotes](val q: Q) extends JavadocAnchorCreator with Scaladoc2A
190190
// For some reason it contains `$$$` instrad of symbol name
191191
s"${sym.name}${sym.fullName}/${sym.signature.resultSig}/[${sym.signature.paramSigs.mkString("/")}]"
192192
)
193+
194+
def driInContextOfInheritingParent(par: Symbol)(using dctx: DocContext): DRI = sym.dri.copy(
195+
location = par.dri.location,
196+
externalLink = None
197+
)

scaladoc/src/dotty/tools/scaladoc/tasty/TastyParser.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ case class ScaladocTastyInspector()(using ctx: DocContext) extends DocTastyInspe
8080
def driFor(link: String): Option[DRI] =
8181
val symOps = new SymOps[q.type](q)
8282
import symOps._
83-
Try(QueryParser(link).readQuery()).toOption.flatMap(q =>
84-
MemberLookup.lookupOpt(q, None).map{ case (sym, _) => sym.dri}
83+
Try(QueryParser(link).readQuery()).toOption.flatMap(query =>
84+
MemberLookup.lookupOpt(query, None).map {
85+
case (sym, _, inheritingParent) => inheritingParent match
86+
case Some(parent) => sym.driInContextOfInheritingParent(parent)
87+
case None => sym.dri
88+
}
8589
)
8690

8791
ctx.staticSiteContext.foreach(_.memberLinkResolver = driFor)

scaladoc/src/dotty/tools/scaladoc/tasty/comments/Comments.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ abstract class MarkupConversion[T](val repr: Repr)(using DocContext) {
8383

8484
object SymOps extends SymOps[qctx.type](qctx)
8585
export SymOps.dri
86+
export SymOps.driInContextOfInheritingParent
8687

8788
def resolveLink(queryStr: String): DocLink =
8889
if SchemeUri.matches(queryStr) then DocLink.ToURL(queryStr)
@@ -94,8 +95,11 @@ abstract class MarkupConversion[T](val repr: Repr)(using DocContext) {
9495
DocLink.UnresolvedDRI(queryStr, msg)
9596
case Right(query) =>
9697
MemberLookup.lookup(using qctx)(query, owner) match
97-
case Some((sym, targetText)) =>
98-
DocLink.ToDRI(sym.dri, targetText)
98+
case Some((sym, targetText, inheritingParent)) =>
99+
var dri = inheritingParent match
100+
case Some(parent) => sym.driInContextOfInheritingParent(parent)
101+
case None => sym.dri
102+
DocLink.ToDRI(dri, targetText)
99103
case None =>
100104
val txt = s"No DRI found for query"
101105
val msg = s"$txt: $queryStr"

0 commit comments

Comments
 (0)