Skip to content
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

Keep EnsoMultiValue as self when dispatching Any instance methods #12170

Merged
merged 13 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from 4 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
69 changes: 23 additions & 46 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5125,34 +5125,29 @@ launcherDistributionRoot := packageBuilder.localArtifact("launcher") / "enso"
projectManagerDistributionRoot :=
packageBuilder.localArtifact("project-manager") / "enso"

lazy val createEnginePackage =
taskKey[Unit]("Creates the engine distribution package")
createEnginePackage := {
lazy val createStdLibsIndexes =
taskKey[Unit]("Creates index files for standard libraries")
createStdLibsIndexes := {
updateLibraryManifests.value
buildEngineDistributionNoIndex.value
val modulesToCopy = componentModulesPaths.value
val root = engineDistributionRoot.value
val log = streams.value.log
val cacheFactory = streams.value.cacheStoreFactory
DistributionPackage.createEnginePackage(
distributionRoot = root,
cacheFactory = cacheFactory,
log = log,
jarModulesToCopy = modulesToCopy,
graalVersion = graalMavenPackagesVersion,
javaVersion = graalVersion,
ensoVersion = ensoVersion,
editionName = currentEdition,
sourceStdlibVersion = stdLibVersion,
targetStdlibVersion = targetStdlibVersion,
targetDir = (`syntax-rust-definition` / rustParserTargetDirectory).value,
generateIndex = true
)
log.info(s"Engine package created at $root")
val modulesToCopy = componentModulesPaths.value
val distributionRoot = engineDistributionRoot.value
val log = streams.value.log
val cacheFactory = streams.value.cacheStoreFactory

DistributionPackage.indexStdLibs(
stdLibVersion = targetStdlibVersion,
ensoVersion = ensoVersion,
stdLibRoot = distributionRoot / "lib",
ensoExecutable = distributionRoot / "bin" / "enso",
cacheFactory = cacheFactory.sub("stdlib"),
log = log
)
log.info(s"Standard library indexes create for $distributionRoot")
}

ThisBuild / createEnginePackage := {
createEnginePackage.result.value
ThisBuild / createStdLibsIndexes := {
createStdLibsIndexes.result.value
}

lazy val createEnginePackageNoIndex =
Expand All @@ -5174,8 +5169,7 @@ createEnginePackageNoIndex := {
editionName = currentEdition,
sourceStdlibVersion = stdLibVersion,
targetStdlibVersion = targetStdlibVersion,
targetDir = (`syntax-rust-definition` / rustParserTargetDirectory).value,
generateIndex = false
targetDir = (`syntax-rust-definition` / rustParserTargetDirectory).value
)
log.info(s"Engine package created at $root")
}
Expand All @@ -5199,25 +5193,7 @@ buildEngineDistributionNoIndex := Def.taskIf {
// of other tasks.
ThisBuild / buildEngineDistributionNoIndex := {
updateLibraryManifests.value
val modulesToCopy = componentModulesPaths.value
val root = engineDistributionRoot.value
val log = streams.value.log
val cacheFactory = streams.value.cacheStoreFactory
DistributionPackage.createEnginePackage(
distributionRoot = root,
cacheFactory = cacheFactory,
log = log,
jarModulesToCopy = modulesToCopy,
graalVersion = graalMavenPackagesVersion,
javaVersion = graalVersion,
ensoVersion = ensoVersion,
editionName = currentEdition,
sourceStdlibVersion = stdLibVersion,
targetStdlibVersion = targetStdlibVersion,
targetDir = (`syntax-rust-definition` / rustParserTargetDirectory).value,
generateIndex = false
)
log.info(s"Engine package created at $root")
createEnginePackageNoIndex.value
}

lazy val shouldBuildNativeImage = taskKey[Boolean](
Expand Down Expand Up @@ -5256,7 +5232,8 @@ lazy val buildEngineDistribution =
taskKey[Unit]("Builds the engine distribution")
buildEngineDistribution := {
buildEngineDistributionNoIndex.value
createEnginePackage.value
createEnginePackageNoIndex.value
createStdLibsIndexes.value
}

// This makes the buildEngineDistributionNoIndex task usable as a dependency
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,9 @@ public final Pair<Function, Type> resolveSymbol(
for (var t : EnsoMultiType.AllTypesWith.getUncached().executeAllTypes(dispatch, null, 0)) {
var fnAndType = node.execute(t, symbol);
if (fnAndType != null) {
if (fnAndType.getRight() == ctx.getBuiltins().any()) {
return fnAndType;
}
if (dispatch.typesLength() == 1 || fnAndType.getRight() != ctx.getBuiltins().any()) {
return Pair.create(fnAndType.getLeft(), t);
}
JaroslavTulach marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
14 changes: 1 addition & 13 deletions project/DistributionPackage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ object DistributionPackage {
editionName: String,
sourceStdlibVersion: String,
targetStdlibVersion: String,
targetDir: File,
generateIndex: Boolean
targetDir: File
): Unit = {
copyDirectoryIncremental(
file("distribution/engine/THIRD-PARTY"),
Expand Down Expand Up @@ -195,17 +194,6 @@ object DistributionPackage {
graalVersion = graalVersion,
javaVersion = javaVersion
)

if (generateIndex) {
indexStdLibs(
stdLibVersion = targetStdlibVersion,
ensoVersion = ensoVersion,
stdLibRoot = distributionRoot / "lib",
ensoExecutable = distributionRoot / "bin" / "enso",
cacheFactory = cacheFactory.sub("stdlib"),
log = log
)
}
}

def indexStdLibs(
Expand Down
6 changes: 6 additions & 0 deletions test/Base_Tests/src/Semantic/Multi_Value_Spec.enso
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ add_specs suite_builder =
c = Complex.new 1.5 0.0
(c:Complex).re . should_equal 1.5
(c:Float) . should_equal 1.5
group_builder.specify "Complex & Float remain after instance method invocation" <|
c = Complex.new 1.5 0.0 . confuse_me
(c:Complex).re . should_equal 1.5
(c:Float) . should_equal 1.5
radeusgd marked this conversation as resolved.
Show resolved Hide resolved

suite_builder.group "Chain Multi Value" group_builder->
to_b_to_c obj =
Expand Down Expand Up @@ -173,6 +177,8 @@ add_specs suite_builder =
Test.expect_panic Type_Error <|
a : C

Any.confuse_me self = self

main filter=Nothing =
suite = Test.build suite_builder->
add_specs suite_builder
Expand Down
Loading