File tree 2 files changed +28
-1
lines changed
compiler/src/dotty/tools/dotc/parsing
tests/sjs-junit/test/org/scalajs/testsuite/compiler 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -1725,7 +1725,8 @@ object Parsers {
1725
1725
*/
1726
1726
def simpleType (): Tree =
1727
1727
if isSimpleLiteral then
1728
- SingletonTypeTree (simpleLiteral())
1728
+ val lit = simpleLiteral()
1729
+ SingletonTypeTree (lit).withSpan(lit.span)
1729
1730
else if in.token == USCORE then
1730
1731
if ctx.settings.YkindProjector .value == " underscores" then
1731
1732
val start = in.skipToken()
Original file line number Diff line number Diff line change @@ -78,6 +78,18 @@ class RegressionTestScala3 {
78
78
val f3 = { () => i += 1 }
79
79
assertSame(f3, Thunk .asFunction0(f3()))
80
80
}
81
+
82
+ @ Test def literalTypeJSNativeIssue16173 (): Unit = {
83
+ js.eval("""
84
+ var RegressionTestScala3_Issue16173_foo = "constant";
85
+ var RegressionTestScala3_Issue16173_bar = function() { return 5; };
86
+ """ )
87
+
88
+ assertEquals(" constant" , Issue16173 .foo1)
89
+ assertEquals(" constant" , Issue16173 .foo2)
90
+
91
+ assertEquals(5 , Issue16173 .bar1())
92
+ }
81
93
}
82
94
83
95
object RegressionTestScala3 {
@@ -148,6 +160,20 @@ object RegressionTestScala3 {
148
160
val entries = js.Object .entries(obj)
149
161
val js .Tuple2 (k, v) = entries(0 ): @ unchecked
150
162
}
163
+
164
+ object Issue16173 {
165
+ @ js.native
166
+ @ JSGlobal (" RegressionTestScala3_Issue16173_foo" )
167
+ val foo1 : " constant" = js.native
168
+
169
+ @ js.native
170
+ @ JSGlobal (" RegressionTestScala3_Issue16173_foo" )
171
+ def foo2 : " constant" = js.native
172
+
173
+ @ js.native
174
+ @ JSGlobal (" RegressionTestScala3_Issue16173_bar" )
175
+ def bar1 (): 5 = js.native
176
+ }
151
177
}
152
178
153
179
// This class needs to be at the top-level, not in an object, to reproduce the issue
You can’t perform that action at this time.
0 commit comments