Skip to content

Nonsense opaque type in extension crashes typer #23036

Open
@jchyb

Description

@jchyb

Compiler version

3.6.4

Minimized code

extension (self: Int) {
  opaque type Maybe[+A] = A
}

Output (click arrow to expand)

-- [E040] Syntax Error: /Users/jchyb/kyo/minim/minim2.scala:2:9 ----------------
2 |  opaque type Maybe[A] = A
  |         ^^^^
  |         'def' expected, but 'type' found

  exception occurred while typechecking /Users/jchyb/kyo/minim/minim2.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Xno-enrich-error-messages.

     while compiling: /Users/jchyb/kyo/minim/minim2.scala
        during phase: typer
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.14
    compiler version: version 3.5.0
            settings: -classpath /Users/jchyb/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.5.0/scala3-library_3-3.5.0.jar:/Users/jchyb/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.14/scala-library-2.13.14.jar -d /Users/jchyb/kyo/minim/.scala-build/minim_cef53d4a2d-8ccf584787/classes/main -sourceroot /Users/jchyb/kyo/minim

Exception in thread "main" java.lang.AssertionError: assertion failed
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11)
        at dotty.tools.dotc.core.Types$RefinedType.<init>(Types.scala:3295)
        at dotty.tools.dotc.core.Types$CachedRefinedType.<init>(Types.scala:3340)
        at dotty.tools.dotc.core.Types$RefinedType$.apply(Types.scala:3349)
        at dotty.tools.dotc.core.Types$ClassInfo.refineSelfType$1(Types.scala:5548)
        at dotty.tools.dotc.core.Types$ClassInfo.integrateOpaqueMembers$$anonfun$1(Types.scala:5552)
        at scala.collection.LinearSeqOps.foldLeft(LinearSeq.scala:183)
        at scala.collection.LinearSeqOps.foldLeft$(LinearSeq.scala:179)
        at scala.collection.immutable.List.foldLeft(List.scala:79)
        at dotty.tools.dotc.core.Types$ClassInfo.integrateOpaqueMembers(Types.scala:5532)
        at dotty.tools.dotc.typer.Namer$ClassCompleter.completeConstructor(Namer.scala:1530)
        at dotty.tools.dotc.typer.Namer$ClassCompleter.completeInCreationContext(Namer.scala:1679)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:850)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:175)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:190)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:192)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:393)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:3206)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3426)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3477)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3554)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3558)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3669)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:47)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:503)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:53)
        at dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:99)
        at scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
        at scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
        at scala.collection.immutable.List.prependedAll(List.scala:152)
        at scala.collection.immutable.List$.from(List.scala:685)
        at scala.collection.immutable.List$.from(List.scala:682)
        at scala.collection.IterableOps$WithFilter.map(Iterable.scala:900)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:98)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:343)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:336)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:396)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:396)
        at dotty.tools.dotc.Run.compileSources(Run.scala:282)
        at dotty.tools.dotc.Run.compile(Run.scala:267)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:201)
        at dotty.tools.dotc.Driver.process(Driver.scala:169)
        at dotty.tools.dotc.Driver.process(Driver.scala:181)
        at dotty.tools.dotc.Driver.main(Driver.scala:211)
        at dotty.tools.dotc.Main.main(Main.scala)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions