diff --git a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala index 52e90c0857ed..bfa684eef8b4 100644 --- a/compiler/src/dotty/tools/dotc/transform/init/Objects.scala +++ b/compiler/src/dotty/tools/dotc/transform/init/Objects.scala @@ -29,7 +29,6 @@ import scala.collection.mutable import scala.annotation.tailrec import scala.annotation.constructorOnly import dotty.tools.dotc.core.Flags.AbstractOrTrait -import Decorators.* /** Check initialization safety of static objects * diff --git a/tests/init-global/neg/TypeCast.scala b/tests/init-global/neg/TypeCast.scala deleted file mode 100644 index 55447e9df4e2..000000000000 --- a/tests/init-global/neg/TypeCast.scala +++ /dev/null @@ -1,18 +0,0 @@ -object A { - val f: Int = 10 - def m() = f -} -object B { - val f: Int = g() - def g(): Int = f // error -} -object C { - val a: A.type | B.type = if ??? then A else B - def cast[T](a: Any): T = a.asInstanceOf[T] - val c: A.type = cast[A.type](a) // abstraction for c is {A, B} - val d = c.f // treat as c.asInstanceOf[owner of f].f - val e = c.m() // treat as c.asInstanceOf[owner of f].m() - val c2: B.type = cast[B.type](a) - val g = c2.f // no error here -} - diff --git a/tests/init-global/warn/ScalaCheck.scala b/tests/init-global/warn/ScalaCheck.scala new file mode 100644 index 000000000000..574db37e8585 --- /dev/null +++ b/tests/init-global/warn/ScalaCheck.scala @@ -0,0 +1,22 @@ +trait CmdLineParser: + outer => + + val a: String + + trait Opt[+T]: + val default: T + val names: Set[String] + val help: String + + trait IntOpt extends Opt[Int]: + println("outer = " + outer) + println("outer.a = " + outer.a) + +object FirstParser extends CmdLineParser: + object OptMinSuccess extends IntOpt: // warn + val default = 100 + val names = Set("bla") + val help = "bla" + + val opts = List(OptMinSuccess) + val a = "FirstParser"