From 690ec2f061a8f249f0007207850efd80a2852b86 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 9 Dec 2019 11:37:11 +0100 Subject: [PATCH 1/2] Fix #7700: Export forwarders of inline methods are themselves inline --- compiler/src/dotty/tools/dotc/core/Flags.scala | 2 +- docs/docs/reference/other-new-features/export.md | 2 +- tests/pos/i7700.scala | 12 ++++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 tests/pos/i7700.scala diff --git a/compiler/src/dotty/tools/dotc/core/Flags.scala b/compiler/src/dotty/tools/dotc/core/Flags.scala index 1ac658387520..e0d60cd5d7f5 100644 --- a/compiler/src/dotty/tools/dotc/core/Flags.scala +++ b/compiler/src/dotty/tools/dotc/core/Flags.scala @@ -507,7 +507,7 @@ object Flags { val RetainedModuleClassFlags: FlagSet = RetainedModuleValAndClassFlags | Enum /** Flags retained in export forwarders */ - val RetainedExportFlags = Given | Implicit | Extension + val RetainedExportFlags = Given | Implicit | Extension | Inline /** Flags that apply only to classes */ val ClassOnlyFlags = Sealed | Open | Abstract.toTypeFlags diff --git a/docs/docs/reference/other-new-features/export.md b/docs/docs/reference/other-new-features/export.md index 5340ca45baa2..732b4058e618 100644 --- a/docs/docs/reference/other-new-features/export.md +++ b/docs/docs/reference/other-new-features/export.md @@ -70,7 +70,7 @@ It is a compile-time error if a simple or renaming selector does not identify an members. Type members are aliased by type definitions, and term members are aliased by method definitions. Export aliases copy the type and value parameters of the members they refer to. -Export aliases are always `final`. Aliases of given instances are again defined as givens (and aliases of old-style implicits are `implicit`). There are no other modifiers that can be given to an alias. This has the following consequences for overriding: +Export aliases are always `final`. Aliases of given instances are again defined as givens (and aliases of old-style implicits are `implicit`). Aliases of inline methods or values are again defined `inline`. There are no other modifiers that can be given to an alias. This has the following consequences for overriding: - Export aliases cannot be overridden, since they are final. - Export aliases cannot override concrete members in base classes, since they are diff --git a/tests/pos/i7700.scala b/tests/pos/i7700.scala new file mode 100644 index 000000000000..913285822c31 --- /dev/null +++ b/tests/pos/i7700.scala @@ -0,0 +1,12 @@ +package test + +trait Show[-A] + def show(a: A): String + +object Macros + inline def (sc: StringContext) show(args: =>Any*): String = ??? + +object Show + def[A] (a: A) show(given S: Show[A]): String = S.show(a) + + export Macros.show \ No newline at end of file From 56cfeb961b7c79f05bc11e4d857a8a7704304cef Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 10 Dec 2019 13:43:00 +0100 Subject: [PATCH 2/2] Remove stale brace --- docs/docs/reference/other-new-features/export.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/docs/reference/other-new-features/export.md b/docs/docs/reference/other-new-features/export.md index 732b4058e618..20c56ecc50be 100644 --- a/docs/docs/reference/other-new-features/export.md +++ b/docs/docs/reference/other-new-features/export.md @@ -119,7 +119,6 @@ class B { val c: Int } object a { val b = new B } export a._ export b._ -} ``` Is the `export b._` clause legal? If yes, what does it export? Is it equivalent to `export a.b._`? What about if we swap the last two clauses? ```