File tree Expand file tree Collapse file tree 3 files changed +31
-15
lines changed
src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +31
-15
lines changed Original file line number Diff line number Diff line change @@ -837,14 +837,18 @@ class RefChecks extends MiniPhase { thisTransformer =>
837
837
if (tree.symbol is Macro ) EmptyTree else tree
838
838
}
839
839
840
- override def transformTemplate (tree : Template )(implicit ctx : Context , info : TransformerInfo ) = {
840
+ override def transformTemplate (tree : Template )(implicit ctx : Context , info : TransformerInfo ) = try {
841
841
val cls = ctx.owner
842
842
checkOverloadedRestrictions(cls)
843
843
checkParents(cls)
844
844
checkCompanionNameClashes(cls)
845
845
checkAllOverrides(cls)
846
846
checkDerivedValueClass(cls, tree.body)
847
847
tree
848
+ } catch {
849
+ case ex : MergeError =>
850
+ ctx.error(ex.getMessage, tree.pos)
851
+ tree
848
852
}
849
853
850
854
override def transformTypeTree (tree : TypeTree )(implicit ctx : Context , info : TransformerInfo ) = {
Original file line number Diff line number Diff line change 1
- // yet another variant, testing super accessors
2
-
3
- trait T {
4
- def foo [B ](x : C [B ]): C [B ]
1
+ // yet another variant, testing type parameters
2
+ trait T [X ] {
3
+ def foo (x : X ): X
5
4
}
6
- abstract class A extends T {
7
- type C [X ]
8
- def foo [B ](x : C [B ]): C [B ] = {println(" A.C" ); x}
9
- def foo [B ](x : List [B ]): List [B ] = {println(" A.List" ); x}
5
+ abstract class A [X ] extends T [X ] {
6
+ def foo (x : X ): X = {println(" A.X" ); x}
7
+ def foo (x : String ): String = {println(" A.String" ); x}
10
8
}
11
- trait U extends T {
12
- def foo [B ](x : C [B ]): C [B ] = super .foo[B ](x)
13
- }
14
- object Test extends A with U {
15
- type C [X ] = List [X ]
16
- def main (args : Array [String ]) = foo(List (" " ))
9
+ trait U [X ] extends T [X ] {
10
+ abstract override def foo (x : X ): X = super .foo(x)
17
11
}
12
+ object Test extends A [String ] with U [String ] // error: accidental override
Original file line number Diff line number Diff line change
1
+ // yet another variant, testing super accessors
2
+ // (but exhibited a crash in RefChecks).
3
+
4
+ trait T {
5
+ def foo [B ](x : C [B ]): C [B ]
6
+ }
7
+ abstract class A extends T {
8
+ type C [X ]
9
+ def foo [B ](x : C [B ]): C [B ] = {println(" A.C" ); x}
10
+ def foo [B ](x : List [B ]): List [B ] = {println(" A.List" ); x}
11
+ }
12
+ trait U extends T {
13
+ abstract override def foo [B ](x : C [B ]): C [B ] = super .foo[B ](x)
14
+ }
15
+ object Test extends A with U {
16
+ type C [X ] = List [X ]
17
+ }
You can’t perform that action at this time.
0 commit comments