diff options
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/TypeErasure.scala | 4 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala | 2 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala | 2 | ||||
-rw-r--r-- | compiler/src/dotty/tools/dotc/transform/patmat/Space.scala | 7 | ||||
-rw-r--r-- | tests/patmat/i2253.check | 3 | ||||
-rw-r--r-- | tests/patmat/i2253.scala | 29 | ||||
-rw-r--r-- | tests/pos/i2234.scala | 13 | ||||
-rw-r--r-- | tests/repl/errmsgs.check | 22 | ||||
-rw-r--r-- | tests/repl/imports.check | 6 | ||||
-rw-r--r-- | tests/repl/overrides.check | 4 |
11 files changed, 71 insertions, 23 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index f35752644..1eb90b8eb 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -377,6 +377,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean defn.FunctionType(0) case AndType(tp1, tp2) => erasedGlb(this(tp1), this(tp2), isJava) + case tp: HKApply => + apply(tp.superType) case OrType(tp1, tp2) => ctx.typeComparer.orType(this(tp1), this(tp2), erased = true) case tp: MethodType => @@ -508,6 +510,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean normalizeClass(sym.asClass).fullName.asTypeName case defn.ArrayOf(elem) => sigName(this(tp)) + case tp: HKApply => + sigName(tp.superType) case JavaArrayType(elem) => sigName(elem) ++ "[]" case tp: TermRef => diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 3112be659..9f393df00 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -2151,7 +2151,7 @@ object Parsers { /** EnumCaseStats = EnumCaseStat {semi EnumCaseStat */ def enumCaseStats(): List[DefTree] = { val cases = new ListBuffer[DefTree] += enumCaseStat() - while (in.token != RBRACE) { + while (in.token != RBRACE && in.token != EOF) { acceptStatSep() cases += enumCaseStat() } diff --git a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala index e20f846ac..87ce31ad9 100644 --- a/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala +++ b/compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala @@ -31,7 +31,7 @@ object SyntaxHighlighting { private val tripleQs = Console.RED_B + "???" + NoColor private val keywords: Seq[String] = for { - index <- IF to INLINE // All alpha keywords + index <- IF to ENUM // All alpha keywords } yield tokenString(index) private val interpolationPrefixes = diff --git a/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala b/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala index 91e65ab66..98af775da 100644 --- a/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala +++ b/compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala @@ -113,7 +113,7 @@ trait MessageRendering { */ def posStr(pos: SourcePosition, diagnosticLevel: String, message: Message)(implicit ctx: Context): String = if (pos.exists) Blue({ - val file = pos.source.file.toString + val file = s"${pos.source.file.toString}:${pos.line + 1}:${pos.column}" val errId = if (message.errorId ne ErrorMessageID.NoExplanationID) { val errorNumber = message.errorId.errorNumber() diff --git a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala index fe2983896..53518ec9c 100644 --- a/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala +++ b/compiler/src/dotty/tools/dotc/transform/patmat/Space.scala @@ -537,7 +537,12 @@ class SpaceEngine(implicit ctx: Context) extends SpaceLogic { tp.refinedName, tpb.derivedTypeBounds(follow(lo, false), follow(hi, true)) ) - case tp => tp + case _ => + tp.derivedRefinedType( + expose(tp.parent), + tp.refinedName, + tp.refinedInfo + ) } case _ => tp } diff --git a/tests/patmat/i2253.check b/tests/patmat/i2253.check new file mode 100644 index 000000000..5c86a1ef8 --- /dev/null +++ b/tests/patmat/i2253.check @@ -0,0 +1,3 @@ +27: Pattern Match Exhaustivity: HasIntXIntM, HasIntXStringM +28: Pattern Match Exhaustivity: HasIntXIntM +29: Pattern Match Exhaustivity: HasIntXIntM diff --git a/tests/patmat/i2253.scala b/tests/patmat/i2253.scala index 8394a86df..0344a6a5d 100644 --- a/tests/patmat/i2253.scala +++ b/tests/patmat/i2253.scala @@ -1,7 +1,30 @@ sealed trait S -object O extends S + +object BodylessObject extends S + +object HasIntM extends S { + type M = Int +} + +object HasStringXStringM extends S { + type M = String + val x: String = "" +} + +object HasIntXStringM extends S { + type M = String + val x: Int = 0 +} + +object HasIntXIntM extends S { + type M = Int + val x: Int = 0 +} + trait T class Test { - def m(s: S { val x: Int }) = s match { case _: T => ; } -}
\ No newline at end of file + def onlyIntX(s: S { val x: Int }) = s match { case _: T => ; } + def exposeAlias1[I <: Int](s: S { type M = I; val x: Int }) = s match { case _: T => ; } + def exposeAlias2[I <: Int](s: S { val x: Int; type M = I }) = s match { case _: T => ; } +} diff --git a/tests/pos/i2234.scala b/tests/pos/i2234.scala new file mode 100644 index 000000000..8173c2091 --- /dev/null +++ b/tests/pos/i2234.scala @@ -0,0 +1,13 @@ +object Test { + type Dummy[A] = A + + def a(d: Dummy[String]) = () + def a(d: Dummy[Int]) = () + + implicit def dummy[A]: Dummy[A] = null.asInstanceOf[A] + def m(x: List[String])(implicit d: Dummy[String]) = "string" + def m(x: List[Int])(implicit d: Dummy[Int]) = "int" + + m(List(1, 2, 3)) + m(List("a")) +} diff --git a/tests/repl/errmsgs.check b/tests/repl/errmsgs.check index 4e89a16a5..a1b3bd6ae 100644 --- a/tests/repl/errmsgs.check +++ b/tests/repl/errmsgs.check @@ -1,34 +1,34 @@ scala> class Inv[T](x: T) defined class Inv scala> val x: List[String] = List(1) --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:4:27 ---------------------------------- 4 |val x: List[String] = List(1) | ^ | found: Int(1) | required: String | scala> val y: List[List[String]] = List(List(1)) --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:4:38 ---------------------------------- 4 |val y: List[List[String]] = List(List(1)) | ^ | found: Int(1) | required: String | scala> val z: (List[String], List[Int]) = (List(1), List("a")) --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:4:41 ---------------------------------- 4 |val z: (List[String], List[Int]) = (List(1), List("a")) | ^ | found: Int(1) | required: String | --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:4:50 ---------------------------------- 4 |val z: (List[String], List[Int]) = (List(1), List("a")) | ^^^ | found: String("a") | required: Int | scala> val a: Inv[String] = new Inv(new Inv(1)) --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:5:33 ---------------------------------- 5 |val a: Inv[String] = new Inv(new Inv(1)) | ^^^^^ | found: Inv[T] @@ -36,7 +36,7 @@ scala> val a: Inv[String] = new Inv(new Inv(1)) | | where: T is a type variable with constraint >: Int(1) scala> val b: Inv[String] = new Inv(1) --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:5:29 ---------------------------------- 5 |val b: Inv[String] = new Inv(1) | ^ | found: Int(1) @@ -57,7 +57,7 @@ scala> abstract class C { } } } --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:9:17 ---------------------------------- 9 | var y: T = x | ^ |found: C.this.T(C.this.x) @@ -65,7 +65,7 @@ scala> abstract class C { | |where: T is a type in class C | T' is a type in the initalizer of value s which is an alias of String --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:13:21 --------------------------------- 13 | val z: T = y | ^ |found: T(y) @@ -74,19 +74,19 @@ scala> abstract class C { |where: T is a type in the initalizer of value s which is an alias of String | T' is a type in method f which is an alias of Int scala> class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr --- [E008] Member Not Found Error: <console> ------------------------------------ +-- [E008] Member Not Found Error: <console>:4:59 ------------------------------- 4 |class Foo() { def bar: Int = 1 }; val foo = new Foo(); foo.barr | ^^^^^^^^ | value `barr` is not a member of Foo(foo) - did you mean `foo.bar`? scala> val x: List[Int] = "foo" :: List(1) --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:4:19 ---------------------------------- 4 |val x: List[Int] = "foo" :: List(1) | ^^^^^ | found: String($1$) | required: Int | scala> { def f: Int = g; val x: Int = 1; def g: Int = 5; } --- [E038] Reference Error: <console> ------------------------------------------- +-- [E038] Reference Error: <console>:5:15 -------------------------------------- 5 |{ def f: Int = g; val x: Int = 1; def g: Int = 5; } | ^ | `g` is a forward reference extending over the definition of `x` diff --git a/tests/repl/imports.check b/tests/repl/imports.check index 345fac142..12056280f 100644 --- a/tests/repl/imports.check +++ b/tests/repl/imports.check @@ -7,7 +7,7 @@ defined module o scala> import o._ import o._ scala> buf += xs --- [E007] Type Mismatch Error: <console> --------------------------------------- +-- [E007] Type Mismatch Error: <console>:11:7 ---------------------------------- 11 |buf += xs | ^^ | found: scala.collection.immutable.List[Int](o.xs) @@ -16,12 +16,12 @@ scala> buf += xs scala> buf ++= xs val res1: scala.collection.mutable.ListBuffer[Int] = ListBuffer(1, 2, 3) scala> import util.foo --- Error: <console> ------------------------------------------------------------ +-- Error: <console>:8:12 ------------------------------------------------------- 8 |import util.foo | ^^^ | foo is not a member of util scala> import util.foo.bar --- [E008] Member Not Found Error: <console> ------------------------------------ +-- [E008] Member Not Found Error: <console>:8:12 ------------------------------- 8 |import util.foo.bar | ^^^^^^^^ | value `foo` is not a member of util.type - did you mean `util.Left`? diff --git a/tests/repl/overrides.check b/tests/repl/overrides.check index 0fbd3d0e3..75970d0a1 100644 --- a/tests/repl/overrides.check +++ b/tests/repl/overrides.check @@ -1,5 +1,5 @@ scala> class B { override def foo(i: Int): Unit = {}; } --- [E036] Reference Error: <console> ------------------------------------------- +-- [E036] Reference Error: <console>:4:23 -------------------------------------- 4 |class B { override def foo(i: Int): Unit = {}; } | ^ | method foo overrides nothing @@ -8,7 +8,7 @@ longer explanation available when compiling with `-explain` scala> class A { def foo: Unit = {}; } defined class A scala> class B extends A { override def foo(i: Int): Unit = {}; } --- [E037] Reference Error: <console> ------------------------------------------- +-- [E037] Reference Error: <console>:5:33 -------------------------------------- 5 |class B extends A { override def foo(i: Int): Unit = {}; } | ^ | method foo has a different signature than the overridden declaration |