Skip to content

Fix #10177: Test @JSType in isJSType instead of using time travel. #10188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions compiler/src/dotty/tools/dotc/transform/sjs/JSSymUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ object JSSymUtils {

extension (sym: Symbol) {
/** Is this symbol a JavaScript type? */
def isJSType(using Context): Boolean = {
atPhase(erasurePhase) {
sym.derivesFrom(jsdefn.JSAnyClass) || sym == jsdefn.PseudoUnionClass
}
}
def isJSType(using Context): Boolean =
sym.hasAnnotation(jsdefn.JSTypeAnnot)

/** Is this symbol a non-native JS class? */
def isNonNativeJSClass(using Context): Boolean =
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.scalajs.testsuite.compiler

import org.junit.Assert._
import org.junit.Test

class RegressionTestScala3 {
import RegressionTestScala3._

@Test def testRegressionDoubleDefinitionOfOuterPointerIssue10177(): Unit = {
assertEquals(6, new OuterClassIssue10177().foo(5))
}
}

object RegressionTestScala3 {
class OuterClassIssue10177 { // can also be trait
trait ParentTrait { // must be trait, can be private
def concreteMethod(x: Int): Int = x + 1 // must have a concrete method
}

private class ChildClass extends ParentTrait // must be class *and* private

def foo(x: Int): Int = new ChildClass().concreteMethod(x)
}
}