Skip to content

Commit a5d3ba9

Browse files
authored
Merge pull request #10188 from dotty-staging/fix-sjs-double-definition-of-outer-pointer
Fix #10177: Test `@JSType` in `isJSType` instead of using time travel.
2 parents 70bcb28 + 03b06cd commit a5d3ba9

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)