Dotty: NoDenotation.owner using string interpolation with -Yexplicit-nulls

Created on 28 Nov 2020  路  5Comments  路  Source: lampepfl/dotty

Minimized code

object Test:
  def foo(x: Int): String = s"$x"

-Yexplicit-nulls must be enabled in scalacOptions.

Output

[info] compiling 1 Scala source to /home/abdulla/projects/tmp/test-scala3/target/scala-3.0.0-M2/classes ...
Error while emitting Main.scala
[info] exception occurred while compiling /home/abdulla/projects/tmp/test-scala3/src/main/scala/Main.scala
java.lang.AssertionError: NoDenotation.owner while compiling /home/abdulla/projects/tmp/test-scala3/src/main/scala/Main.scala
[error] ## Exception when compiling 1 sources to /home/abdulla/projects/tmp/test-scala3/target/scala-3.0.0-M2/classes
[error] java.lang.AssertionError: NoDenotation.owner
[error] dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:2351)
[error] dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genCallMethod(BCodeBodyBuilder.scala:1110)
[error] dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genStringConcat(BCodeBodyBuilder.scala:1082)
[error] dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genPrimitiveOp(BCodeBodyBuilder.scala:240)
[error] dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genApply(BCodeBodyBuilder.scala:758)
[error] dotty.tools.backend.jvm.BCodeBodyBuilder$PlainBodyBuilder.genLoad(BCodeBodyBuilder.scala:356)
[error] dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.emitNormalMethodBody$1(BCodeSkelBuilder.scala:708)
[error] dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.genDefDef(BCodeSkelBuilder.scala:743)
[error] dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen(BCodeSkelBuilder.scala:591)
[error] dotty.tools.backend.jvm.BCodeSkelBuilder$PlainSkelBuilder.gen$$anonfun$1(BCodeSkelBuilder.scala:597)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)

Expectation

Compiled successfully.

Notes

if you change s"$uid" to something like toString() or even to s"uid-${uid]" it starts working also.

bug

Most helpful comment

I can reproduce the error when using -Yexplicit-nulls. Thanks!

All 5 comments

The example compiles successfully for me using 3.0.0-M2, 3.0.0-M1, and 3.0.0-RC1-bin-20201127-ed93a48-NIGHTLY.

Are you able to reproduce the error with the code as posted?

Try this:
https://github.com/abdolence/scala3-opaque-type-bug

Maybe it is also related to compiler flags or sbt version, not sure.

I can reproduce the error when using -Yexplicit-nulls. Thanks!

We can actually minimize this some more to remove the use of opaque types:

object Test:
  def foo(x: Int): String = s"$x"

When compiled using -Yexplicit-nulls it fails with the same NoDenotation.owner error as above.

thanks @griggt
Updated the issue with your code

Was this page helpful?
0 / 5 - 0 ratings

Related issues

travisbrown picture travisbrown  路  3Comments

fommil picture fommil  路  3Comments

m-sp picture m-sp  路  3Comments

liufengyun picture liufengyun  路  3Comments

milessabin picture milessabin  路  3Comments