File tree 7 files changed +23
-4
lines changed
compiler/src/dotty/tools/dotc/core
7 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -2762,7 +2762,8 @@ object Types {
2762
2762
NamedType (prefix, name, d)
2763
2763
}
2764
2764
if (prefix eq this .prefix) this
2765
- else if ! NamedType .validPrefix(prefix) then UnspecifiedErrorType
2765
+ else if ! NamedType .validPrefix(prefix) then
2766
+ throw TypeError (em " invalid new prefix $prefix cannot replace ${this .prefix} in type $this" )
2766
2767
else if (lastDenotation == null ) NamedType (prefix, designator)
2767
2768
else designator match {
2768
2769
case sym : Symbol =>
@@ -5411,6 +5412,9 @@ object Types {
5411
5412
def explanation (using Context ): String = msg.message
5412
5413
}
5413
5414
5415
+ /** Note: Make sure an errors is reported before construtcing this
5416
+ * as the type of a tree.
5417
+ */
5414
5418
object ErrorType :
5415
5419
def apply (m : Message )(using Context ): ErrorType =
5416
5420
val et = new PreviousErrorType
Original file line number Diff line number Diff line change @@ -699,6 +699,9 @@ class TreePickler(pickler: TastyPickler) {
699
699
case ex : AssertionError =>
700
700
println(i " error when pickling tree $tree" )
701
701
throw ex
702
+ case ex : MatchError =>
703
+ println(i " error when pickling tree $tree" )
704
+ throw ex
702
705
}
703
706
}
704
707
Original file line number Diff line number Diff line change 1
1
object Main {
2
2
def mkArray [T <: A ]: T # AType // error // error
3
- mkArray[Array ] // was: "assertion failed: invalid prefix HKTypeLambda..."
4
- val x = mkArray[Array ]
3
+ mkArray[Array ] // was: "assertion failed: invalid prefix HKTypeLambda..." // error
4
+ val x = mkArray[Array ] // error
5
5
}
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg/i16842.scala:24:7 ----------------------------------------------------------------------------------
2
+ 24 | Liter(SemanticArray[SemanticInt.type], x) // error
3
+ | ^
4
+ | invalid new prefix (dim: Int): SemanticArray[SemanticInt.type] cannot replace ty.type in type ty.T
Original file line number Diff line number Diff line change @@ -21,5 +21,5 @@ def typecheckArrayLiter(
21
21
a : ArrayLiter
22
22
): Liter [SemanticArray [SemanticType ]] = {
23
23
val x : List [Expr2 [SemanticInt .type ]] = List ()
24
- Liter (SemanticArray [SemanticInt .type ], x) // error // error
24
+ Liter (SemanticArray [SemanticInt .type ], x) // error
25
25
}
Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg/i18058.scala:4:21 ----------------------------------------------------------------------------------
2
+ 4 |type G = (f: _ <: F) => f.A // error
3
+ | ^
4
+ | invalid new prefix <: F cannot replace f.type in type f.A
Original file line number Diff line number Diff line change
1
+ trait F :
2
+ type A
3
+
4
+ type G = (f : _ <: F ) => f.A // error
You can’t perform that action at this time.
0 commit comments