diff options
author | Martin Odersky <odersky@gmail.com> | 2016-01-31 23:55:27 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-02-09 09:43:06 +0100 |
commit | a0fb0685fcfc5e988e0d033af26c1055269488e5 (patch) | |
tree | 71916852f90187a91a99fdbe4ca3ca17a94f860c | |
parent | e87dee212351aa7acb15760814cdd1c30c4de019 (diff) | |
download | dotty-a0fb0685fcfc5e988e0d033af26c1055269488e5.tar.gz dotty-a0fb0685fcfc5e988e0d033af26c1055269488e5.tar.bz2 dotty-a0fb0685fcfc5e988e0d033af26c1055269488e5.zip |
Handle imports in path checks.
If `T` is a member of `p` then
{ import p._; ... T ... }
should be checked in the same way as
{ ... p.T ... }
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 2 | ||||
-rw-r--r-- | test/dotc/tests.scala | 2 | ||||
-rw-r--r-- | tests/neg/i1050.scala | 20 |
3 files changed, 12 insertions, 12 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index ce0a5c0f2..7894a5b5f 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -274,6 +274,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val tree1 = ownType match { case ownType: NamedType if !prefixIsElidable(ownType) => + checkRealizable(ownType.prefix, tree.pos) ref(ownType).withPos(tree.pos) case _ => tree.withType(ownType) @@ -991,6 +992,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit val impl1 = cpy.Template(impl)(constr1, parents1, self1, body1) .withType(dummy.nonMemberTermRef) checkVariance(impl1) + if (!cls.is(AbstractOrTrait)) checkRealizableBounds(cls.typeRef, cdef.pos) assignType(cpy.TypeDef(cdef)(name, impl1, Nil), cls) // todo later: check that diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 81fc277fa..e1a10a6e2 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -162,7 +162,7 @@ class tests extends CompilerTest { @Test def neg_i803 = compileFile(negDir, "i803", xerrors = 2) @Test def neg_i866 = compileFile(negDir, "i866", xerrors = 2) @Test def neg_i974 = compileFile(negDir, "i974", xerrors = 2) - @Test def neg_i1050 = compileFile(negDir, "i1050", xerrors = 6) + @Test def neg_i1050 = compileFile(negDir, "i1050", xerrors = 8) @Test def neg_i1050a = compileFile(negDir, "i1050a", xerrors = 2) @Test def neg_moduleSubtyping = compileFile(negDir, "moduleSubtyping", xerrors = 4) @Test def neg_escapingRefs = compileFile(negDir, "escapingRefs", xerrors = 2) diff --git a/tests/neg/i1050.scala b/tests/neg/i1050.scala index 047d9f776..25e647a57 100644 --- a/tests/neg/i1050.scala +++ b/tests/neg/i1050.scala @@ -40,7 +40,7 @@ object Tiark1 { trait B { type L >: Any} trait U { lazy val p: B - def brand(x: Any): p.L = x // error: not final + def brand(x: Any): p.L = x // error: nonfinal lazy } trait V extends U { lazy val p: A & B = ??? @@ -54,7 +54,7 @@ object Tiark2 { trait U { type X <: B lazy val p: X - def brand(x: Any): p.L = x // error: not final + def brand(x: Any): p.L = x // error: nonfinal lazy } trait V extends U { type X = B & A @@ -70,7 +70,7 @@ object Tiark3 { type X <: B def p2: X final lazy val p: X = p2 - def brand(x: Any): p.L = x + def brand(x: Any): p.L = x // error: underlying not concrete } trait V extends U { type X = B with A @@ -79,20 +79,18 @@ object Tiark3 { val v = new V {} v.brand("boom!"): Nothing } -/* object Import { trait A { type L <: Nothing } trait B { type L >: Any} trait U { - val p: B - def brand(x: Any): p.L = x // error: not final - locally { import p._ + lazy val p: B + locally { val x: p.L = ??? } // error: nonfinal lazy + locally { + import p._ + val x: L = ??? // error: nonfinal lazy } } trait V extends U { lazy val p: A & B = ??? - } - val v = new V {} - v.brand("boom!") } -*/ + |