Skip to content

Spurious "cannot be checked at runtime" in latest 2.12.x (regression wrt. 2.12.8) #11534

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

Closed
sjrd opened this issue May 15, 2019 · 4 comments · Fixed by scala/scala#9504
Closed
Assignees
Milestone

Comments

@sjrd
Copy link
Member

sjrd commented May 15, 2019

Trying to build the latest 0.6.x branch of Scala.js with the latest 2.12.x, I get a warning that I do not get with 2.12.8.

Repro:

$ git clone [email protected]:scala-js/scala-js.git
$ cd scala-js
$ git checkout fa02c74
$ sbt
> set resolvers in Global += "scala-integration" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
> ++2.12.9-bin-ae27fe9
> compiler/compile
[...]
[warn] compiler/src/main/scala/org/scalajs/core/compiler/GenJSCode.scala:4421: The outer reference in this type test cannot be checked at run time.
[warn]         case JSUnaryOpMethodName(code) if argc == 0 =>
[warn]                                 ^

The line mentioned is here:
https://github.com/scala-js/scala-js/blob/fa02c745a64b869127b8cb68d594f5ca6c1b2d4e/compiler/src/main/scala/org/scalajs/core/compiler/GenJSCode.scala#L4421

The warning was not reported by 2.12.8.

Note that the next case with JSBinaryOpMethodName, which is extremely similar, does not emit a warning.

A similar problem exists on our master branch (commit scala-js/scala-js@9f4f59b), where this becomes an error because we have -Xfatal-warnings.

@dwijnand dwijnand added this to the 2.12.9 milestone May 15, 2019
@eed3si9n
Copy link
Member

It's 2 weeks before 2.12.9, but it doesn't look like there's an activity on this, so I am bumping this to 2.12.10.

@eed3si9n eed3si9n modified the milestones: 2.12.9, 2.12.10 Jul 18, 2019
@lrytz
Copy link
Member

lrytz commented Jul 19, 2019

This is caused by one of the commits in scala/scala@8257b83...ae27fe9. With the parent merge commit (8257b83) the warning doesn't appear. @retronym

@Jasper-M
Copy link

Jasper-M commented Jul 19, 2019

Not a clue if that's the cause—or how it could possibly be the cause—but it seems that name.newName(str) no longer retains the "cachedness" of the Name.

@retronym
Copy link
Member

Here's a smaller repro:

// scalac: -Xfatal-warnings -unchecked
object Test1 {
    val g: scala.tools.nsc.Global = ???
    import g._
    def test(sym: Symbol) = sym.name match {
        case _: TermName  =>
    }
}

ExplicitOuter opts not to emit an outer test anymore because although TermName has an outer accessor, it is now a final class. This is somehow tied up in the morass of #4440.

Ideally the compiler would be smart enough to avoid the runtime test in this case as we statically know that the prefixes are the same. But sym.name has an exotic type: sym.NameType an abstract type defined by >: Null <: Test1.g.Name. The code that tries to statically unify the prefixes doesn't deal with this correctly.

@retronym retronym modified the milestones: 2.12.10, 2.12.9 Jul 25, 2019
@eed3si9n eed3si9n modified the milestones: 2.12.9, 2.12.10 Jul 31, 2019
@SethTisue SethTisue modified the milestones: 2.12.10, 2.12.11 Sep 3, 2019
sjrd added a commit to sjrd/scala-js that referenced this issue Oct 1, 2019
sjrd added a commit to sjrd/scala-js that referenced this issue Oct 1, 2019
@lrytz lrytz modified the milestones: 2.12.11, 2.12.12 Feb 27, 2020
@retronym retronym modified the milestones: 2.12.12, 2.12.13 Jul 1, 2020
@dwijnand dwijnand modified the milestones: 2.12.13, Backlog Oct 20, 2020
@dwijnand dwijnand modified the milestones: Backlog, 2.13.6 Feb 18, 2021
@dwijnand dwijnand self-assigned this Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants