Skip to content

REPL breaks when complicated type is inferred #2554

Closed
@Jasper-M

Description

@Jasper-M

I was trying to investigate something about how dotty infers types that scalac infers as existential "forSome" types. Alas the REPL only shows me an error that seems to come from the code generation phase of the REPL itself.

scala> 
object foo { 
    trait ShapeLevel 
    trait FlatShapeLevel extends ShapeLevel 
    trait ColumnsShapeLevel extends FlatShapeLevel 
   
    abstract class Shape[Level <: ShapeLevel, -Mixed, Unpacked, Packed] 
    object Shape extends TupleShapeImplicits { } 
    trait TupleShapeImplicits { 
      implicit final def tuple2Shape[Level <: ShapeLevel, M1,M2, U1,U2, P1,P2](implicit u1: Shape[_ <: Level, M1, U1, P1], u2: Shape[_ <: Level, M2, U2, P2]): Shape[Level, (M1,M2), (U1,U2), (P1,P2)] = ??? 
    } 
  } 
defined module foo
scala> import foo._ 
import foo._
scala> implicit val shape: Shape[_ <: FlatShapeLevel, Int, Int, _] = null 
val shape: foo.Shape[_ <: foo.FlatShapeLevel, Int, Int, _] = null
scala> def hint = Shape.tuple2Shape(shape, shape) 
-- Error: <console>:4:4 --------------------------------------------------------
4 |(""+"def hint: foo.Shape[foo.FlatShapeLevel, (Int, Int), (Int, Int), (shape.Packed, 
  |    ^
  |    unclosed string literal
-- [E039] Syntax Error: <console>:6:1 ------------------------------------------
6 |)]\n"
  | ^
  | ';' expected, but `Packed` found

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions