From fec567fa76a7c3708812729308a50120788ffdbb Mon Sep 17 00:00:00 2001 From: Jon Ross-Perkins Date: Mon, 11 Mar 2024 10:59:55 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Chandler Carruth --- proposals/p3762.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/proposals/p3762.md b/proposals/p3762.md index 7dd06283aa74d..6e54374c846c8 100644 --- a/proposals/p3762.md +++ b/proposals/p3762.md @@ -43,7 +43,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception ## Abstract - Add the `extern` keyword for forward declarations in libraries that don't - have the definition. + provide the definition. - Treat repeated forward declarations as redundant. - Allow them when they prevent a dependence on an imported name. - Clarify rules for when modifier keywords should be on forward declarations @@ -248,7 +248,7 @@ import library "a"; fn Foo(c: C); -// Invalid: `F` used the imported `C`, so an `extern` declaration of `C` is now +// Invalid: `Foo` used the imported `C`, so an `extern` declaration of `C` is now // invalid. extern class C; ``` @@ -304,16 +304,20 @@ For example: class C { class D; - fn F(); + fn F() -> D; + class D { - fn G() { return C.F(); } + fn G() -> Self { return C.F(); } + + var x: i32; } - fn F() { D.G(); } + + fn F() -> D { return {.x = 42}; } } ``` This is necessary because type bodies are not automatically moved out-of-line, -unlike function types. +unlike function bodies. ### Merging `extern` declarations @@ -330,7 +334,7 @@ different imported libraries): For a new declaration in the importing file, an imported `extern` declaration is always superseded. It is invalid to use the imported declaration before the new declaration. It is considered the same entity for type checking, but diagnostics -will lean towards the local definition. +should use the local definition. For a new declaration in the importing file, an imported non-`extern` declaration will: