Skip to content

Commit 556e916

Browse files
Backport "fix: update scala-cli.jar path" to 3.6 (#22274)
Backports #22185 to the 3.6.3. PR submitted by the release tooling. [skip ci]
2 parents c3cff52 + d31b1b2 commit 556e916

File tree

5 files changed

+44
-18
lines changed

5 files changed

+44
-18
lines changed

compiler/src/dotty/tools/dotc/config/PathResolver.scala

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,25 @@ object PathResolver {
3636
/** Values found solely by inspecting environment or property variables.
3737
*/
3838
object Environment {
39-
private def searchForBootClasspath = (
40-
systemProperties find (_._1 endsWith ".boot.class.path") map (_._2) getOrElse ""
41-
)
39+
private def searchForBootClasspath = {
40+
import scala.jdk.CollectionConverters.*
41+
val props = System.getProperties
42+
// This formulation should be immune to ConcurrentModificationExceptions when system properties
43+
// we're unlucky enough to witness a partially published result of System.setProperty or direct
44+
// mutation of the System property map. stringPropertyNames internally uses the Enumeration interface,
45+
// rather than Iterator, and this disables the fail-fast ConcurrentModificationException.
46+
val propNames = props.stringPropertyNames()
47+
propNames.asScala collectFirst { case k if k endsWith ".boot.class.path" => props.getProperty(k) } getOrElse ""
48+
}
4249

4350
/** Environment variables which java pays attention to so it
4451
* seems we do as well.
4552
*/
4653
def classPathEnv: String = envOrElse("CLASSPATH", "")
4754
def sourcePathEnv: String = envOrElse("SOURCEPATH", "")
4855

49-
def javaBootClassPath: String = propOrElse("sun.boot.class.path", searchForBootClasspath)
56+
//using propOrNone/getOrElse instead of propOrElse so that searchForBootClasspath is lazy evaluated
57+
def javaBootClassPath: String = propOrNone("sun.boot.class.path") getOrElse searchForBootClasspath
5058

5159
def javaExtDirs: String = propOrEmpty("java.ext.dirs")
5260
def scalaHome: String = propOrEmpty("scala.home")

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,6 @@ object RefChecks {
525525

526526
// todo: align accessibility implication checking with isAccessible in Contexts
527527
def isOverrideAccessOK =
528-
val memberIsPublic = (member.flags & AccessFlags).isEmpty && !member.privateWithin.exists
529528
def protectedOK = !other.is(Protected) || member.is(Protected) // if o is protected, so is m
530529
def accessBoundaryOK =
531530
val ob = other.accessBoundary(member.owner)
@@ -534,7 +533,7 @@ object RefChecks {
534533
def companionBoundaryOK = ob.isClass && !ob.isLocalToBlock && mb.is(Module) && (ob.companionModule eq mb.companionModule)
535534
ob.isContainedIn(mb) || companionBoundaryOK // m relaxes o's access boundary,
536535
def otherIsJavaProtected = other.isAllOf(JavaProtected) // or o is Java defined and protected (see #3946)
537-
memberIsPublic || protectedOK && (accessBoundaryOK || otherIsJavaProtected)
536+
member.isPublic || protectedOK && (accessBoundaryOK || otherIsJavaProtected)
538537
end isOverrideAccessOK
539538

540539
if !member.hasTargetName(other.targetName) then
@@ -1169,16 +1168,18 @@ object RefChecks {
11691168
target.nonPrivateMember(sym.name)
11701169
.filterWithPredicate:
11711170
member =>
1172-
val memberIsImplicit = member.info.hasImplicitParams
1173-
val paramTps =
1174-
if memberIsImplicit then methTp.stripPoly.firstParamTypes
1175-
else methTp.firstExplicitParamTypes
1176-
1177-
paramTps.isEmpty || memberIsImplicit && !methTp.hasImplicitParams || {
1178-
val memberParamTps = member.info.stripPoly.firstParamTypes
1179-
!memberParamTps.isEmpty
1180-
&& memberParamTps.lengthCompare(paramTps) == 0
1181-
&& memberParamTps.lazyZip(paramTps).forall((m, x) => x frozen_<:< m)
1171+
member.symbol.isPublic && {
1172+
val memberIsImplicit = member.info.hasImplicitParams
1173+
val paramTps =
1174+
if memberIsImplicit then methTp.stripPoly.firstParamTypes
1175+
else methTp.firstExplicitParamTypes
1176+
1177+
paramTps.isEmpty || memberIsImplicit && !methTp.hasImplicitParams || {
1178+
val memberParamTps = member.info.stripPoly.firstParamTypes
1179+
!memberParamTps.isEmpty
1180+
&& memberParamTps.lengthCompare(paramTps) == 0
1181+
&& memberParamTps.lazyZip(paramTps).forall((m, x) => x frozen_<:< m)
1182+
}
11821183
}
11831184
.exists
11841185
if !target.typeSymbol.denot.isAliasType && !target.typeSymbol.denot.isOpaqueAlias && hidden

dist/libexec/cli-common-platform

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
SCALA_CLI_CMD_BASH=("\"$JAVACMD\"" "-jar \"$PROG_HOME/bin/scala-cli.jar\"")
3+
SCALA_CLI_CMD_BASH=("\"$JAVACMD\"" "-jar \"$PROG_HOME/libexec/scala-cli.jar\"")

dist/libexec/cli-common-platform.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
@rem we need to escape % in the java command path, for some reason this doesnt work in common.bat
44
set "_JAVACMD=!_JAVACMD:%%=%%%%!"
5-
set SCALA_CLI_CMD_WIN="%_JAVACMD%" "-jar" "%_PROG_HOME%\bin\scala-cli.jar"
5+
set SCALA_CLI_CMD_WIN="%_JAVACMD%" "-jar" "%_PROG_HOME%\libexec\scala-cli.jar"

tests/warn/i21816.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
case class CC(a: String, b: String) extends Iterable[String] {
3+
override def iterator: Iterator[String] = Iterator(a, b)
4+
}
5+
6+
trait T {
7+
extension (cc: CC) def className: String = "foo"
8+
}
9+
10+
object O extends T {
11+
def foo = {
12+
val cc = CC("a", "b")
13+
println(cc.className)
14+
}
15+
}
16+
17+
@main def main() = O.foo

0 commit comments

Comments
 (0)