Skip to content
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

Compiler crash (ClassCastException) with -Ysafe-init #17997

Closed
durban opened this issue Jun 18, 2023 · 1 comment · Fixed by #18069
Closed

Compiler crash (ClassCastException) with -Ysafe-init #17997

durban opened this issue Jun 18, 2023 · 1 comment · Fixed by #18069

Comments

@durban
Copy link

durban commented Jun 18, 2023

Compiler version

3.3.0

Minimized code

Full code is at https://github.com/durban/dotty-crash

package com.example


trait MySelfType

trait MyTrait extends munit.FunSuite { this: MySelfType =>

  test("foo") {
  }

  val x = ""

  test("bar") {
  }
}

abstract class MyAbstractClass extends munit.FunSuite { this: MySelfType =>

  override def munitValueTransforms: List[ValueTransform] = {
    super.munitValueTransforms
  }
}

final class MyFinalClass
  extends MyAbstractClass
  with MyTrait
  with MySelfType

Output (click arrow to expand)

sbt:dotty-crash> Test/compile
[info] compiling 1 Scala source to .../dotty-crash/target/scala-3.3.0/test-classes ...
[info] exception occurred while compiling .../dotty-crash/src/test/scala/com/example/Foo.scala
java.lang.ClassCastException: class dotty.tools.dotc.core.Symbols$NoSymbol$ cannot be cast to class dotty.tools.dotc.core.Symbols$ClassSymbol (dotty.tools.dotc.core.Symbols$NoSymbol$ and dotty.tools.dotc.core.Symbols$ClassSymbol are in unnamed module of loader sbt.internal.classpath.ClassLoaderCache$Key$CachedClassLoader @155f058) while compiling .../dotty-crash/src/test/scala/com/example/Foo.scala
[error] ## Exception when compiling 1 sources to .../dotty-crash/target/scala-3.3.0/test-classes
[error] java.lang.ClassCastException: class dotty.tools.dotc.core.Symbols$NoSymbol$ cannot be cast to class dotty.tools.dotc.core.Symbols$ClassSymbol (dotty.tools.dotc.core.Symbols$NoSymbol$ and dotty.tools.dotc.core.Symbols$ClassSymbol are in unnamed module of loader sbt.internal.classpath.ClassLoaderCache$Key$CachedClassLoader @155f058)
[error] dotty.tools.dotc.core.Symbols$Symbol.asClass(Symbols.scala:178)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$42(Semantic.scala:1342)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1342)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1418)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$11(Semantic.scala:813)
[error] dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:812)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$45(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1346)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1346)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1346)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1466)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$2(Semantic.scala:1290)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1290)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1417)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$31(Semantic.scala:1103)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:542)
[error] dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1107)
[error] dotty.tools.dotc.transform.init.Semantic$ArgInfo.$anonfun$39(Semantic.scala:1258)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$ArgInfo.promote(Semantic.scala:1257)
[error] dotty.tools.dotc.transform.init.Semantic$.promoteArgs$1$$anonfun$1(Semantic.scala:717)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.init.Semantic$.promoteArgs$1(Semantic.scala:717)
[error] dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:777)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$45(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1466)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$2(Semantic.scala:1290)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1290)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1417)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$11(Semantic.scala:813)
[error] dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:812)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$47(Semantic.scala:1359)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1359)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1418)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$11(Semantic.scala:813)
[error] dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:812)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$45(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$31(Semantic.scala:1103)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:542)
[error] dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1107)
[error] dotty.tools.dotc.transform.init.Semantic$ArgInfo.$anonfun$39(Semantic.scala:1258)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$ArgInfo.promote(Semantic.scala:1257)
[error] dotty.tools.dotc.transform.init.Semantic$.promoteArgs$1$$anonfun$1(Semantic.scala:717)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.init.Semantic$.promoteArgs$1(Semantic.scala:717)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$10(Semantic.scala:802)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$Reporter$.errorsIn(Semantic.scala:534)
[error] dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:802)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$45(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1418)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1448)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1418)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$31(Semantic.scala:1103)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:542)
[error] dotty.tools.dotc.transform.init.Semantic$.promote(Semantic.scala:1107)
[error] dotty.tools.dotc.transform.init.Semantic$ArgInfo.$anonfun$39(Semantic.scala:1258)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$ArgInfo.promote(Semantic.scala:1257)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$26(Semantic.scala:936)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$Reporter$.$anonfun$4(Semantic.scala:549)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.transform.init.Semantic$Reporter$.stopEarly(Semantic.scala:542)
[error] dotty.tools.dotc.transform.init.Semantic$Reporter$.hasErrors(Semantic.scala:549)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$25(Semantic.scala:936)
[error] scala.collection.immutable.List.map(List.scala:250)
[error] dotty.tools.dotc.transform.init.Semantic$.instantiate(Semantic.scala:939)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$41(Semantic.scala:1332)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1330)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.evalArgs$$anonfun$1(Semantic.scala:1300)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.init.Semantic$.evalArgs(Semantic.scala:1302)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1337)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.evalArgs$$anonfun$1(Semantic.scala:1300)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.init.Semantic$.evalArgs(Semantic.scala:1302)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1337)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$2(Semantic.scala:1290)
[error] scala.collection.immutable.List.map(List.scala:246)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1290)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1417)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1418)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$11(Semantic.scala:813)
[error] dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:812)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$45(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1418)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$11(Semantic.scala:813)
[error] dotty.tools.dotc.transform.init.Semantic$.call(Semantic.scala:812)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$45(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1350)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.init$$anonfun$4(Semantic.scala:1704)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.transform.init.Semantic$.init(Semantic.scala:1705)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1481)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.$anonfun$18(Semantic.scala:894)
[error] dotty.tools.dotc.transform.init.Semantic$.callConstructor(Semantic.scala:894)
[error] dotty.tools.dotc.transform.init.Semantic$.superCall$1$$anonfun$1(Semantic.scala:1612)
[error] dotty.tools.dotc.transform.init.Semantic$.init$$anonfun$3(Semantic.scala:1677)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.IterableOnceOps.foreach(IterableOnce.scala:575)
[error] scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:573)
[error] scala.collection.AbstractIterable.foreach(Iterable.scala:933)
[error] dotty.tools.dotc.transform.init.Semantic$.init(Semantic.scala:1677)
[error] dotty.tools.dotc.transform.init.Semantic$.cases(Semantic.scala:1481)
[error] dotty.tools.dotc.transform.init.Semantic$.eval$$anonfun$1(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$Cache$Cache.assume(Semantic.scala:374)
[error] dotty.tools.dotc.transform.init.Semantic$.eval(Semantic.scala:1285)
[error] dotty.tools.dotc.transform.init.Semantic$.iterate$1(Semantic.scala:1231)
[error] dotty.tools.dotc.transform.init.Semantic$.checkClass(Semantic.scala:1242)
[error] dotty.tools.dotc.transform.init.Semantic$.checkClasses$$anonfun$2(Semantic.scala:1251)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.IterableOnceOps.foreach(IterableOnce.scala:575)
[error] scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:573)
[error] scala.collection.AbstractIterable.foreach(Iterable.scala:933)
[error] scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:903)
[error] dotty.tools.dotc.transform.init.Semantic$.checkClasses(Semantic.scala:1251)
[error] dotty.tools.dotc.transform.init.Checker.runOn(Checker.scala:39)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:247)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1321)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:263)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:271)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:280)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:67)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:280)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:195)
[error] dotty.tools.dotc.Run.compile(Run.scala:179)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:88)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:193)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:248)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:183)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:163)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:211)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5(Incremental.scala:179)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$5$adapted(Incremental.scala:177)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:463)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:263)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:418)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:505)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:405)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:171)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:534)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:488)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:425)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2366)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2316)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:30)
[error] sbt.internal.io.Retry$.apply(Retry.scala:46)
[error] sbt.internal.io.Retry$.apply(Retry.scala:28)
[error] sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:30)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2314)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] sbt.Execute.work(Execute.scala:291)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] java.base/java.lang.Thread.run(Thread.java:833)
[error]            
[error] stack trace is suppressed; run last Test / compileIncremental for the full output
[error] (Test / compileIncremental) java.lang.ClassCastException: class dotty.tools.dotc.core.Symbols$NoSymbol$ cannot be cast to class dotty.tools.dotc.core.Symbols$ClassSymbol (dotty.tools.dotc.core.Symbols$NoSymbol$ and dotty.tools.dotc.core.Symbols$ClassSymbol are in unnamed module of loader sbt.internal.classpath.ClassLoaderCache$Key$CachedClassLoader @155f058)

