Skip to content

Commit 224232d

Browse files
committed
Check AppliedTypeTrees bounds inside AppliedTypeTree
1 parent 06e18c6 commit 224232d

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,16 @@ object Checking {
5050

5151
/** Check all AppliedTypeTree nodes in this tree for legal bounds */
5252
val boundsChecker = new TreeTraverser {
53-
def traverse(tree: Tree)(implicit ctx: Context) = tree match {
54-
case AppliedTypeTree(tycon, args) =>
55-
val tparams = tycon.tpe.typeSymbol.typeParams
56-
val bounds = tparams.map(tparam =>
57-
tparam.info.asSeenFrom(tycon.tpe.normalizedPrefix, tparam.owner.owner).bounds)
58-
checkBounds(args, bounds, _.substDealias(tparams, _))
59-
case _ => traverseChildren(tree)
53+
def traverse(tree: Tree)(implicit ctx: Context) = {
54+
tree match {
55+
case AppliedTypeTree(tycon, args) =>
56+
val tparams = tycon.tpe.typeSymbol.typeParams
57+
val bounds = tparams.map(tparam =>
58+
tparam.info.asSeenFrom(tycon.tpe.normalizedPrefix, tparam.owner.owner).bounds)
59+
checkBounds(args, bounds, _.substDealias(tparams, _))
60+
case _ =>
61+
}
62+
traverseChildren(tree)
6063
}
6164
}
6265

test/dotc/tests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ class tests extends CompilerTest {
176176
@Test def neg_validateParsing = compileFile(negDir, "validate-parsing", xerrors = 7)
177177
@Test def neg_validateRefchecks = compileFile(negDir, "validate-refchecks", xerrors = 2)
178178
@Test def neg_skolemize = compileFile(negDir, "skolemize", xerrors = 2)
179+
@Test def neg_nested_bounds = compileFile(negDir, "nested_bounds", xerrors = 1)
179180

180181
@Test def run_all = runFiles(runDir)
181182

tests/neg/nested_bounds.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class OnlyInt[T <: Int]
2+
3+
object Test {
4+
type T = List[OnlyInt[String]] // error: Type argument String does not conform to upper bound Int
5+
}

0 commit comments

Comments
 (0)