Skip to content

Backport "fix: update scala-cli.jar path" to 3.6 #22274

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

Merged
merged 7 commits into from
Dec 30, 2024
Merged
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
16 changes: 12 additions & 4 deletions compiler/src/dotty/tools/dotc/config/PathResolver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,25 @@ object PathResolver {
/** Values found solely by inspecting environment or property variables.
*/
object Environment {
private def searchForBootClasspath = (
systemProperties find (_._1 endsWith ".boot.class.path") map (_._2) getOrElse ""
)
private def searchForBootClasspath = {
import scala.jdk.CollectionConverters.*
val props = System.getProperties
// This formulation should be immune to ConcurrentModificationExceptions when system properties
// we're unlucky enough to witness a partially published result of System.setProperty or direct
// mutation of the System property map. stringPropertyNames internally uses the Enumeration interface,
// rather than Iterator, and this disables the fail-fast ConcurrentModificationException.
val propNames = props.stringPropertyNames()
propNames.asScala collectFirst { case k if k endsWith ".boot.class.path" => props.getProperty(k) } getOrElse ""
}

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

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

def javaExtDirs: String = propOrEmpty("java.ext.dirs")
def scalaHome: String = propOrEmpty("scala.home")
Expand Down
25 changes: 13 additions & 12 deletions compiler/src/dotty/tools/dotc/typer/RefChecks.scala
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,6 @@ object RefChecks {

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

if !member.hasTargetName(other.targetName) then
Expand Down Expand Up @@ -1169,16 +1168,18 @@ object RefChecks {
target.nonPrivateMember(sym.name)
.filterWithPredicate:
member =>
val memberIsImplicit = member.info.hasImplicitParams
val paramTps =
if memberIsImplicit then methTp.stripPoly.firstParamTypes
else methTp.firstExplicitParamTypes

paramTps.isEmpty || memberIsImplicit && !methTp.hasImplicitParams || {
val memberParamTps = member.info.stripPoly.firstParamTypes
!memberParamTps.isEmpty
&& memberParamTps.lengthCompare(paramTps) == 0
&& memberParamTps.lazyZip(paramTps).forall((m, x) => x frozen_<:< m)
member.symbol.isPublic && {
val memberIsImplicit = member.info.hasImplicitParams
val paramTps =
if memberIsImplicit then methTp.stripPoly.firstParamTypes
else methTp.firstExplicitParamTypes

paramTps.isEmpty || memberIsImplicit && !methTp.hasImplicitParams || {
val memberParamTps = member.info.stripPoly.firstParamTypes
!memberParamTps.isEmpty
&& memberParamTps.lengthCompare(paramTps) == 0
&& memberParamTps.lazyZip(paramTps).forall((m, x) => x frozen_<:< m)
}
}
.exists
if !target.typeSymbol.denot.isAliasType && !target.typeSymbol.denot.isOpaqueAlias && hidden
Expand Down
2 changes: 1 addition & 1 deletion dist/libexec/cli-common-platform
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

SCALA_CLI_CMD_BASH=("\"$JAVACMD\"" "-jar \"$PROG_HOME/bin/scala-cli.jar\"")
SCALA_CLI_CMD_BASH=("\"$JAVACMD\"" "-jar \"$PROG_HOME/libexec/scala-cli.jar\"")
2 changes: 1 addition & 1 deletion dist/libexec/cli-common-platform.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

@rem we need to escape % in the java command path, for some reason this doesnt work in common.bat
set "_JAVACMD=!_JAVACMD:%%=%%%%!"
set SCALA_CLI_CMD_WIN="%_JAVACMD%" "-jar" "%_PROG_HOME%\bin\scala-cli.jar"
set SCALA_CLI_CMD_WIN="%_JAVACMD%" "-jar" "%_PROG_HOME%\libexec\scala-cli.jar"
17 changes: 17 additions & 0 deletions tests/warn/i21816.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

case class CC(a: String, b: String) extends Iterable[String] {
override def iterator: Iterator[String] = Iterator(a, b)
}

trait T {
extension (cc: CC) def className: String = "foo"
}

object O extends T {
def foo = {
val cc = CC("a", "b")
println(cc.className)
}
}

@main def main() = O.foo
Loading