Skip to content

Commit 5cdd42f

Browse files
committed
initial works
1 parent 07fd8a3 commit 5cdd42f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2693
-0
lines changed

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,17 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
5050
private var _id = 0 // left for debuging
5151

5252
override def transformMatch(tree: Match)(implicit ctx: Context, info: TransformerInfo): Tree = {
53+
val Match(sel, cases) = tree
54+
5355
val translated = new Translator()(ctx).translator.translateMatch(tree)
5456

57+
// check exhaustivity and unreachability
58+
val engine = new SpaceEngine
59+
if (!engine.skipCheck(sel.tpe)) {
60+
engine.exhaustivity(tree)
61+
engine.redundancy(tree)
62+
}
63+
5564
translated.ensureConforms(tree.tpe)
5665
}
5766

@@ -1275,6 +1284,7 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
12751284
case _ => (cases, None)
12761285
}
12771286

1287+
12781288
// checkMatchVariablePatterns(nonSyntheticCases) // only used for warnings
12791289

12801290
// we don't transform after uncurry

src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import Symbols._, TypeUtils._
3838
*
3939
* (9) Adds SourceFile annotations to all top-level classes and objects
4040
*
41+
* (10) Adds Child annotations to all sealed classes
42+
*
4143
* The reason for making this a macro transform is that some functions (in particular
4244
* super and protected accessors and instantiation checks) are naturally top-down and
4345
* don't lend themselves to the bottom-up approach of a mini phase. The other two functions
@@ -231,6 +233,13 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran
231233
ctx.compilationUnit.source.exists &&
232234
sym != defn.SourceFileAnnot)
233235
sym.addAnnotation(Annotation.makeSourceFile(ctx.compilationUnit.source.file.path))
236+
237+
if (!sym.isAnonymousClass) // ignore anonymous class
238+
for (parent <- sym.asClass.classInfo.classParents) {
239+
val pclazz = parent.classSymbol
240+
if (pclazz.is(Sealed)) pclazz.addAnnotation(Annotation.makeChild(sym))
241+
}
242+
234243
tree
235244
}
236245
else {

0 commit comments

Comments
 (0)