Skip to content

Commit

Permalink
Fix checkClassType for Scala 2.13.5.
Browse files Browse the repository at this point in the history
`checkClassType` was renamed to `checkClassOrModuleType` upstream,
to be released in Scala 2.13.5, to account for its change in
behavior that was introduced in Scala 2.13.4. The renaming was done
in scala/scala@5312148

This commit introduces a compat hack to use the new method. This is
only in the hack for `classOf` desugaring, which corresponds to the
fact that `typedClassOf` upstream started using the renamed method
upstream.
  • Loading branch information
sjrd committed Feb 1, 2021
1 parent d4e6eb9 commit 4b95e19
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ trait CompatComponent {
}
}

implicit final class TyperCompat(self: analyzer.Typer) {
// Added in Scala 2.13.5 to make it clearer what is allowed since 2.13.4
def checkClassOrModuleType(tpt: Tree): Boolean =
self.checkClassType(tpt)

def checkClassType(tpt: Tree): Boolean =
infiniteLoop()
}

private implicit final class FlagsCompat(self: Flags.type) {
def IMPLCLASS: Long = infiniteLoop()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ abstract class PrepJSInterop[G <: Global with Singleton](val global: G)
if predef.symbol == PredefModule =>
if (scalaJSOpts.fixClassOf) {
// Replace call by literal constant containing type
if (typer.checkClassType(tpeArg)) {
if (typer.checkClassOrModuleType(tpeArg)) {
typer.typed { Literal(Constant(tpeArg.tpe.dealias.widen)) }
} else {
reporter.error(tpeArg.pos, s"Type ${tpeArg} is not a class type")
Expand Down

0 comments on commit 4b95e19

Please sign in to comment.