Merge: Force standard as public
authorJean Privat <jean@pryen.org>
Mon, 17 Nov 2014 22:55:25 +0000 (17:55 -0500)
committerJean Privat <jean@pryen.org>
Mon, 17 Nov 2014 22:55:25 +0000 (17:55 -0500)
Standard me become privately imported when importing only modules privately.
Thus, some sub-modules cannot see standard.

This PR force standard to be always public if it is imported.

Close #909

Pull-Request: #913
Reviewed-by: Lucas Bajolet <r4pass@hotmail.com>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

src/modelbuilder.nit
tests/base_import_standard.nit [new file with mode: 0644]
tests/base_import_standard2.nit [new file with mode: 0644]
tests/sav/base_import_standard.res [new file with mode: 0644]
tests/sav/base_import_standard2.res [new file with mode: 0644]

index 83f5e0e..1ae7e45 100644 (file)
@@ -705,6 +705,13 @@ class ModelBuilder
                self.toolcontext.info("{mmodule} imports {imported_modules.join(", ")}", 3)
                mmodule.set_imported_mmodules(imported_modules)
 
+               # Force standard to be public if imported
+               for sup in mmodule.in_importation.greaters do
+                       if sup.name == "standard" then
+                               mmodule.set_visibility_for(sup, public_visibility)
+                       end
+               end
+
                # TODO: Correctly check for useless importation
                # It is even doable?
                var directs = mmodule.in_importation.direct_greaters
diff --git a/tests/base_import_standard.nit b/tests/base_import_standard.nit
new file mode 100644 (file)
index 0000000..2e76488
--- /dev/null
@@ -0,0 +1,17 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+private import template
+
+print 1
diff --git a/tests/base_import_standard2.nit b/tests/base_import_standard2.nit
new file mode 100644 (file)
index 0000000..da5111e
--- /dev/null
@@ -0,0 +1,17 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import base_import_standard
+
+print 2
diff --git a/tests/sav/base_import_standard.res b/tests/sav/base_import_standard.res
new file mode 100644 (file)
index 0000000..d00491f
--- /dev/null
@@ -0,0 +1 @@
+1
diff --git a/tests/sav/base_import_standard2.res b/tests/sav/base_import_standard2.res
new file mode 100644 (file)
index 0000000..0cfbf08
--- /dev/null
@@ -0,0 +1 @@
+2