Commit Graph

107 Commits

Author SHA1 Message Date
Gary Verhaegen
151e12b81a
bump copyright (#16002)
This is the result of:

- Updating `./COPY` to say `2023`.
- Running `./dev-env/bin/dade-copyright-headers update .`
2023-01-04 18:21:15 +01:00
Stephen Compall
99a48557d3
deprecate interface library names; use new names downstream (#14856)
* new names in daml-script/runner

* new names in json-api

* new names in Scala bindings/codegen

* new names in Java bindings/codegen

* new names in daml-lf interpreter tests

* more new names in daml-script tests

* new names in navigator backend

* deprecate all iface symbols and old method names

CHANGELOG_BEGIN
- [Scala API] ``com.daml.lf.iface`` has been deprecated, as discussed
  further in
  `issue #14783 <https://github.com/digital-asset/daml/pull/14783>`__.
  Use the deprecation warnings as guidance to the new names.
CHANGELOG_END

* prefix cases in OrderingSpec

- suggested by @remyhaemmerle-da; thanks
2022-08-29 20:43:47 +00:00
Stephen Compall
f43bc5c8d1
use new api-type-signature names in some dependents (#14785)
* use new names in json-api

* use new names in java codegen

* use new names in Scala codegen

* use new names in TypedValueGenerators

CHANGELOG_BEGIN
CHANGELOG_END
2022-08-23 17:52:10 +00:00
Stephen Compall
f85f7816c7
rename interface library to api-type-signature; alias symbols (#14783)
* move interface directory to api-type-signature; change bazel target; move scala files

* rename iface package to typesig; rename EnvironmentInterface to EnvironmentSignature

* rename Interface to PackageSignature

* rename fromReaderInterfaces to fromPackageSignatures

* rename InterfaceReader to SignatureReader

* rename InterfaceReader to SignatureReader in deprecation note

* rename readInterface to readPackageSignature

* rename InterfaceReaderError to Error

* rename InterfaceReaderMain to SignatureReaderMain

* rename InterfaceType to PackageSignature.TypeDecl

* rename astInterfaces to interfaces

* rename astInterfaces to interfaces in PackageSignature

* rename findAstInterface to findInterface

* rename a couple arguments

CHANGELOG_BEGIN
- [Scala API] The "quasi-public" API in ``com.daml.lf.iface`` has moved
  to the new ``com.daml.lf.typesig`` package, with many accompanying
  name changes as documented in `issue #13669
  <https://github.com/digital-asset/daml/issues/13669>`__.

  Daml 2.5.0 or later will remove the old names, and also rename the
  Maven artifact from ``daml-lf-interface`` to
  ``daml-lf-api-type-signature``.  We recommend that users of this API
  use the deprecation guidance in 2.4.0 to port their applications
  before this happens.
CHANGELOG_END
2022-08-23 15:21:45 +00:00
Moritz Kiefer
70d7482349
Support exercise without actor in Scala codegen (#14627)
* Support exercise without actor in Scala codegen

changelog_begin
changelog_end
2022-08-05 07:26:38 +00:00
Stephen Compall
d2c7be9dd8
interface views for daml-lf/interface library (#14569)
* add viewType to DefInterface
* interface view type resolvers
* in codegen, interfaces depend on their view types

CHANGELOG_BEGIN
CHANGELOG_END
2022-08-01 10:40:26 -04:00
Stephen Compall
6e3069d220
add retroImplements to lf/iface DefInterface (#14192)
* add resolveRetroImplements to EnvironmentInterface
* test that resolveRetroImplements does nothing with no data
* resolve retroactive interfaces in Java codegen
* resolve retroactive interfaces in Scala codegen
* resolve retroactive interfaces in json-api

CHANGELOG_BEGIN
CHANGELOG_END
2022-06-29 13:13:02 -04:00
Stephen Compall
4075389f92
remove inherited choices from Scala codegen, test interface/template IDs (#14113)
* inherited choices are gone, convert to interface
* use toInterface for conformance tests on interfaces

CHANGELOG_BEGIN
- [Scala codegen] Interface choices can no longer be invoked directly on
  template IDs, or via ``createAnd`` or ``key`` directly.  Instead, use
  ``toInterface[Ifn]`` before calling the relevant ``exercise*`` method.

  The resulting ledger commands now contain the correct interface ID
  rather than template ID for looking up the choice, but see #13993 for
  a caveat regarding create-and-exercise and exercise-by-key.
CHANGELOG_END
2022-06-08 08:37:56 -04:00
Stephen Compall
15b82efb87
toInterface and unsafeToTemplate in Scala codegen (#13991)
* Template.Implements marker, and toInterface for contract IDs
* unsafeToTemplate for interface contract IDs
* toInterface for create-and-exercise, exercise by key

CHANGELOG_BEGIN
- [Scala codegen] Template contract IDs and interface contract IDs have
  new coercion methods, ``toInterface`` and ``unsafeToTemplate``,
  respectively.

  ``toInterface`` can also be used with ``createAnd`` as well as ``key``
  for create-and-exercise and exercise-by-key respectively; however, see
  #13993 for a caveat regarding ledger API support.
CHANGELOG_END
2022-06-07 16:55:19 +00:00
Stephen Compall
4341130fe0
interface contract ID types in Scala codegen (#13975)
* define Interface and InterfaceCompanion parent classes
* generate package ID aliases for interface-only modules
* generate choice methods for interfaces
* include all interfaces in what to write from Scala codegen
* handle interface references in variance resolution

CHANGELOG_BEGIN
- [Scala codegen] Interface contract ID types, and references to them in
  serializable types, are now supported, as is exercise of interface
  choices on interface contract IDs.  To support this, ``DomainCommand``
  now includes a ``ContractTypeCompanion``, which may describe either a
  template or an interface, rather than a ``TemplateCompanion``.
CHANGELOG_END
2022-06-07 14:30:11 +00:00
Stephen Compall
eef97d04d2
remove inherited exercise methods from Java codegen (#14078)
* stop resolving in Java codegen, and use direct choices only
* wrong issue reference in Scala codegen

CHANGELOG_BEGIN
- [Java codegen] Direct invocation of interface exercise methods on
  templates is no longer supported, and the ``exercise*`` methods, which
  could generate invalid commands in some cases anyway, are removed.
  Use ``toInterface`` to access interface exercise methods.
CHANGELOG_END
2022-06-03 09:08:24 -04:00
Stephen Compall
96a6fe62e4
choice name overloading in lf/interface (#13938)
* introduce TemplateChoices to mediate template choice resolution
* if any resolutions fail in EnvironmentInterface, discard the template's resolution
* if any resolutions fail in Interface, discard the remaining unresolved

CHANGELOG_BEGIN
CHANGELOG_END
2022-05-31 08:41:48 -04:00
Stephen Compall
30e9b87279
minimal Scala codegen interface support (#13858)
* add inherited choices for Scala codegen, test output exercises

CHANGELOG_BEGIN
- [scala codegen] Choices inherited from interfaces may be exercised
  directly from those templates via ``createAnd``, contract ID, or
  exercise-by-key.  Exercise by interface-contract-ID and
  interface-contract-ID types in signatures are not supported.
  See `issue #13858 <https://github.com/digital-asset/daml/pull/13858>`__.
CHANGELOG_END
2022-05-12 08:03:00 -04:00
Nicu Reut
a792de39a5
Update scalafmt to 3.5.1. (#13584)
CHANGELOG_BEGIN
CHANGELOG_END
2022-04-28 09:57:04 +00:00
Stefano Baghino
10cd76a5d4
Add interface support to transitiveClosure (#13557)
* Remove unused field from `Node`

* Add interface support to `transitiveClosure`

Contributes to #13324

changelog_begin
changelog_end

This work can be reused to address #13349 and I left `TODO`s where appropriate.

* Address https://github.com/digital-asset/daml/pull/13557#discussion_r847434729

* Address https://github.com/digital-asset/daml/pull/13557#discussion_r847435412

* Turn the bulk of the logic of `transitiveClosure` into a smart constructor
2022-04-11 16:36:23 +00:00
Stefano Baghino
b245703b39
Refactor Java codegen (#13440)
* Remove unused class `JavaConf`

* Adapt tests to add template references for every type

* Minimize the data passed to `collectDamlLfInterfaces`

* Separate `CodeGen` from `CodeGenRunner`

* Refactor interfaces collection and resolution

* Refactor Java codegen

* Return `InterfaceType`s from `transitiveClosure`, move `DefTemplateWithRecord` to the Scala codegen

* Remove unused abstractions from the Java codegen

changelog_begin
changelog_end

* Minimize diff: move as much as possible to `CodeGenRunner`

* Revert "Adapt tests to add template references for every type"

This reverts commit 37c8c827179daa29668fa843c79afc8cef09e431.

* Fix compilation errors

* Minimize diff: restore imports in `ClassForType`

* Minimize diff: get rid of unnecessary refactorings

* Further simplications and fixing compilation errors

* Minimize diff: move `collectDamlLfInterfaces` back to its previous position

* Address https://github.com/digital-asset/daml/pull/13440#discussion_r846301958
2022-04-11 10:06:30 +00:00
Stefano Baghino
9d6eecaa4f
Refactoring codegen (#13439)
* Remove unused `name` field from `InterfaceTreeBuilder`, inline builder construction

* Remove unused `Traverse` instance for `TypeDeclOrTemplateWrapper`

* Remove unneccessary type parameter from `TypeDeclOrTemplateWrapper`

* Remove some unnecessary copies `.toList`

* Remove `TypeDeclOrTemplateWrapper`, use `Either` directly as a wrapper

* Use `bimap` instead of explicitly wrapping and unwrapping the `Either`

* Remove unnecessary type `Mode`

* Remove unnecessary type parameter from `WriteParams`

* Remove unnecessary binding

* Pull `OrderedDependencies` out of `Graph`

* Move computation of relevant packages to `codegen-common`

* Move `templateCount` from `LFUtil` into `CodeGen`

* Comment the purpose of `TransitiveClosure`

* Pull the variance cache out of `LFUtil`

`LFUtil`'s purpose is that of limiting passing around certain
values. While the purpose is questionable, the variance cache did
not need to access any of those values and it's quite easy to
move to a separate class where the purpose and the scope are clearer.

* Make `DependencyGraph` work directly on type declarations

* Add constructor for a collection of interfaces to `EnvironmentInterfaces`

* Factor the error message from `cyclicDependencies` out of `DependencyGraph`

changelog_begin
changelog_end
2022-03-29 16:29:22 +02:00
Stefano Baghino
50f0c568f4
Remove unneccesary generality from Scala codegen (#13372)
changelog_begin
changelog_end

Addresses https://github.com/digital-asset/daml/pull/13367#discussion_r832251452
2022-03-23 09:07:53 +00:00
Stefano Baghino
587d9abfc3
Standardize package for JVM codegen (#13370)
The Scala codegen code lives under `com.daml.codegen` but the common
library and the Java codegen both live under `com.daml.lf.codegen`.

In order to share code while preserving package private access of
certain facilities (i.e. `DependencyGraph`) the package needs to
be standardized. I chose to go the Java way mostly to reduce noise
on work currently on its way on the Java codegen (#13366).

Contributes towards https://github.com/digital-asset/daml/issues/13324

changelog_begin
changelog_end
2022-03-23 09:03:35 +01:00
Stefano Baghino
f4580aeeff
Move DependencyGraph from //language-support/scala/codegen to //language-support/codegen-common/ (#13367)
Move `DependencyGraph` from `//language-support/scala/codegen` to `//language-support/codegen-common/`

changelog_begin
changelog_end

The idea is that of re-using `DependencyGraph` for the Java codegen.

Builds on top of https://github.com/digital-asset/daml/pull/13361 and
contributes towards https://github.com/digital-asset/daml/issues/13324.
2022-03-22 12:36:46 -04:00
Stefano Baghino
452d37c6a1
Refactor Scala codegen: simplify by removing unnecessary abstractions (#13361)
* Refactor Scala codegen

changelog_begin
changelog_end

* Remove unnecessary abstractions

`DependencyGraph` and `LFUtil` both had an abstract superclass of
which they were the only implementation. Removing this unneccesary
layer of abstraction allows to avoid jumping between the superclass
and its concrete implementation to make sense of the overall meaning
of the code. Removing this layer also allows to find and remove
dead code and unused parameters.

* Throw away dead code around `BaseNode` and remove the unnecessary abstraction

* Throw away unused code

* Fix typo: unsopported -> unsupported

* Remove incorrect capitalization of type definitions

Before the refactoring, both `Util` and `LFUtil` had an implementation
of `toTypeDef` which were mostly matching, apart from the fact that
one capitalized its output while the other didn't. Apparently, I used
the wrong version and this broke existing code.
2022-03-22 13:39:13 +01:00
Stephen Compall
0b5ad7a7bd
interface support in the interface library (#13154)
This adds the presence of interface names, as well as lists of choices
and their argument/return types for each interface.

It also changes the semantics of DefTemplate and EnvironmentInterface:
each may contain "unresolved choices", which are the choices inherited
from interfaces for each implementing template;
EnvironmentInterface#resolveChoices will copy the full type information
as a concrete choice for each implementing template, which should be
much simpler for codegen and json-api.

A type generator should take account of the astInterfaces as well as
typeDecls in EnvironmentInterface; interfaces aren't included in
typeDecls because where I is an interface only ContractId I is
serializable.

* Ast.DataInterface is empty, just use the interfaces map directly
* port json-api for interface API changes; does not solve #12689
* port Scala codegen for interface API changes; does not add support
* port Java codegen for interface API changes; does not solve #11350

CHANGELOG_BEGIN
CHANGELOG_END
2022-03-15 19:34:54 +00:00
Stefano Baghino
f1cd4b1c7c
Remove dependencies on compatibility libraries (#12548)
Continues the work started in https://github.com/digital-asset/daml/pull/12543

These libraries were only needed to transition from Scala 2.12 to 2.13
and are no longer useful as all the necessary items are now available
in Scala 2.13.

changelog_begin
changelog_end
2022-01-24 18:04:07 +00:00
Stefano Baghino
aec3390904
Replace silencer plugin with built-in warning configuration (#12543)
Since Scala 2.13.2, Scala introduced built-in support to
manage warnings in a more granular fashion, thus making
the silencer plugin we are currently using no longer
strictly useful. Removing compiler plugins also removes
friction from migrating to Scala 3 in the future. As a
cherry on top, the built-in warning configuration also
allows to check whether a `@nowarn` actually does
anything, allowing us to proactively remove unused
warnings should the need arise.

[Here][1] is s a blog post by the Scala team about it.

Warnings have been either solved or preserved if useful,
trying to minimize the scope (keeping it at the single
expression scope if possible). In particular, all
remaining usages of the Scala Collection API compatibility
module have been removed.

Using the silencer plugin also apparently hid a few
remaining usages of compatibility libraries that were used
as part of the transition from Scala 2.12 to Scala 2.13
that are no longer needed. Removing those warnings
highlighted those.

changelog_begin
changelog_end

[1]: https://www.scala-lang.org/2021/01/12/configuring-and-suppressing-warnings.html
2022-01-24 15:01:35 +00:00
Gary Verhaegen
d2e2c21684
update copyright headers (#12240)
New year, new copyright, new expected unknown issues with various files
that won't be covered by the script and/or will be but shouldn't change.

I'll do the details on Jan 1, but would appreciate this being
preapproved so I can actually get it merged by then.

CHANGELOG_BEGIN
CHANGELOG_END
2022-01-03 16:36:51 +00:00
Stefano Baghino
42adfdc857
Get rid of deprecated components (#12167)
* Get rid of deprecated components

Removes:
- mentions of the Node.js bindings
- mentions of the Scala bindings
- usage of the Scala codegen as an SDK tool
- Java bindings "reactive components"

changelog_begin
The Node.js bindings are no longer supported as part of the Daml SDK
The Scala bindings are no longer supported as part of the Daml SDK
The Java bindings reactive components are no longer supported as part of the Daml SDK
The `daml codegen` command has dropped support for Scala
changelog_end

* Fix typo noticed by @cocreature

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>

* Address https://github.com/digital-asset/daml/pull/12167#issuecomment-995714093

* Remove quickstart-scala from the SDK tarballs

* Fix failing codegen test

* Address https://github.com/digital-asset/daml/pull/12167#pullrequestreview-833991243

Co-authored-by: Moritz Kiefer <moritz.kiefer@purelyfunctional.org>
2021-12-16 16:55:19 +00:00
Remy
58e69ade1a
LF: replace "dev" LF version by "1.dev" in bazel files (#11894)
the more consistent, as asked by Moritz in review of #11820

CHANGELOG_BEGIN
CHANGELOG_END
2021-11-26 12:23:17 +00:00
Moritz Kiefer
c8ace8b1cf
Factor kind projector target into a variable (#11759)
Seems nicer than trying to format a string everywhere

changelog_begin
changelog_end
2021-11-18 09:51:43 +01:00
nicu-da
9b2a8c7eb5
Enable top level statement blank lines scalafmt rule, which adds a blank line after imports (#11180)
CHANGELOG_BEGIN
CHANGELOG_END
2021-10-10 23:16:48 -07:00
Samir Talwar
4b8b67a1b5
Upgrade Scalatest to v3.2.9. (#10576)
* Upgrade Scalatest to v3.2.9.

Because of some coupling we also have to upgrade Scalaz to the latest
v7.2 point release, v7.2.33.

The Scalatest changes are quite involved because the JAR has been broken
up into several smaller JARs. Because Bazel expects us to specify all
dependencies and doesn't allow transitive dependencies to be used
directly, this means that we need to specify the explicit Scalatest
components that we use.

As you can imagine, this results in quite a big set of changes. They
are, however, constrained to dependency management; all the code remains
the same.

CHANGELOG_BEGIN
CHANGELOG_END

* http-json-oracle: Fix a Scalatest dependency.

* ledger-api-client: Fix a Scalatest dependency.
2021-08-12 23:19:35 +00:00
Remy
a8f190214c
LF: change type from Try to Either in archive module (#10277)
* LF: change type from Try to Either in archive module

This is the first part of restructuring errors in archive module.
This is part of #9974.

CHANGELOG_BEGIN
CHANGELOG_END

* Apply suggestions from code review

Co-authored-by: Stephen Compall <stephen.compall@daml.com>

* remove type alias

* apply stephen suggestion

* fix after rebase

* fix test

Co-authored-by: Stephen Compall <stephen.compall@daml.com>
2021-07-14 19:24:31 +00:00
Remy
906184ce1a
LF: Simplify UniversalDarReader (#10271)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-14 15:38:22 +02:00
Remy
6e8ec1d618
LF: Drop old depreated code (#10251)
CHANGELOG_BEGIN
CHANGELOG_END
2021-07-13 13:10:00 +00:00
Remy
41b8448b17
LF: Simplify archive reader. (#10208)
* LF: Simplify archive reader.

- decouple Reader and Decoder
- introduce case class to handle hash, proto payload, and version

CHANGELOG_BEGIN
CHANGELOG_END

* Address Moritz' review

* cosmetic
2021-07-07 19:56:40 +00:00
Samir Talwar
e7e8a5705b
daml-lf/data: Optionally truncate party names in structured logs. [KVL-996] (#10163)
* daml-lf/data: Truncate party names in log output, on request.

The party name can grow quite long, so we offer ledger implementors the
opportunity to truncate it in structured log output.

Unfortunately, because we use Logback through the global
`LoggerFactory`, there is no place to inject logging configuration. This
means we also need to use global, mutable state to configure logging
output. I have added a `LoggingConfiguration` class+object in Daml-LF
Data, which may not be the best place, but I can't think of a better
one right now. I suggest we leave it there until it has reason to grow,
at which point we may want to move it.

CHANGELOG_BEGIN
CHANGELOG_END

* logging-entries: Make `ToLoggingValue` mixin-able.

* participant-integration-api: Truncate parties in filters when logging.

* participant-integration-api: Cast to `Party` for logging.

Invalid input should not break the request at this point. No assertions.

* daml-lf/data: Move `Party to LoggingValue` to a new package.

This avoids the transitive dependency issue most of the time.

* daml-lf-data: Move the `Identifier` logging to another package.

Again, reduces the need for transitively depending on _logging-entries_.
2021-07-01 16:50:49 +00:00
Samir Talwar
5493e4e2b1
language-support/scala/codegen: Set the logging level to WARN. (#10165)
I don't find the output from Bazel very helpful most of the time. It
does, however, produce a lot of noise which I have to filter through
when something else goes wrong.

CHANGELOG_BEGIN
CHANGELOG_END
2021-07-01 16:49:46 +00:00
Samir Talwar
eda1245311
daml-lf/data: Add a conversion from Ref.Identifier to LoggingValue. (#10157)
I am getting quite tired of (Bazel + Scala)'s attitude to transitive
dependencies.

CHANGELOG_BEGIN
CHANGELOG_END
2021-06-30 20:05:06 +00:00
Stephen Compall
401069ef00
prepare for upgrade to Scalaz 7.3.3 (#9997)
* upgrade scalacheck to 1.14.3

* regenerate maven_install files

* some different names and implicits

* remove some fromTryCatchNonFatal

* more porting

* port fromTryCatchNonFatal to attempt

* factor the assertions in SignatureSpec to avoid \/

* deal with invariant \/

* make partial unification do what we want

* \/, parse*, and toNel

* many uses of the .right method

* a legitimate use of fromTryCatchThrowable

* rebuild maven pins

* further invariant \/

* OneAnd and Nel interface changes

* further Either games

* \/ and reformatting

* \/ in http-json

* \/ in http-json

* deprecations

* more invariance

* cleanup unused

* more invariance; http-json compiles

* final either follies

* small 2.12 extra incompatibility

* rebuild deps

* revisit a couple earlier fixes using nicer expressions I learned later

* no changelog

CHANGELOG_BEGIN
CHANGELOG_END

* repin 2.12
2021-06-15 14:41:48 -04:00
Moritz Kiefer
ab55fb2546
Handle module-prefixes in Java codegen (#9929)
* Handle module-prefixes in Java codegen

changelog_begin

- [Java Codegen] The Java codegen will now pick up the
  `module-prefixes` field from `daml.yaml` which can be used to handle
  module name collisions between different DALFs.

changelog_end

* Reference ticket in todos

changelog_begin
changelog_end

* less stupid map initialization

changelog_begin
changelog_end

* Pull out string assembly

changelog_begin
changelog_end

* Update language-support/java/codegen/src/main/scala/com/digitalasset/daml/lf/codegen/CodeGenRunner.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* Update language-support/java/codegen/src/main/scala/com/digitalasset/daml/lf/codegen/CodeGenRunner.scala

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>

* fewer views

changelog_begin
changelog_end

* more assert

changelog_begin
changelog_end

* more private

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end

* fix scala 2.12

changelog_begin
changelog_end

Co-authored-by: Stefano Baghino <43749967+stefanobaghino-da@users.noreply.github.com>
2021-06-09 07:31:28 +00:00
Moritz Kiefer
850c7310e8
Include PackageMetadata in LF interface (#9892)
* Include PackageMetadata in LF interface

I want to use this in codegens but more generally, I think it also
fits well into the scope of the iface library in that it’s only
metadata and relatively stable.

changelog_begin
changelog_end

* Iterating more is less

changelog_begin
changelog_end

* fix tests

changelog_begin
changelog_end

* fmt

changelog_begin
changelog_end

* fix scala 2.12

changelog_begin
changelog_end
2021-06-03 09:06:23 +00:00
Miklos
cd9933328a
runtime: Damlification of Scala files (#9668)
CHANGELOG_BEGIN
CHANGELOG_END
2021-05-17 10:28:50 +02:00
Stephen Compall
ca9e89b3da
check whether collection.compat is unused when compiling for Scala 2.12 (#9604)
* check whether collection.compat is unused when compiling for Scala 2.12

- Instead of always suppressing warnings for collection.compat._,
  we should only do it for Scala 2.13

- We can also reduce boilerplate by automatically adding this
  option when both silencer_plugin and collection-compat are
  present

CHANGELOG_BEGIN
CHANGELOG_END

* remove unused import

* remove another unused import

* remove even more unused imports

* missed compat dependency

* more missed compat dependencies

* missed compat dependency

* use scala_deps in scaladoc_jar

- #8423 inlined the major version expansion, but this seems to
  have been prior to proper support by scaladoc_jar

* restore custom handling of participant-integration-api

- fixing scaladoc_jar isn't worth it for a single case, as with
  deps vs scala_deps
2021-05-11 21:54:14 +00:00
Samir Talwar
e1af564bcc
Switch from @silent to @nowarn. (#9498)
* Switch from `@silent` to `@nowarn`.

This annotation is native to Scala 2.12.13+ and 2.13.2+. It replaces
most usages of `@silent`.

I had to get creative about a couple of use cases that didn't work.
Specifically:

  1.  Suppressing deprecation warnings works, but Scala 2.12 erroneously
      complains that the `@nowarn` is unnecessary.  I had to suppress
      this warning too with `-Ywarn-unused:-nowarn`.
  2.  I can't seem to suppress the warning, "The outer reference in this
      type test cannot be checked at run time." Instead, I have
      refactored the code to remove the warning.

We still need to use the silencer plugin to suppress some warnings about
unused imports (because of compatibility between Scala 2.12 and 2.13),
but this means we no longer need the library, and therefore it is not a
transitive dependency that downstream consumers need to worry about.

CHANGELOG_BEGIN
CHANGELOG_END

* Add some comments around `@nowarn` support.

* language-support/scala: Fix a warning suppression.

* Revert to the default warnings.

Compatibility was complaining.
2021-04-26 19:46:14 +00:00
Stephen Compall
a6da995ecb
use representational variance for generated Scala classes (#8879)
* variance calculation without references or cycles

* an idea for handling the recursive reference case elegantly

* extra data for resolving constraints from [recursive] references later

* note on TypeVar case

* trying a different delayed resolution

* quagmire

* the problem: we were trying to solve too early and mix reference levels

* force inner delays to be pulled out; squash the delays iteratively

* make the variance result accessible

* phantoms are covariant

* scalafmt

* simplest GenMap test

* reference tests

* factoring

* don't treat covariant reference arguments as phantom

* making the wrong reference in delays was breaking solve steps

* test cons list self-recursion

* more recursion testing

* -> is better for 2-tuples here

* test cumulative variance tracking

* uninhabited types have variance too

* test mutual recursion with lots of indirect references

* trigger for failing case in incremental resolution

* redesign delayed constraints to handle nesting properly, and be much simpler

* integrate variance calculation with rest of Scala codegen

* handle concrete type and all-phantoms cases; test

* add integration test for variance inference

* add changelog

CHANGELOG_BEGIN
- [Scala Codegen] Type parameters used in GenMap keys are now supported.
  See `issue #8879 <https://github.com/digital-asset/daml/pull/8879>`__.
CHANGELOG_END

* proper doc for covariantVars

- suggested by @cocreature; thanks

* remove useless local var

- suggested by @cocreature; thanks

* add another recursive function to capture more invariants

- suggested by @cocreature; thanks

* absence in what

- suggested by @cocreature; thanks

* use Identifier instead of I

- suggested by @cocreature; thanks

* remove unused type vars; make goSdt cleaner

* also precache variance of choice and key-referenced types

- suggested by @cocreature; thanks
2021-03-17 16:47:18 +00:00
Stephen Compall
52c5054568
qualify Set in Scala codegen output to avoid name collision (#8868)
CHANGELOG_BEGIN
- [Scala codegen] Allow codegen with Set.
  See `issue #8854 <https://github.com/digital-asset/daml/issues/8854>`__.
CHANGELOG_END
2021-02-17 07:51:41 +00:00
Moritz Kiefer
f02e0fe42b
Generate Scala code compatible with Scala 2.13 (#8841)
fixes #8498

This fixes the error in 2.13 wtr to the location change of Predef. It
doesn’t yet address the warning wtr to the import of higherKinds. For
now, our build ignores that warning. Trying to figure out if we can
get away with a breaking change here or if we need to hide that change
behind a flag but either way, no need to block fixing the actual error
on that.

changelog_begin
changelog_end
2021-02-15 09:06:40 +01:00
Moritz Kiefer
22ce940954
Upgrade scalafmt and enable trailing commas (#8437)
This PR updates scalafmt and enables trailingCommas =
multiple. Unfortunately, scalafmt broke the version field which means
we cannot fully preserve the rest of the config. I’ve made some
attempts to stay reasonably close to the original config but couldn’t
find an exact equivalent in a lot of cases. I don’t feel strongly
about any of the settings so happy to change them to something else.

As announced, this will be merged on Saturday to avoid too many conflicts.

changelog_begin
changelog_end
2021-01-09 11:37:37 +01:00
Moritz Kiefer
3a8f5e8aaa
Port //language-support/scala to Scala 2.13 (#8442)
The one thing that is still missing is making the generated Scala code
from the codegen compatible with Scala 2.13 so the examples are
excluded for now.

changelog_begin
changelog_end
2021-01-08 20:28:15 +01:00
Bernhard Elsner
cda93db944
Daml case and logo (#8433)
* Replace many occurrences of DAML with Daml

* Update docs logo

* A few more CLI occurrences

CHANGELOG_BEGIN
- Change DAML capitalization and docs logo
CHANGELOG_END

* Fix some over-eager replacements

* A few mor occurrences in md files

* Address comments in *.proto files

* Change case in comments and strings in .ts files

* Revert changes to frozen proto files

* Also revert LF 1.11

* Update get-daml.sh

* Update windows installer

* Include .py files

* Include comments in .daml files

* More instances in the assistant CLI

* some more help texts
2021-01-08 12:50:15 +00:00
Gary Verhaegen
a925f0174c
update copyright notices for 2021 (#8257)
* update copyright notices for 2021

To be merged on 2021-01-01.

CHANGELOG_BEGIN
CHANGELOG_END

* patch-bazel-windows & da-ghc-lib
2021-01-01 19:49:51 +01:00