diff --git a/src/dmd/attrib.d b/src/dmd/attrib.d index aae4c7ff93cb..ee0c26d5007a 100644 --- a/src/dmd/attrib.d +++ b/src/dmd/attrib.d @@ -538,8 +538,13 @@ extern (C++) final class ProtDeclaration : AttribDeclaration super(decl); this.loc = loc; this.protection.kind = Prot.Kind.package_; - this.protection.pkg = null; this.pkg_identifiers = pkg_identifiers; + if (pkg_identifiers !is null && pkg_identifiers.dim > 0) + { + Dsymbol tmp; + Package.resolve(pkg_identifiers, &tmp, null); + protection.pkg = tmp ? tmp.isPackage() : null; + } } override Dsymbol syntaxCopy(Dsymbol s) diff --git a/test/compilable/extra-files/header18364.di b/test/compilable/extra-files/header18364.di new file mode 100644 index 000000000000..64d8ad073cf5 --- /dev/null +++ b/test/compilable/extra-files/header18364.di @@ -0,0 +1,6 @@ +module foo.bar.ba; +nothrow pure @nogc @safe package(foo) +{ + void foo(); + nothrow pure @nogc @safe package(foo.bar) void foo2(); +} diff --git a/test/compilable/header18364.d b/test/compilable/header18364.d new file mode 100644 index 000000000000..9ed8a5160928 --- /dev/null +++ b/test/compilable/header18364.d @@ -0,0 +1,8 @@ +// REQUIRED_ARGS: -c -o- -Hf${RESULTS_DIR}/compilable/header18364.di +// POST_SCRIPT: compilable/extra-files/header-postscript.sh header18364 +module foo.bar.ba; +@safe pure nothrow @nogc package(foo): +void foo(); + +@safe pure nothrow @nogc package(foo.bar): +void foo2();