Skip to content

Commit 03b06cd

Browse files
committed
Fix #10177: Test @JSType in isJSType instead of using time travel.
The time travel in `isJSType` was causing an issue when used from `ExplicitJSClasses`. It would somehow interfere with `ExplicitOuter`, which would then generate an outer pointer twice. We now test the presence of the `@JSType` annotation, which is also what Scala 2 does. Historically we used the time travel because we had not implemented `PrepJSInterop`, which is responsible for adding the `@JSType` annotations in the first place.
1 parent 70bcb28 commit 03b06cd

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

compiler/src/dotty/tools/dotc/transform/sjs/JSSymUtils.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ object JSSymUtils {
4343

4444
extension (sym: Symbol) {
4545
/** Is this symbol a JavaScript type? */
46-
def isJSType(using Context): Boolean = {
47-
atPhase(erasurePhase) {
48-
sym.derivesFrom(jsdefn.JSAnyClass) || sym == jsdefn.PseudoUnionClass
49-
}
50-
}
46+
def isJSType(using Context): Boolean =
47+
sym.hasAnnotation(jsdefn.JSTypeAnnot)
5148

5249
/** Is this symbol a non-native JS class? */
5350
def isNonNativeJSClass(using Context): Boolean =
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.scalajs.testsuite.compiler
2+
3+
import org.junit.Assert._
4+
import org.junit.Test
5+
6+
class RegressionTestScala3 {
7+
import RegressionTestScala3._
8+
9+
@Test def testRegressionDoubleDefinitionOfOuterPointerIssue10177(): Unit = {
10+
assertEquals(6, new OuterClassIssue10177().foo(5))
11+
}
12+
}
13+
14+
object RegressionTestScala3 {
15+
class OuterClassIssue10177 { // can also be trait
16+
trait ParentTrait { // must be trait, can be private
17+
def concreteMethod(x: Int): Int = x + 1 // must have a concrete method
18+
}
19+
20+
private class ChildClass extends ParentTrait // must be class *and* private
21+
22+
def foo(x: Int): Int = new ChildClass().concreteMethod(x)
23+
}
24+
}

0 commit comments

Comments
 (0)