Note: -Ysafe-init seems to be required for the crash to happen.

@durban durban added itype:bug itype:crash stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 18, 2023
@mbovel mbovel added area:initialization and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Jun 19, 2023
@liufengyun liufengyun self-assigned this Jun 20, 2023
@q-ata
Copy link
Contributor

q-ata commented Jun 26, 2023

The project that crashes depends on munit compiled in Scala 3.

The crash seems to be a result of this line in the init checker: https://github.com/lampepfl/dotty/blob/894809278a47a5455ee12f5dfb7c16da8d641e6c/compiler/src/dotty/tools/dotc/transform/init/Semantic.scala#L1232C11-L1232C102

val thisValue2 = extendTrace(ref) { resolveThis(thisTp.classSymbol.asClass, thisV, klass) }

thisTp.classSymbol.asClass seems to be failing. The value for thisTp is ThisType(TypeRef(ThisType(TypeRef(NoPrefix,module class example)),class MyAbstractClass)). classSymbol returns NoSymbol for this class.

liufengyun added a commit to dotty-staging/dotty that referenced this issue Jun 26, 2023
olhotak added a commit that referenced this issue Jun 27, 2023
Fix #17997: Handle intersection type as this type of super type
olhotak added a commit to dotty-staging/dotty that referenced this issue Jul 4, 2023
EnzeXing pushed a commit to dotty-staging/dotty that referenced this issue Jul 24, 2023
olhotak added a commit that referenced this issue Jul 27, 2023
…checker (#18141)

Issue #17997 reported a minimized example that crashed the object
instance initialization checker. That checker was fixed in #18069.
However, a similar example also crashes the global object initialization
checker. This PR adds a test that exhibits this crash in the global
object initialization checker.
@Kordyjan Kordyjan added this to the 3.4.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants