Skip to content

AssertionError: invalid prefix MethodType ... #16842

Closed
@mateusz-lichota

Description

@mateusz-lichota

Compiler version

3.2.2

Minimized code

sealed trait Expr1
sealed trait Literal extends Expr1

case class ArrayLiter(elems: List[Expr1]) extends Literal

sealed trait SemanticType {
  type T // the type with which a literal of this semanticType is represented
}
case object SemanticInt extends SemanticType {
  type T = Int
}

case class SemanticArray[U <: SemanticType](dim: Int) extends SemanticType {
  type T = List[U]
}

sealed trait Expr2[+T]
class Liter[T <: SemanticType](val ty: T, val value: ty.T) extends Expr2[T]

def typecheckArrayLiter(
    a: ArrayLiter
): Liter[SemanticArray[SemanticType]] = {
  val x: List[Expr2[SemanticInt.type]] = List()
  Liter(SemanticArray[SemanticInt.type], x)
}

Output (click arrow to expand)

java.lang.AssertionError: assertion failed: invalid prefix MethodType(List(dim), List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)), AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class SemanticArray),List(TermRef(ThisType(TypeRef(NoPrefix,module class <empty>)),object SemanticInt)))) while typechecking src/main/scala/wacc/Main.scala
exception occurred while typechecking src/main/scala/wacc/Main.scala
exception occurred while compiling src/main/scala/wacc/Main.scala
java.lang.AssertionError: assertion failed: invalid prefix MethodType(List(dim), List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)), AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class SemanticArray),List(TermRef(ThisType(TypeRef(NoPrefix,module class <empty>)),object SemanticInt)))) while compiling src/main/scala/wacc/Main.scala
Exception in thread "main" java.lang.AssertionError: assertion failed: invalid prefix MethodType(List(dim), List(TypeRef(TermRef(ThisType(TypeRef(NoPrefix,module class <root>)),object scala),class Int)), AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class SemanticArray),List(TermRef(ThisType(TypeRef(NoPrefix,module class <empty>)),object SemanticInt))))
        at scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:8)
        at dotty.tools.dotc.core.Types$NamedType.<init>(Types.scala:2189)
        at dotty.tools.dotc.core.Types$TypeRef.<init>(Types.scala:2804)
        at dotty.tools.dotc.core.Types$CachedTypeRef.<init>(Types.scala:2860)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.newType$1(Uniques.scala:45)
        at dotty.tools.dotc.core.Uniques$NamedTypeUniques.enterIfNew(Uniques.scala:46)
        at dotty.tools.dotc.core.Types$TypeRef$.apply(Types.scala:2919)
        at dotty.tools.dotc.core.Types$TypeRef$.apply(Types.scala:2925)
        at dotty.tools.dotc.core.Types$NamedType$.apply(Types.scala:2899)
        at dotty.tools.dotc.core.Types$NamedType.reload$1(Types.scala:2706)
        at dotty.tools.dotc.core.Types$NamedType.withPrefix(Types.scala:2722)
        at dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:2636)
        at dotty.tools.dotc.core.Substituters$.substParam(Substituters.scala:142)
        at dotty.tools.dotc.core.Types$Type.substParam(Types.scala:1813)
        at dotty.tools.dotc.typer.TypeAssigner.safeSubstParam(TypeAssigner.scala:275)
        at dotty.tools.dotc.typer.TypeAssigner.safeSubstParam$(TypeAssigner.scala:16)
        at dotty.tools.dotc.typer.Typer.safeSubstParam(Typer.scala:121)
        at dotty.tools.dotc.typer.Applications$Application.addTyped$1$$anonfun$1(Applications.scala:579)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:91)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:107)
        at dotty.tools.dotc.typer.Applications$Application.addTyped$1(Applications.scala:579)
        at dotty.tools.dotc.typer.Applications$Application.matchArgs(Applications.scala:640)
        at dotty.tools.dotc.typer.Applications$Application.init(Applications.scala:479)
        at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:766)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:883)
        at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1095)
        at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:346)
        at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:121)
        at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:941)
        at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$3(Applications.scala:1021)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3169)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1032)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1070)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:346)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:121)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2895)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3145)
        at dotty.tools.dotc.typer.Typer.typedBlock(Typer.scala:1069)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2903)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3145)
        at dotty.tools.dotc.typer.Typer.$anonfun$51(Typer.scala:2356)
        at dotty.tools.dotc.inlines.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:249)
        at dotty.tools.dotc.typer.Typer.typedDefDef(Typer.scala:2356)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2871)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2957)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3051)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3101)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2532)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2883)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2887)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2957)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3051)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3101)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2659)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2928)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2958)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3025)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:3029)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3145)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:44)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$adapted$1(TyperPhase.scala:54)
        at scala.Function0.apply$mcV$sp(Function0.scala:42)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:429)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54)
        at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:238)
        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:1321)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:249)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:257)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:266)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:266)
        at dotty.tools.dotc.Run.compileSources(Run.scala:190)
        at dotty.tools.dotc.Run.compile(Run.scala:174)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:35)
        at dotty.tools.dotc.Driver.process(Driver.scala:195)
        at dotty.tools.dotc.Driver.process(Driver.scala:163)
        at dotty.tools.dotc.Driver.process(Driver.scala:175)
        at dotty.tools.dotc.Driver.main(Driver.scala:205)
        at dotty.tools.MainGenericCompiler$.run$1(MainGenericCompiler.scala:162)
        at dotty.tools.MainGenericCompiler$.main(MainGenericCompiler.scala:186)
        at dotty.tools.MainGenericCompiler.main(MainGenericCompiler.scala)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at coursier.bootstrap.launcher.a.a(Unknown Source)
        at coursier.bootstrap.launcher.Launcher.main(Unknown Source)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions