SLING-9657 - Same-name JS Use dependencies are not always correctly resolved

* added a test structure for overlays
diff --git a/src/main/resources/SLING-INF/apps/sightly/scripts/inherit.json b/src/main/resources/SLING-INF/apps/sightly/scripts/inherit.json
new file mode 100644
index 0000000..fc13874
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightly/scripts/inherit.json
@@ -0,0 +1,3 @@
+{
+    "sling:resourceSuperType": "sightly/scripts/base"
+}
diff --git a/src/main/resources/SLING-INF/libs/sightly/scripts/base/base.html b/src/main/resources/SLING-INF/libs/sightly/scripts/base/base.html
new file mode 100644
index 0000000..e4b55c0
--- /dev/null
+++ b/src/main/resources/SLING-INF/libs/sightly/scripts/base/base.html
@@ -0,0 +1,19 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<div class="base" data-sly-include="include.html"></div>
diff --git a/src/main/resources/SLING-INF/libs/sightly/scripts/base/base.js b/src/main/resources/SLING-INF/libs/sightly/scripts/base/base.js
new file mode 100644
index 0000000..6f32287
--- /dev/null
+++ b/src/main/resources/SLING-INF/libs/sightly/scripts/base/base.js
@@ -0,0 +1,23 @@
+/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements.  See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership.  The ASF licenses this file
+ ~ to you 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.
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
+use(function() {
+    return {
+        message: 'base.js'
+    }
+});
diff --git a/src/main/resources/SLING-INF/libs/sightly/scripts/base/include.html b/src/main/resources/SLING-INF/libs/sightly/scripts/base/include.html
new file mode 100644
index 0000000..26f7bd0
--- /dev/null
+++ b/src/main/resources/SLING-INF/libs/sightly/scripts/base/include.html
@@ -0,0 +1,19 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<div class="include" data-sly-use.base="base.js">${base.message}</div>
diff --git a/src/main/resources/SLING-INF/libs/sightly/scripts/inherit.json b/src/main/resources/SLING-INF/libs/sightly/scripts/inherit.json
new file mode 100644
index 0000000..fc13874
--- /dev/null
+++ b/src/main/resources/SLING-INF/libs/sightly/scripts/inherit.json
@@ -0,0 +1,3 @@
+{
+    "sling:resourceSuperType": "sightly/scripts/base"
+}
diff --git a/src/main/resources/SLING-INF/libs/sightly/scripts/inherit/include.html b/src/main/resources/SLING-INF/libs/sightly/scripts/inherit/include.html
new file mode 100644
index 0000000..4285be4
--- /dev/null
+++ b/src/main/resources/SLING-INF/libs/sightly/scripts/inherit/include.html
@@ -0,0 +1,19 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<div class="include-inherit" data-sly-use.base="base.js">${base.message}</div>
diff --git a/src/main/resources/SLING-INF/sightly.json b/src/main/resources/SLING-INF/sightly.json
index 0d8ac4b..d7dbde6 100644
--- a/src/main/resources/SLING-INF/sightly.json
+++ b/src/main/resources/SLING-INF/sightly.json
@@ -71,6 +71,10 @@
     "synthetic-resource": {
         "jcr:primaryType": "nt:unstructured",
         "sling:resourceType": "/apps/sightly/scripts/syntheticresourcecaller"
+    },
+    "inherit": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "sightly/scripts/inherit"
     }
 
 }